-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup - only batch analytics events with same sessionID (#1430)
* Create separate FPTI POST requests per sessionID --------- Co-authored-by: Sammy Cannillo <[email protected]>
- Loading branch information
Showing
5 changed files
with
65 additions
and
17 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
19 changes: 10 additions & 9 deletions
19
Sources/BraintreeCore/Analytics/BTAnalyticsEventsStorage.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 |
---|---|---|
@@ -1,27 +1,28 @@ | ||
import Foundation | ||
|
||
/// Used to store and access our array of events in a thread-safe manner | ||
/// Used to store and access our dictionary of events in a thread-safe manner | ||
actor BTAnalyticsEventsStorage { | ||
|
||
private var events: [FPTIBatchData.Event] | ||
// A list of analytic events, keyed by sessionID | ||
private var events: [String: [FPTIBatchData.Event]] | ||
|
||
var isEmpty: Bool { | ||
events.isEmpty | ||
} | ||
|
||
var allValues: [FPTIBatchData.Event] { | ||
var allValues: [String: [FPTIBatchData.Event]] { | ||
events | ||
} | ||
|
||
init() { | ||
self.events = [] | ||
self.events = [:] | ||
} | ||
|
||
func append(_ event: FPTIBatchData.Event) { | ||
events.append(event) | ||
func append(_ event: FPTIBatchData.Event, sessionID: String) { | ||
events[sessionID] = (events[sessionID] ?? []) + [event] | ||
} | ||
|
||
func removeAll() { | ||
events.removeAll() | ||
func removeFor(sessionID: String) { | ||
events.removeValue(forKey: sessionID) | ||
} | ||
} |
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