Skip to content

Conversation

@anikiki
Copy link
Contributor

@anikiki anikiki commented Dec 18, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1200581511062568/task/1212447038478340?focus=true

Description

Refactored OkHttp pixel interceptors to always proceed with the original request object when unchanged. Improved readability.

These changes maintain the same functionality while making the code more maintainable and potentially more efficient by reducing unnecessary object creation.

Steps to test this PR

Code review.
Tests are passing.

NO UI changes


Note

Standardizes multiple interceptors to early-return and reuse the original request unless modified, and adds a plugin to remove all params from the ATP TDS failure pixel.

  • Interceptors refactor (early returns, reuse originalRequest, only rebuild when URL changes):
    • App Tracking Protection:
      • vpn-impl/.../AppTPBlockListInterceptorApiPlugin.kt: Simplifies TDS experiment URL rewriting flow with early exits; only proceeds with modified URL when applicable.
      • vpn-impl/.../cohort/CohortPixelInterceptor.kt: Adds cohort param only when present; otherwise drops; otherwise proceeds unmodified.
    • Core App:
      • app/.../PixelParamRemovalInterceptor.kt: Computes flags for ATB/version removal; proceeds unmodified when not needed; rebuilds URL only if params removed.
      • app/.../PixelReQueryInterceptor.kt: Rewrites rq_*_android_{formFactor} only if present; otherwise proceeds unchanged.
      • app/.../CampaignPixelParamsAdditionInterceptor.kt: Adds campaign params only when eligible and feature-enabled; no-op otherwise.
    • Tracker Blocklist:
      • app/.../BlockListInterceptorApiPlugin.kt: Early-return when TDS not required or no active experiment; only rewrite to $TDS_BASE_URL when path resolved; fires failure pixel on non-2xx.
    • Attributed Metrics:
      • .../AttributedMetricPixelInterceptor.kt: Renames android_{phone} suffix to android only for attributed_metric*; otherwise unchanged.
    • Feature Toggles:
      • .../MetricPixelInterceptor.kt: Validates metrics pixels and proceeds using original request; drops invalid/out-of-window as before.
    • Network Protection:
      • .../NetpCohortPixelInterceptor.kt: Drops cohort pixels when no cohort; otherwise proceeds unchanged.
      • .../VpnLatencyPixelInterceptor.kt: Appends location and os15Above only for latency pixels; otherwise proceeds unchanged.
    • PIR:
      • .../PirPixelInterceptor.kt: Appends base64-encoded metadata only for relevant pixels; otherwise proceeds unchanged.
  • Plugins:
    • Adds MetricPixelRemovalInterceptor to remove all params for ATP_TDS_EXPERIMENT_DOWNLOAD_FAILED.

Written by Cursor Bugbot for commit 47f39ce. This will update automatically on new commits. Configure here.

…l request object when unchanged. Improve readability.
Copy link
Contributor Author

anikiki commented Dec 18, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@anikiki anikiki changed the title Refactor OkHttp pixel interceptors to always proceed with the original request object when unchanged. Improve readability. [Android]: Native poll once crash Dec 18, 2025
@anikiki anikiki marked this pull request as ready for review December 18, 2025 12:49
}

return chain.proceed(request.url(url).build())
logcat { "Pixel interceptor: $modifiedUrlString" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we see the log only if the interceptor modified the URL. I can move it up if we want to see the log for all intercepted requests, as it was before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant