Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.8.8+1

- Edit to error handler to not use default `Analytic.send` method and use new `Analytics._sendError` method that doesn't create a session id

## 5.8.8

- [Bug fix](https://github.com/dart-lang/tools/issues/252) rewrite the other call site for the session file
Expand Down
4 changes: 4 additions & 0 deletions pkgs/unified_analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
[![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics)
[![package publisher](https://img.shields.io/pub/publisher/unified_analytics.svg)](https://pub.dev/packages/unified_analytics/publisher)

## Hotfix `5.8.8+1` special release for Flutter 3.22

[Diff](https://github.com/dart-lang/tools/compare/unified_analytics-v5.8.8...hotfix-analytics-5.8.8+1?expand=1) between `5.8.8` and this hotfix release.

## What's this?

This package is intended to be used on Dart and Flutter related
Expand Down
43 changes: 42 additions & 1 deletion pkgs/unified_analytics/lib/src/analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:io' as io;

import 'package:clock/clock.dart';
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:file/memory.dart';
Expand Down Expand Up @@ -420,7 +421,7 @@ class AnalyticsImpl implements Analytics {

// Initialization for the error handling class that will prevent duplicate
// [Event.analyticsException] events from being sent to GA4
_errorHandler = ErrorHandler(sendFunction: send);
_errorHandler = ErrorHandler(sendFunction: _sendError);

// Initialize the user property class that will be attached to
// each event that is sent to Google Analytics -- it will be responsible
Expand Down Expand Up @@ -706,6 +707,46 @@ class AnalyticsImpl implements Analytics {
_surveyHandler.dismiss(survey, false);
send(Event.surveyShown(surveyId: survey.uniqueId));
}

/// Private method for sending an instance of [Event] that does not create
/// a session id, which was found to cause a stack overflow error.
void _sendError(Event event) {
if (!okToSend) return;

// Construct the body of the request
//
// This hard codes the session id to the current timestamp and doesn't
// try to parse the session json file again when attempting to send an error
final body = {
'client_id': _clientId,
'events': <Map<String, Object?>>[
<String, Object?>{
'name': event.eventName.label,
'params': event.eventData,
}
],
'user_properties': <String, Map<String, Object?>>{
'session_id': {'value': clock.now().millisecondsSinceEpoch},
'flutter_channel': {'value': userProperty.flutterChannel},
'flutter_version': {'value': userProperty.flutterVersion},
'host': {'value': userProperty.host},
'dart_version': {'value': userProperty.dartVersion},
'analytics_pkg_version': {'value': kPackageVersion},
'tool': {'value': userProperty.tool},
'local_time': {'value': formatDateTime(clock.now())},
'host_os_version': {'value': userProperty.hostOsVersion},
'locale': {'value': userProperty.locale},
'client_ide': {'value': userProperty.clientIde},
'enabled_features': {'value': userProperty.enabledFeatures},
},
};

if (_enableAsserts) checkBody(body);

final gaClientFuture = _gaClient.sendData(body);
_futures.add(gaClientFuture);
gaClientFuture.whenComplete(() => _futures.remove(gaClientFuture));
}
}

/// This fake instance of [Analytics] is intended to be used by clients of
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const int kLogFileLength = 2500;
const String kLogFileName = 'dart-flutter-telemetry.log';

/// The current version of the package, should be in line with pubspec version.
const String kPackageVersion = '5.8.8';
const String kPackageVersion = '5.8.8+1';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: >-
to Google Analytics.
# When updating this, keep the version consistent with the changelog and the
# value in lib/src/constants.dart.
version: 5.8.8
version: 5.8.8+1
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics

environment:
Expand Down