From e217b28d1a1ac2522b05522e970e364a1d0f1030 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Tue, 2 Aug 2022 12:48:24 -0500 Subject: [PATCH 1/9] Update: added firebase integration --- .../flutter_segment/FlutterSegmentOptions.java | 13 +++++++++++-- .../flutter_segment/FlutterSegmentPlugin.java | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/example/flutter_segment/FlutterSegmentOptions.java b/android/src/main/java/com/example/flutter_segment/FlutterSegmentOptions.java index 2c0975d9..49d3af13 100644 --- a/android/src/main/java/com/example/flutter_segment/FlutterSegmentOptions.java +++ b/android/src/main/java/com/example/flutter_segment/FlutterSegmentOptions.java @@ -9,6 +9,7 @@ public class FlutterSegmentOptions { private final Boolean trackApplicationLifecycleEvents; private final Boolean amplitudeIntegrationEnabled; private final Boolean appsflyerIntegrationEnabled; + private final Boolean firebaseIntegrationEnabled; private final Boolean debug; public FlutterSegmentOptions( @@ -16,12 +17,14 @@ public FlutterSegmentOptions( Boolean trackApplicationLifecycleEvents, Boolean amplitudeIntegrationEnabled, Boolean appsflyerIntegrationEnabled, + Boolean firebaseIntegrationEnabled, Boolean debug ) { this.writeKey = writeKey; this.trackApplicationLifecycleEvents = trackApplicationLifecycleEvents; this.amplitudeIntegrationEnabled = amplitudeIntegrationEnabled; this.appsflyerIntegrationEnabled = appsflyerIntegrationEnabled; + this.firebaseIntegrationEnabled = firebaseIntegrationEnabled; this.debug = debug; } @@ -41,6 +44,10 @@ public Boolean isAppsflyerIntegrationEnabled() { return appsflyerIntegrationEnabled; } + public Boolean isFirebaseIntegrationEnabled() { + return firebaseIntegrationEnabled; + } + public Boolean getDebug() { return debug; } @@ -50,8 +57,9 @@ static FlutterSegmentOptions create(Bundle bundle) { Boolean trackApplicationLifecycleEvents = bundle.getBoolean("com.claimsforce.segment.TRACK_APPLICATION_LIFECYCLE_EVENTS"); Boolean isAmplitudeIntegrationEnabled = bundle.getBoolean("com.claimsforce.segment.ENABLE_AMPLITUDE_INTEGRATION", false); Boolean isAppsflyerIntegrationEnabled = bundle.getBoolean("com.claimsforce.segment.ENABLE_APPSFLYER_INTEGRATION", false); + Boolean isFirebaseIntegrationEnabled = bundle.getBoolean("com.claimsforce.segment.ENABLE_FIREBASE_INTEGRATION", false); Boolean debug = bundle.getBoolean("com.claimsforce.segment.DEBUG", false); - return new FlutterSegmentOptions(writeKey, trackApplicationLifecycleEvents, isAmplitudeIntegrationEnabled, isAppsflyerIntegrationEnabled, debug); + return new FlutterSegmentOptions(writeKey, trackApplicationLifecycleEvents, isAmplitudeIntegrationEnabled, isAppsflyerIntegrationEnabled, isFirebaseIntegrationEnabled, debug); } static FlutterSegmentOptions create(HashMap options) { @@ -59,8 +67,9 @@ static FlutterSegmentOptions create(HashMap options) { Boolean trackApplicationLifecycleEvents = (Boolean) options.get("trackApplicationLifecycleEvents"); Boolean isAmplitudeIntegrationEnabled = orFalse((Boolean) options.get("amplitudeIntegrationEnabled")); Boolean isAppsflyerIntegrationEnabled = orFalse((Boolean) options.get("appsflyerIntegrationEnabled")); + Boolean isFirebaseIntegrationEnabled = orFalse((Boolean) options.get("firebaseIntegrationEnabled")); Boolean debug = orFalse((Boolean) options.get("debug")); - return new FlutterSegmentOptions(writeKey, trackApplicationLifecycleEvents, isAmplitudeIntegrationEnabled, isAppsflyerIntegrationEnabled, debug); + return new FlutterSegmentOptions(writeKey, trackApplicationLifecycleEvents, isAmplitudeIntegrationEnabled, isAppsflyerIntegrationEnabled, isFirebaseIntegrationEnabled, debug); } private static Boolean orFalse(Boolean value) { diff --git a/android/src/main/java/com/example/flutter_segment/FlutterSegmentPlugin.java b/android/src/main/java/com/example/flutter_segment/FlutterSegmentPlugin.java index 40b92236..ce996916 100644 --- a/android/src/main/java/com/example/flutter_segment/FlutterSegmentPlugin.java +++ b/android/src/main/java/com/example/flutter_segment/FlutterSegmentPlugin.java @@ -14,6 +14,7 @@ import com.segment.analytics.integrations.BasePayload; import com.segment.analytics.android.integrations.amplitude.AmplitudeIntegration; import com.segment.analytics.android.integrations.appsflyer.AppsflyerIntegration; +import com.segment.analytics.android.integrations.firebase.FirebaseIntegration; import static com.segment.analytics.Analytics.LogLevel; import androidx.annotation.NonNull; @@ -85,6 +86,10 @@ private void setupChannels(FlutterSegmentOptions options) { analyticsBuilder.use(AppsflyerIntegration.FACTORY); } + if (options.isFirebaseIntegrationEnabled()) { + analyticsBuilder.use(FirebaseIntegration.FACTORY); + } + // Here we build a middleware that just appends data to the current context // using the [deepMerge] strategy. analyticsBuilder.useSourceMiddleware( From a7c534a2dc27924cb235ecb84151be5ea4cc81ce Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Tue, 2 Aug 2022 14:49:52 -0500 Subject: [PATCH 2/9] Update: added firebase argument to segment config dart class --- lib/src/segment_config.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/segment_config.dart b/lib/src/segment_config.dart index 6dbdd660..261f9c35 100644 --- a/lib/src/segment_config.dart +++ b/lib/src/segment_config.dart @@ -4,6 +4,7 @@ class SegmentConfig { this.trackApplicationLifecycleEvents = false, this.amplitudeIntegrationEnabled = false, this.appsflyerIntegrationEnabled = false, + this.firebaseIntegrationEnabled = false, this.debug = false, }); @@ -11,6 +12,7 @@ class SegmentConfig { final bool trackApplicationLifecycleEvents; final bool amplitudeIntegrationEnabled; final bool appsflyerIntegrationEnabled; + final bool firebaseIntegrationEnabled; final bool debug; Map toMap() { @@ -19,6 +21,7 @@ class SegmentConfig { 'trackApplicationLifecycleEvents': trackApplicationLifecycleEvents, 'amplitudeIntegrationEnabled': amplitudeIntegrationEnabled, 'appsflyerIntegrationEnabled': appsflyerIntegrationEnabled, + 'firebaseIntegrationEnabled': firebaseIntegrationEnabled, 'debug': debug, }; } From ca20edd403b2a65b76a91c46cb6f3112b2da20f3 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 3 Aug 2022 09:59:36 -0500 Subject: [PATCH 3/9] Update: added segment firebase permissions and dependencies --- android/build.gradle | 6 ++++-- android/src/main/AndroidManifest.xml | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 469f463e..f78c6757 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,11 +5,11 @@ buildscript { repositories { google() mavenCentral() - } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.google.gms:google-services:3.1.0' } } @@ -17,6 +17,7 @@ rootProject.allprojects { repositories { google() mavenCentral() + maven { url 'https://maven.google.com' } } } @@ -37,9 +38,10 @@ android { implementation 'com.segment.analytics.android:analytics:4.10.4' implementation 'com.segment.analytics.android.integrations:amplitude:3.1.0' implementation 'com.appsflyer:segment-android-integration:6.5.2' + implementation 'com.segment.analytics.android.integrations:firebase:+@aar' } } dependencies { testImplementation 'junit:junit:4.13.2' -} \ No newline at end of file +} diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 48d11960..977799f1 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ + From 68951961955bdcc6e95beb7f5623c97e404edde5 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 3 Aug 2022 10:15:52 -0500 Subject: [PATCH 4/9] Update: added segment firebase to ios --- ios/Classes/FlutterSegmentPlugin.m | 11 +++++++++++ ios/flutter_segment.podspec | 1 + 2 files changed, 12 insertions(+) diff --git a/ios/Classes/FlutterSegmentPlugin.m b/ios/Classes/FlutterSegmentPlugin.m index 60eebf98..0b273e95 100644 --- a/ios/Classes/FlutterSegmentPlugin.m +++ b/ios/Classes/FlutterSegmentPlugin.m @@ -4,6 +4,7 @@ #import #import #import +#import @implementation FlutterSegmentPlugin // Contents to be appended to the context @@ -350,6 +351,7 @@ + (SEGAnalyticsConfiguration*)createConfigFromFile { NSString *writeKey = [dict objectForKey: @"com.claimsforce.segment.WRITE_KEY"]; BOOL trackApplicationLifecycleEvents = [[dict objectForKey: @"com.claimsforce.segment.TRACK_APPLICATION_LIFECYCLE_EVENTS"] boolValue]; BOOL isAmplitudeIntegrationEnabled = [[dict objectForKey: @"com.claimsforce.segment.ENABLE_AMPLITUDE_INTEGRATION"] boolValue]; + BOOL isFirebaseIntegrationEnabled = [[dict objectForKey: @"com.claimsforce.segment.ENABLE_FIREBASE_INTEGRATION"] boolValue]; if(!writeKey) { return nil; } @@ -360,6 +362,10 @@ + (SEGAnalyticsConfiguration*)createConfigFromFile { [configuration use:[SEGAmplitudeIntegrationFactory instance]]; } + if (isFirebaseIntegrationEnabled) { + [configuration use:[SEGFirebaseIntegrationFactory instance]]; + } + return configuration; } @@ -368,6 +374,7 @@ + (SEGAnalyticsConfiguration*)createConfigFromDict:(NSDictionary*) dict { BOOL trackApplicationLifecycleEvents = [[dict objectForKey: @"trackApplicationLifecycleEvents"] boolValue]; BOOL isAmplitudeIntegrationEnabled = [[dict objectForKey: @"amplitudeIntegrationEnabled"] boolValue]; BOOL isAppsflyerIntegrationEnabled = [[dict objectForKey: @"appsflyerIntegrationEnabled"] boolValue]; + BOOL isFirebaseIntegrationEnabled = [[dict objectForKey: @"firebaseIntegrationEnabled"] boolValue]; SEGAnalyticsConfiguration *configuration = [SEGAnalyticsConfiguration configurationWithWriteKey:writeKey]; configuration.trackApplicationLifecycleEvents = trackApplicationLifecycleEvents; @@ -379,6 +386,10 @@ + (SEGAnalyticsConfiguration*)createConfigFromDict:(NSDictionary*) dict { [configuration use:[SEGAppsFlyerIntegrationFactory instance]]; } + if (isFirebaseIntegrationEnabled) { + [configuration use:[SEGFirebaseIntegrationFactory instance]]; + } + return configuration; } diff --git a/ios/flutter_segment.podspec b/ios/flutter_segment.podspec index 40d406a0..c5a223ee 100644 --- a/ios/flutter_segment.podspec +++ b/ios/flutter_segment.podspec @@ -18,6 +18,7 @@ A new flutter plugin project. s.dependency 'Analytics', '4.1.6' s.dependency 'Segment-Amplitude', '3.3.2' s.dependency 'segment-appsflyer-ios', '6.5.2' + s.dependency 'Segment-Firebase', '2.7.9' s.ios.deployment_target = '11.0' # Added because Segment-Amplitude dependencies on iOS cause this error: From 2cb734c5d7ad4eb787c202bfa6a1013acfc80e92 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 3 Aug 2022 12:21:46 -0500 Subject: [PATCH 5/9] Fix: dependency issues --- android/build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index f78c6757..9f4193b6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -38,10 +38,12 @@ android { implementation 'com.segment.analytics.android:analytics:4.10.4' implementation 'com.segment.analytics.android.integrations:amplitude:3.1.0' implementation 'com.appsflyer:segment-android-integration:6.5.2' - implementation 'com.segment.analytics.android.integrations:firebase:+@aar' + implementation 'com.segment.analytics.android.integrations:firebase:2.3.3' } } dependencies { testImplementation 'junit:junit:4.13.2' } + +apply plugin: 'com.google.gms.google-services' \ No newline at end of file From 182a2a60bf7fae78e823e8bfaf1579cc2220290f Mon Sep 17 00:00:00 2001 From: Richar Cangui <69091719+RicharC293@users.noreply.github.com> Date: Wed, 3 Aug 2022 18:33:08 -0500 Subject: [PATCH 6/9] Update: build gradle --- android/build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 9f4193b6..08b5d125 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,7 +9,6 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.2.1' - classpath 'com.google.gms:google-services:3.1.0' } } @@ -38,7 +37,7 @@ android { implementation 'com.segment.analytics.android:analytics:4.10.4' implementation 'com.segment.analytics.android.integrations:amplitude:3.1.0' implementation 'com.appsflyer:segment-android-integration:6.5.2' - implementation 'com.segment.analytics.android.integrations:firebase:2.3.3' + implementation 'com.segment.analytics.android.integrations:firebase:+@aar' } } @@ -46,4 +45,3 @@ dependencies { testImplementation 'junit:junit:4.13.2' } -apply plugin: 'com.google.gms.google-services' \ No newline at end of file From 576fce018ca48720a82135310fb4bf314ce253d8 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Thu, 4 Aug 2022 09:55:25 -0500 Subject: [PATCH 7/9] Update: solved PR issues --- android/build.gradle | 3 +-- android/src/main/AndroidManifest.xml | 1 - ios/flutter_segment.podspec | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 08b5d125..593aa925 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -16,7 +16,6 @@ rootProject.allprojects { repositories { google() mavenCentral() - maven { url 'https://maven.google.com' } } } @@ -37,7 +36,7 @@ android { implementation 'com.segment.analytics.android:analytics:4.10.4' implementation 'com.segment.analytics.android.integrations:amplitude:3.1.0' implementation 'com.appsflyer:segment-android-integration:6.5.2' - implementation 'com.segment.analytics.android.integrations:firebase:+@aar' + implementation 'com.segment.analytics.android.integrations:firebase:2.3.3' } } diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 977799f1..48d11960 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - diff --git a/ios/flutter_segment.podspec b/ios/flutter_segment.podspec index c5a223ee..1ec81c77 100644 --- a/ios/flutter_segment.podspec +++ b/ios/flutter_segment.podspec @@ -18,7 +18,7 @@ A new flutter plugin project. s.dependency 'Analytics', '4.1.6' s.dependency 'Segment-Amplitude', '3.3.2' s.dependency 'segment-appsflyer-ios', '6.5.2' - s.dependency 'Segment-Firebase', '2.7.9' + s.dependency 'Segment-Firebase', '2.7.10' s.ios.deployment_target = '11.0' # Added because Segment-Amplitude dependencies on iOS cause this error: From 784eed7b5a199b13357c93b953257de90adfa483 Mon Sep 17 00:00:00 2001 From: Daan Van Ruijven Date: Fri, 4 Nov 2022 16:56:50 +0000 Subject: [PATCH 8/9] Updated build.gradle to use aar for firebase integrations --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 593aa925..69b00827 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -36,7 +36,7 @@ android { implementation 'com.segment.analytics.android:analytics:4.10.4' implementation 'com.segment.analytics.android.integrations:amplitude:3.1.0' implementation 'com.appsflyer:segment-android-integration:6.5.2' - implementation 'com.segment.analytics.android.integrations:firebase:2.3.3' + implementation 'com.segment.analytics.android.integrations:firebase:2.3.3@aar' } } From 078eab08ecc1eb74f181971a0ed10a8bec40b82b Mon Sep 17 00:00:00 2001 From: Daan Van Ruijven Date: Mon, 7 Nov 2022 15:44:31 +0000 Subject: [PATCH 9/9] Update Segment-Firebase pod version --- ios/flutter_segment.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/flutter_segment.podspec b/ios/flutter_segment.podspec index e5da56ff..bbb4205d 100644 --- a/ios/flutter_segment.podspec +++ b/ios/flutter_segment.podspec @@ -20,7 +20,7 @@ Library to let Flutter apps use Segment.io s.dependency 'Analytics', '4.1.6' s.dependency 'Segment-Amplitude', '3.3.2' s.dependency 'segment-appsflyer-ios', '6.8.0' - s.dependency 'Segment-Firebase', '2.7.10' + s.dependency 'Segment-Firebase', '2.7.11' s.ios.deployment_target = '11.0' # Added because Segment-Amplitude dependencies on iOS cause this error: