-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebase and Segment integration #291
Conversation
chore: added abstract layer for push notifications
chore: test braze
… if firebase enabled
…nd Segment managers
enabled = dictionary[SegmentKeys.enabled] as? Bool == true | ||
writeKey = dictionary[SegmentKeys.writeKey] as? String ?? "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make enabled
also dependent on writeKey
like the writeKey shouldn't be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -131,7 +131,7 @@ public class SignUpViewModel: ObservableObject { | |||
fields: validateFields, | |||
isSocial: externalToken != nil | |||
) | |||
analytics.setUserID("\(user.id)") | |||
analytics.identify(id: "\(user.id)", username: user.username, email: user.email) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving the analytics.identify(.....)
call to showMainOrWhatsNewScreen
so you don't have to worry about from where the main screen is being shown? At the moment it's being called from multiple places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like the idea of passing User variable inside the router. However, we may come back to this question when we work with analytics (this is not part of this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
import Firebase | ||
import Core | ||
|
||
class FirebaseAnalyticsManager: AnalyticsService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although we have collaborated on it and name is also fine, but as it's more like a tracker instead of manager, how about renaming it to FirebaseAnalyticsTracker
.
If it sounds good then the same will go for Segment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about FirebaseAnalyticsService
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.trackApplicationLifecycleEvents(true) | ||
.flushInterval(10) | ||
analytics = Analytics(configuration: configuration) | ||
if config.firebase.isAnalyticsSourceSegment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it got missed, please update condition for config.firebase.enabled
as well so in case of missing keys app will not crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
if let configuration = config.firebase.firebaseOptions { | ||
FirebaseApp.configure(options: configuration) | ||
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't remove that part of the code, Crashlytics will stop working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodymyr-chekyrta We've added FirebaseCrashlyticsCollectionEnabled in the info.plist, I believe this will do the job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Got it, let me check it out.
public init(config: ConfigProtocol) { | ||
guard config.firebase.enabled && config.firebase.isAnalyticsSourceFirebase else { return } | ||
|
||
FirebaseApp.configure() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't have the GoogleServices.plist file to configure Firebase, we have to pass the configuration to the configure function.
https://github.com/openedx/openedx-app-ios/blob/main/OpenEdX/AppDelegate.swift#L42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodymyr-chekyrta The config processing script is already generating the GoogleService-Info.plist
file by reading the values from the config for FIREBASE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rnr, LGTM 👍
@saeedbashir, thanks for comments
This PR implements both Analytics options -
Firebase+GoogleAnalytics
standalone library andSegment+GoogleAnalytics
.In the config we have the
ANALYTICS_SOURCE
parameter:This parameter may have values:
Depending on this parameter, the application uses the appropriate library. For this purpose,
FirebaseAnalyticsService
andSegmentAnalyticsService
are added. Both services are added to the DI.