Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 5 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 <netsoft1985@gmail.com>
Sarthak Verma <sarthak@artiosys.com>
Mike Diarmid <mike@invertase.io>
Invertase <oss@invertase.io>
Elliot Hesp <elliot@invertase.io>
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
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