Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[firebase_analytics] Add resetAnalyticsData method #1311

Merged
merged 8 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ Tuyển Vũ Xuân <[email protected]>
Sarthak Verma <[email protected]>
Mike Diarmid <[email protected]>
Invertase <[email protected]>
Elliot Hesp <[email protected]>
4 changes: 4 additions & 0 deletions packages/firebase_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.3

* Add resetAnalyticsData method

## 2.0.2+1

* Log messages about automatic configuration of the default app are now less confusing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public void onMethodCall(MethodCall call, Result result) {
case "setUserProperty":
handleSetUserProperty(call, result);
break;
case "resetAnalyticsData":
handleResetAnalyticsData(call, result);
break;
default:
result.notImplemented();
break;
Expand Down Expand Up @@ -123,6 +126,11 @@ private void handleSetUserProperty(MethodCall call, Result result) {
result.success(null);
}

private void handleResetAnalyticsData(MethodCall call, Result result) {
firebaseAnalytics.resetAnalyticsData();
result.success(null);
}

private static Bundle createBundleFromMap(Map<String, Object> map) {
if (map == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
NSNumber *enabled = [NSNumber numberWithBool:call.arguments];
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:[enabled boolValue]];
result(nil);
} else if ([@"resetAnalyticsData" isEqualToString:call.method]) {
[FIRAnalytics resetAnalyticsData];
result(nil);
} else {
result(FlutterMethodNotImplemented);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/firebase_analytics/lib/firebase_analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ class FirebaseAnalytics {
});
}

/// Clears all analytics data for this app from the device and resets the app instance id.
Future<void> resetAnalyticsData() async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await _channel.invokeMethod('resetAnalyticsData');
}

/// Logs the standard `add_payment_info` event.
///
/// This event signifies that a user has submitted their payment information
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Google Analytics for Firebase, an app measuremen
solution that provides insight on app usage and user engagement on Android and iOS.
author: Flutter Team <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_analytics
version: 2.0.2+1
version: 2.0.3

flutter:
plugin:
Expand Down
5 changes: 5 additions & 0 deletions packages/firebase_analytics/test/firebase_analytics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ void main() {
expect(invokedMethod, 'setSessionTimeoutDuration');
expect(arguments, 234);
});

test('resetAnalyticsData', () async {
await analytics.resetAnalyticsData();
expect(invokedMethod, 'resetAnalyticsData');
});
});

group('$FirebaseAnalytics analytics events', () {
Expand Down