Forward a compile-time agent id to native for test tooling - #1138
Draft
ctufts wants to merge 1 commit into
Draft
Conversation
Some of our internal test tooling needs to tag outbound requests made during automated test runs with an identifier, so that request volume generated by that tooling can be distinguished from real user traffic. That identifier is resolved at Dart compile time via `--dart-define=MAPBOX_AGENT=<id>` (never set in a normal app build) and now gets forwarded to the native side over the same per-map platform channel already used for other startup configuration, mirroring the existing `map#setMaxRequestsPerHost` handler. The native handlers on Android and iOS are currently placeholders: the underlying native API to actually apply the forwarded id doesn't exist in any released version of the native SDK dependency this plugin consumes yet, so calling it today would break the build. The handlers validate their arguments and no-op, with comments describing the exact one-line change to make once that native API ships. No public API changes. Builds that don't pass the dart-define are completely unaffected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this pull request do?
Adds test-only plumbing that forwards a compile-time identifier to the native side of this plugin, for use by our internal test tooling.
--dart-define=MAPBOX_AGENT=<id>(compiled into the Dart binary; empty by default).MethodChannelthis plugin already uses for other startup configuration (platform#setMapboxAgentId, mirroring the existingmap#setMaxRequestsPerHosthandler).The native Android/iOS handlers are placeholders for now: the native API this is meant to call doesn't exist in any released version of the native SDK dependency this plugin consumes, so wiring it up for real today would break compilation. Each handler validates its arguments and no-ops, with a comment describing the exact one-line change to make once that native API ships.
What is the motivation and context behind this change?
We're adding lightweight, opt-in tagging so our own test infrastructure can distinguish traffic it generates from real user traffic. This has no effect on the public API or on any app that doesn't explicitly pass the new
--dart-define.Testing
Covered by a unit test (
test/mapbox_maps_platform_test.dart) that checks both branches: no channel call when the define is absent, and a correctly-shaped call (platform#setMapboxAgentId,{'agentId': ...}) when it's present.flutter analyze,flutter test, anddart formatare all clean on the touched files. An integration test (example/integration_test/mapbox_agent_id_test.dart) renders a realMapWidgetand confirms it loads successfully whether or not the define is set, so this plumbing doesn't interfere with normal map creation.Not verified: the actual outbound
User-Agentheader, since the native forwarding call is still a no-op placeholder as described above. Once the native handlers are wired up in a future release, header-level verification belongs in that dependency's own HTTP-layer test suite rather than here.Pull request checklist:
@internal.)PRs must be submitted under the terms of our Contributor License Agreement CLA.