-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ios): replace AnalyticsService with swift-utilities Analytic…
…sService
- Loading branch information
1 parent
10b37f7
commit 3eca943
Showing
27 changed files
with
216 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 0 additions & 102 deletions
102
ios/Approach/Sources/AnalyticsService/AnalyticsService+Live.swift
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
ios/Approach/Sources/AnalyticsService/BreadcrumbService+Live.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import AnalyticsServiceInterface | ||
import Dependencies | ||
import Sentry | ||
|
||
extension BreadcrumbService: DependencyKey { | ||
public static var liveValue: Self { | ||
Self( | ||
drop: { breadcrumb in | ||
let crumb = Sentry.Breadcrumb(level: .info, category: breadcrumb.category.rawValue) | ||
crumb.message = breadcrumb.message | ||
SentrySDK.addBreadcrumb(crumb) | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import AnalyticsServiceInterface | ||
import Dependencies | ||
import Sentry | ||
|
||
extension CrashGenerator: DependencyKey { | ||
public static var liveValue: Self { | ||
return Self { SentrySDK.crash() } | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
ios/Approach/Sources/AnalyticsService/GameAnalyticsService+Live.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import AnalyticsPackageServiceInterface | ||
import AnalyticsServiceInterface | ||
import Dependencies | ||
import Foundation | ||
|
||
extension GameAnalyticsService: DependencyKey { | ||
public static var liveValue: Self { | ||
let sessionID = ActorIsolated<UUID?>(nil) | ||
let sessions = ActorIsolated<[UUID: Set<UUID>]>([:]) | ||
|
||
return Self( | ||
trackEvent: { event in | ||
if let session = await sessionID.value { | ||
let inserted = await sessions.withValue { | ||
$0[session, default: []].insert(event.eventId).inserted | ||
} | ||
|
||
if !inserted { | ||
return | ||
} | ||
} | ||
|
||
@Dependency(\.analytics) var analytics | ||
let basicEvent = BasicEvent(name: event.name, payload: event.payload) | ||
try? await analytics.trackEvent(basicEvent) | ||
}, | ||
resetGameSessionID: { | ||
@Dependency(\.uuid) var uuid | ||
await sessionID.setValue(uuid()) | ||
} | ||
) | ||
} | ||
} | ||
|
||
private struct BasicEvent: TrackableEvent { | ||
let name: String | ||
let payload: [String: String]? | ||
} |
15 changes: 2 additions & 13 deletions
15
ios/Approach/Sources/AnalyticsServiceInterface/Analytics.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
ios/Approach/Sources/AnalyticsServiceInterface/AnalyticsService+Interface.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.