feat: add HTTP tracking and Clarity adapter#6
Conversation
There was a problem hiding this comment.
Bugbot free trial expires on July 29, 2025
Learn more in the Cursor dashboard.
| try { | ||
| _authClient = await auth.clientViaServiceAccount( | ||
| auth.ServiceAccountCredentials.fromJson(_config.credentials), | ||
| auth.ServiceAccountCredentials.fromJson(config.credentials), |
There was a problem hiding this comment.
Bug: Initialization Race Condition in Analytics Adapters
The _isInitialized flag is prematurely set to true before the actual initialization logic completes in several analytics and bug tracking adapters. This creates a race condition where an adapter may report as initialized even if the underlying service initialization fails.
Locations (7)
lib/src/analytics/adapters/engine_firebase_analytics_adapter.dart#L31-L39lib/src/analytics/adapters/engine_splunk_analytics_adapter.dart#L34-L42lib/src/analytics/adapters/engine_google_logging_analytics_adapter.dart#L35-L48lib/src/bug_tracking/adapters/engine_crashlytics_adapter.dart#L32-L42lib/src/analytics/adapters/engine_faro_analytics_adapter.dart#L32-L33lib/src/analytics/adapters/engine_clarity_adapter.dart#L32-L39lib/src/bug_tracking/adapters/engine_google_logging_bug_tracking_adapter.dart#L38-L51
|
|
||
| try { | ||
| _faro!.setUserMeta(userId: null, userEmail: null, userName: null); | ||
| _faro?.setUserMeta(userId: null, userEmail: null, userName: null); |
There was a problem hiding this comment.
Bug: Reset Method Executes Incorrectly
The reset() method in EngineFaroAnalyticsAdapter contains inverted logic. The condition if (isFaroInitialized) should be if (!isFaroInitialized). This prevents the reset functionality from executing when Faro is initialized and causes it to attempt a reset when it's not, contradicting the debug message and the method's intended purpose.
| Future<void> didPush(final Route<dynamic> route, final Route<dynamic>? previousRoute) async { | ||
| super.didPush(route, previousRoute); | ||
| await EngineAnalytics.setPage(route.settings.name ?? rootRouteName, previousRoute?.settings.name ?? rootRouteName); | ||
| await EngineAnalytics.setPage(route.settings.name ?? rootRouteName, previousRoute?.settings.name); |
There was a problem hiding this comment.
Bug: Analytics Bug: Inconsistent Previous Route Handling
The EngineNavigationObserver.didPush method inconsistently omits the ?? rootRouteName fallback for previousRoute?.settings.name when calling EngineAnalytics.setPage. This allows null to be passed, breaking the pattern used in didPop and didReplace and potentially causing issues in analytics systems expecting non-null previous screen names.
Locations (1)
|
|
||
| // Set the global override | ||
| HttpOverrides.global = engineOverride; | ||
| _isEnabled = true; |
There was a problem hiding this comment.
Bug: HttpOverrides Initialization Fails to Save Original State
The initialize method retrieves the existing HttpOverrides.current but fails to store it in the _previousOverride field. This prevents the disable method from restoring the original HttpOverrides, causing it to always set HttpOverrides.global = null.
Changes
EngineHttpTrackingIEngineConfiginterfaceTesting
Breaking Changes
None - all changes are backward compatible.