Skip to content

Commit

Permalink
back to sync flush
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshnj committed Oct 4, 2024
1 parent 66bf92b commit 817a0e1
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions DatadogCore/Sources/Core/DatadogCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,13 @@ internal final class DatadogCore {
///
/// - Parameter trackingConsent: new consent value, which will be applied for all data collected from now on
func set(trackingConsent: TrackingConsent) {
// There could be events in the queue that were collected before the consent change
// but not written to the disk yet, which must be migrated to the new consent.
// We synchronize this by reading the context because to obtain a file writer, we need to read the context.
// which is performed via CoreFeatureScope.eventWriteContext(bypassConsent:,block:) API.
contextProvider.read { _ in
if trackingConsent != self.consentPublisher.consent {
self.allStorages.forEach {
$0.migrateUnauthorizedData(toConsent: trackingConsent)
}
self.consentPublisher.consent = trackingConsent
flush()

if trackingConsent != self.consentPublisher.consent {
self.allStorages.forEach {
$0.migrateUnauthorizedData(toConsent: trackingConsent)
}
self.consentPublisher.consent = trackingConsent
}
}

Expand Down

0 comments on commit 817a0e1

Please sign in to comment.