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 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
6 changes: 6 additions & 0 deletions packages/firebase_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 5.0.0

* Android : Remove deprecated method `setMinimumSessionDuration`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can you make this more consistent with other CHANGELOG entries, e.g. the one below it.? Make sure to indicate the removal of methods as a breaking change.

* Android : AGP and gradle update.
* Android : Remove redundant castings.

## 4.0.2

* Update google-services Android gradle plugin to 4.3.0 in documentation and examples.
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_analytics/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:3.4.2'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,14 @@ public void onMethodCall(MethodCall call, Result result) {
case "setAnalyticsCollectionEnabled":
handleSetAnalyticsCollectionEnabled(call, result);
break;
case "setMinimumSessionDuration":
handleSetMinimumSessionDuration(call, result);
break;
case "setSessionTimeoutDuration":
handleSetSessionTimeoutDuration(call, result);
break;
case "setUserProperty":
handleSetUserProperty(call, result);
break;
case "resetAnalyticsData":
handleResetAnalyticsData(call, result);
handleResetAnalyticsData(result);
break;
default:
result.notImplemented();
Expand All @@ -66,13 +63,10 @@ public void onMethodCall(MethodCall call, Result result) {
}

private void handleLogEvent(MethodCall call, Result result) {
@SuppressWarnings("unchecked")
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
final String eventName = (String) arguments.get("name");

@SuppressWarnings("unchecked")
final Bundle parameterBundle =
createBundleFromMap((Map<String, Object>) arguments.get("parameters"));
final String eventName = call.argument("name");
final Map<String, Object> map = call.argument("parameters");
final Bundle parameterBundle = createBundleFromMap(map);
firebaseAnalytics.logEvent(eventName, parameterBundle);
result.success(null);
}
Expand All @@ -84,49 +78,40 @@ private void handleSetUserId(MethodCall call, Result result) {
}

private void handleSetCurrentScreen(MethodCall call, Result result) {
@SuppressWarnings("unchecked")
Activity activity = registrar.activity();
if (activity == null) {
result.error("no_activity", "handleSetCurrentScreen requires a foreground activity", null);
return;
}
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
final String screenName = (String) arguments.get("screenName");
final String screenClassOverride = (String) arguments.get("screenClassOverride");

final String screenName = call.argument("screenName");
final String screenClassOverride = call.argument("screenClassOverride");

firebaseAnalytics.setCurrentScreen(activity, screenName, screenClassOverride);
result.success(null);
}

private void handleSetAnalyticsCollectionEnabled(MethodCall call, Result result) {
final Boolean enabled = (Boolean) call.arguments;
final Boolean enabled = call.arguments();
firebaseAnalytics.setAnalyticsCollectionEnabled(enabled);
result.success(null);
}

private void handleSetMinimumSessionDuration(MethodCall call, Result result) {
final Integer milliseconds = (Integer) call.arguments;
firebaseAnalytics.setMinimumSessionDuration(milliseconds);
result.success(null);
}

private void handleSetSessionTimeoutDuration(MethodCall call, Result result) {
final Integer milliseconds = (Integer) call.arguments;
final Integer milliseconds = call.arguments();
firebaseAnalytics.setSessionTimeoutDuration(milliseconds);
result.success(null);
}

private void handleSetUserProperty(MethodCall call, Result result) {
@SuppressWarnings("unchecked")
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
final String name = (String) arguments.get("name");
final String value = (String) arguments.get("value");
final String name = call.argument("name");
final String value = call.argument("value");

firebaseAnalytics.setUserProperty(name, value);
result.success(null);
}

private void handleResetAnalyticsData(MethodCall call, Result result) {
private void handleResetAnalyticsData(Result result) {
firebaseAnalytics.resetAnalyticsData();
result.success(null);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_analytics/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.3.0'
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Wed Jul 31 23:52:55 BRT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
9 changes: 0 additions & 9 deletions packages/firebase_analytics/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ class _MyHomePageState extends State<MyHomePage> {
setMessage('setAnalyticsCollectionEnabled succeeded');
}

Future<void> _testSetMinimumSessionDuration() async {
await analytics.android?.setMinimumSessionDuration(20000);
setMessage('setMinimumSessionDuration succeeded');
}

Future<void> _testSetSessionTimeoutDuration() async {
await analytics.android?.setSessionTimeoutDuration(2000000);
setMessage('setSessionTimeoutDuration succeeded');
Expand Down Expand Up @@ -298,10 +293,6 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Text('Test setAnalyticsCollectionEnabled'),
onPressed: _testSetAnalyticsCollectionEnabled,
),
MaterialButton(
child: const Text('Test setMinimumSessionDuration'),
onPressed: _testSetMinimumSessionDuration,
),
MaterialButton(
child: const Text('Test setSessionTimeoutDuration'),
onPressed: _testSetSessionTimeoutDuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
expect(analytics.android, isNull);
}
if (Platform.isAndroid) {
await analytics.android.setMinimumSessionDuration(9000);
await analytics.android.setAnalyticsCollectionEnabled(true);
}
});

Expand Down
15 changes: 1 addition & 14 deletions packages/firebase_analytics/lib/firebase_analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FirebaseAnalytics {
/// Example:
///
/// FirebaseAnalytics analytics = FirebaseAnalytics();
/// analytics.android?.setMinimumSessionDuration(200000);
/// analytics.android?.setAnalyticsCollectionEnabled(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be less confusing to use setSessionTimeoutDuration since setAnalyticsCollectionEnabled is on the main class.

Also, since we're doing a breaking change here it might make sense to remove setAnalyticsCollectionEnabled from the FirebaseAnalyticsAndroid

final FirebaseAnalyticsAndroid android =
defaultTargetPlatform == TargetPlatform.android
? FirebaseAnalyticsAndroid()
Expand Down Expand Up @@ -874,26 +874,13 @@ class FirebaseAnalyticsAndroid {
/// Sets whether analytics collection is enabled for this app on this device.
///
/// This setting is persisted across app sessions. By default it is enabled.
/// Deprecated: Use [FirebaseAnalytics.setAnalyticsCollectionEnabled] instead.
@deprecated
Future<void> setAnalyticsCollectionEnabled(bool enabled) async {
if (enabled == null) {
throw ArgumentError.notNull('enabled');
}
await _channel.invokeMethod<void>('setAnalyticsCollectionEnabled', enabled);
}

/// Sets the minimum engagement time required before starting a session.
///
/// The default value is 10000 (10 seconds).
Future<void> setMinimumSessionDuration(int milliseconds) async {
if (milliseconds == null) {
throw ArgumentError.notNull('milliseconds');
}
await _channel.invokeMethod<void>(
'setMinimumSessionDuration', milliseconds);
}

/// Sets the duration of inactivity that terminates the current session.
///
/// The default value is 1800000 (30 minutes).
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 <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_analytics
version: 4.0.2
version: 5.0.0

flutter:
plugin:
Expand Down
11 changes: 0 additions & 11 deletions packages/firebase_analytics/test/firebase_analytics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,6 @@ void main() {
);
});

test('setMinimumSessionDuration', () async {
await analytics.android.setMinimumSessionDuration(123);
expect(
methodCall,
isMethodCall(
'setMinimumSessionDuration',
arguments: 123,
),
);
});

test('setSessionTimeoutDuration', () async {
await analytics.android.setSessionTimeoutDuration(234);
expect(
Expand Down