-
Notifications
You must be signed in to change notification settings - Fork 121
[Local catalog] Analytics for sync, launch, and loading #16345
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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
769a947
Analytics for local catalog
joshheald 651f1e2
Improve local catalog analytics error handling
joshheald 06400b5
Add splash screen error analytics tracking
joshheald 494b199
Fir lint
joshheald 4d228db
Track error type for catalog sync errors
joshheald 7a5fd94
Add analytics tracking to incremental catalog sync
joshheald 1589150
Add unit tests for local catalog analytics tracking
joshheald 9775114
Remove unnecessary periphery ignores
joshheald 166e309
Track database full errors
joshheald 997ffaf
Classify errors based on their types
joshheald e87b5f7
Fix lint, unused code, and mistaken testing commit
joshheald f41d046
Merge branch 'feat/WOOMOB-1173-background-catalog-download-updated' i…
joshheald 9ffb8bb
Improve test timing/blocking approach
joshheald 24615de
Merge branch 'feat/WOOMOB-1173-parse-catalog-downloads-in-the-backgro…
joshheald aac839e
Merge branch 'feat/WOOMOB-1173-parse-catalog-downloads-in-the-backgro…
joshheald cd8784e
Improve classification of AFErrors
joshheald 93604af
Decorate catalog analytics with POS
joshheald e110275
Track skipped syncs
joshheald 8071a33
Ensure catalog events are tracked even when POS not active
joshheald 83b3161
Track incremental sync counts
joshheald eaccdda
Track full sync counts
joshheald 1b19fa9
Update tests to return catalog
joshheald 5001954
Use task to ensure we only log syncing event once per cycle
joshheald 4a05010
Simplify error classification by removing redundant switch cases
joshheald 1a2b55b
Refactor WaitingTimeTracker to follow DRY principle
joshheald f40615d
Add type safety and reduce code duplication in sync coordinator
joshheald 50e3729
Remove explicit nil parameter in coordinator initialization
joshheald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -32,11 +32,12 @@ public class WaitingTimeTracker { | |
| /// and returning an analytics event for tracking. | ||
| /// | ||
| /// - Parameter trackingUnit: Defines whether the elapsed time should be tracked in `.seconds` or `.milliseconds` (default is `.seconds`). | ||
| /// - Parameter additionalProperties: Optional additional properties to include in the analytics event. | ||
| /// - Returns: The analytics event to be tracked. | ||
| /// | ||
| public func end(using trackingUnit: TrackingUnit = .seconds) -> WooAnalyticsEvent { | ||
| public func end(using trackingUnit: TrackingUnit = .seconds, additionalProperties: [String: String] = [:]) -> WooAnalyticsEvent { | ||
| let elapsedTime = calculateElapsedTime(in: trackingUnit) | ||
| return .WaitingTime.waitingFinished(scenario: trackScenario, elapsedTime: elapsedTime) | ||
| return .WaitingTime.waitingFinished(scenario: trackScenario, elapsedTime: elapsedTime, additionalProperties: additionalProperties) | ||
| } | ||
|
|
||
| /// Calculates elapsed time in the specified tracking unit. | ||
|
|
@@ -66,20 +67,40 @@ public extension WooAnalyticsEvent { | |
| static let millisecondsTimeElapsedInSplashScreen = "milliseconds_time_elapsed_in_splash_screen" | ||
| } | ||
|
|
||
| static func waitingFinished(scenario: Scenario, elapsedTime: TimeInterval) -> WooAnalyticsEvent { | ||
| static func waitingFinished(scenario: Scenario, | ||
| elapsedTime: TimeInterval, | ||
| additionalProperties: [String: String] = [:]) -> WooAnalyticsEvent { | ||
| // Convert additional properties to WooAnalyticsEventPropertyType | ||
| let typedAdditionalProperties: [String: WooAnalyticsEventPropertyType] = | ||
| additionalProperties.mapValues { $0 as WooAnalyticsEventPropertyType } | ||
|
|
||
| switch scenario { | ||
| case .orderDetails: | ||
| return WooAnalyticsEvent(statName: .orderDetailWaitingTimeLoaded, properties: [Keys.waitingTime: elapsedTime]) | ||
| return WooAnalyticsEvent( | ||
| statName: .orderDetailWaitingTimeLoaded, | ||
| properties: [Keys.waitingTime: elapsedTime].merging(typedAdditionalProperties) { $1 }) | ||
|
||
| case .dashboardTopPerformers: | ||
| return WooAnalyticsEvent(statName: .dashboardTopPerformersWaitingTimeLoaded, properties: [Keys.waitingTime: elapsedTime]) | ||
| return WooAnalyticsEvent( | ||
| statName: .dashboardTopPerformersWaitingTimeLoaded, | ||
| properties: [Keys.waitingTime: elapsedTime].merging(typedAdditionalProperties) { $1 }) | ||
| case .dashboardMainStats: | ||
| return WooAnalyticsEvent(statName: .dashboardMainStatsWaitingTimeLoaded, properties: [Keys.waitingTime: elapsedTime]) | ||
| return WooAnalyticsEvent( | ||
| statName: .dashboardMainStatsWaitingTimeLoaded, | ||
| properties: [Keys.waitingTime: elapsedTime].merging(typedAdditionalProperties) { $1 }) | ||
| case .analyticsHub: | ||
| return WooAnalyticsEvent(statName: .analyticsHubWaitingTimeLoaded, properties: [Keys.waitingTime: elapsedTime]) | ||
| return WooAnalyticsEvent( | ||
| statName: .analyticsHubWaitingTimeLoaded, | ||
| properties: [Keys.waitingTime: elapsedTime].merging(typedAdditionalProperties) { $1 }) | ||
| case .appStartup: | ||
| return WooAnalyticsEvent(statName: .applicationOpenedWaitingTimeLoaded, properties: [Keys.waitingTime: elapsedTime]) | ||
| return WooAnalyticsEvent( | ||
| statName: .applicationOpenedWaitingTimeLoaded, | ||
| properties: [Keys.waitingTime: elapsedTime].merging(typedAdditionalProperties) { $1 }) | ||
| case .pointOfSaleLoaded: | ||
| return WooAnalyticsEvent(statName: .pointOfSaleLoaded, properties: [Keys.millisecondsTimeElapsedInSplashScreen: elapsedTime]) | ||
| let properties: [String: WooAnalyticsEventPropertyType] = | ||
| [Keys.millisecondsTimeElapsedInSplashScreen: elapsedTime] | ||
| return WooAnalyticsEvent( | ||
| statName: .pointOfSaleLoaded, | ||
| properties: properties.merging(typedAdditionalProperties) { $1 }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we do this on the view's init to avoid tracking multiple events on potential view recreation?