Skip to content

Commit

Permalink
feat: Crashlytics Integration with FullStory (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
shafqat-muneer authored Aug 15, 2024
1 parent 8328432 commit 98a2e27
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions OpenEdX/DI/AppAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ class AppAssembly: Assembly {
FirebaseAnalyticsService()
}.inObjectScope(.container)

container.register(FullStoryAnalyticsService.self) { r in
FullStoryAnalyticsService()
container.register(FullStoryAnalyticsService.self) { _, firebaseEnabled in
FullStoryAnalyticsService(firebaseEnabled)
}.inObjectScope(.container)

container.register(PipManagerProtocol.self) { r in
Expand Down
5 changes: 4 additions & 1 deletion OpenEdX/Managers/AnalyticsManager/AnalyticsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ class AnalyticsManager: AuthorizationAnalytics,
}

if config.fullStory.enabled,
let fullStoryService = Container.shared.resolve(FullStoryAnalyticsService.self) {
let fullStoryService = Container.shared.resolve(
FullStoryAnalyticsService.self,
argument: config.firebase.enabled
) {
analyticsServices.append(fullStoryService)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
import Foundation
import Core
import FullStory
import FirebaseCrashlytics

class FullStoryAnalyticsService: AnalyticsService {
class FullStoryAnalyticsService: NSObject, AnalyticsService, FSDelegate {

var firebaseEnabled: Bool
init(_ firebaseEnabled: Bool) {
self.firebaseEnabled = firebaseEnabled
super.init()
FS.delegate = self
}

func identify(id: String, username: String?, email: String?) {
FS.identify(id, userVars: ["displayName": id])
Expand All @@ -22,4 +30,13 @@ class FullStoryAnalyticsService: AnalyticsService {
func logScreenEvent(_ event: Core.AnalyticsEvent, parameters: [String: Any]?) {
FS.page(withName: event.rawValue, properties: parameters).start()
}

func fullstoryDidStartSession(_ sessionUrl: String) {
if firebaseEnabled {
Crashlytics.crashlytics().setCustomValue(
sessionUrl,
forKey: "fullstory_session_url"
)
}
}
}

0 comments on commit 98a2e27

Please sign in to comment.