feat: Add telemetry support for flutter windows#829
Draft
NandanPrabhu wants to merge 1 commit into
Draft
Conversation
Mirrors the telemetry pattern used by Auth0.swift / iOS:
- auth0_client.h/cpp: new BuildAuth0ClientHeader(name, version) helper
that builds a base64url-encoded JSON payload:
{"name":"auth0-flutter","version":"x.y.z","env":{"Windows":"10.0"}}
and attaches it as the Auth0-Client header on every /oauth/token POST.
Windows version is read via RtlGetVersion (works on Windows 10+,
unlike the deprecated GetVersionEx).
- login_web_auth_request_handler.cpp: extracts the _userAgent map
(name + version) sent from the Dart layer, builds the header value,
and passes it through to Auth0Client.
- auth0_client_telemetry_test.cpp: unit tests for BuildAuth0ClientHeader
covering encoding correctness, absence of padding/standard-base64-chars,
and decodable JSON structure.
The Dart side already sends _userAgent in every WebAuthRequest (see
auth0_flutter_platform_interface/lib/src/request/request.dart:16).
Co-Authored-By: Claude Opus 4.6 <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.
📋 Changes
Adds the
Auth0-Clientinstrumentation/telemetry header to the Windows/oauth/tokenPOST requestNew —
BuildAuth0ClientHeader(name, version)helper (auth0_client.h/cpp):Auth0-ClientHTTP header:{"name":"auth0-flutter","version":"2.1.0","env":{"Windows":"10.0"}}RtlGetVersion(works correctly on Windows 10+ whereGetVersionExlies)Modified —
Auth0Clientclass (auth0_client.h/cpp):auth0ClientHeaderstring parameterExchangeCodeForTokensattaches theAuth0-Clientheader on the token exchange request when the value is non-emptyModified —
LoginWebAuthRequestHandler(login_web_auth_request_handler.cpp):_userAgentmap (name+version) from Dart method call argumentsBuildAuth0ClientHeader(name, version)and passes the result intoAuth0Client_userAgenton everyWebAuthRequestvia the platform interfaceRequestbase class — no Dart changes neededPlatform consistency:
{"iOS":"17.0","swift":"5.9"}{"android":"34"}{"Windows":"10.0"}All platforms use the same JSON schema and base64url encoding.
📎 References
Auth0/Telemetry.swift(setsAuth0-Clientheader on every request)_userAgentsource:auth0_flutter_platform_interface/lib/src/request/request.dart:16🎯 Testing
Automated (5 unit tests in
auth0_client_telemetry_test.cpp):IsNotEmpty— header is always producedContainsNoBase64Padding— no=padding charactersContainsNoStandardBase64Chars—+→-,/→_DecodestoValidJson— decoded payload contains expected name, version, env, and Windows keysEmptyNameAndVersionStillProducesValidHeader— graceful fallback when Dart doesn't supply agent infoManual verification:
Auth0-Clientheader is present on the/oauth/tokenrequest