Skip to content

Commit

Permalink
Merge pull request #14 from shortcut/main
Browse files Browse the repository at this point in the history
Release 6.0.3
  • Loading branch information
ardian4 committed May 23, 2024
2 parents 677bf6a + ef10a4a commit b7ba0ac
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 24 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Commercial SDK (c) 2016-2020 Kantar Sifo
Commercial SDK (c) 2016-2024 Kantar Media Sweden AB
14 changes: 14 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ The Sifo SDK is happy with whatever permissions your app uses.

## Release notes

6.0.3 2024-05-23
- Fixed bug related to the SifoInternet App
- Make default values to true for attributes: shouldSyncWithBackendFirst and shouldUseJsonUrlSchemeSyncFormat
- Update license to Commercial SDK (c) 2016-2024 Kantar Media Sweden AB
- No API changes

6.0.2 2024-03-13
- Fix double encoding issue
- Maintain order of query parameters
- No API changes

6.0.1 2024-02-27
- Add Privacy Manifest

6.0.0
- Complete Swift refactor of SDK
- No API changes
Expand Down
58 changes: 35 additions & 23 deletions Sources/TSMobileAnalytics/TSMobileAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public final class TSMobileAnalytics {
// TODO: Find a way to automate this.
/// This needs to be updated when a new release is made.
/// Swift Package version numbers are grabbed from the tags of the git repository.
static let sdkVersion = "6.0.0"
static let sdkVersion = "6.0.3"

static var shared: TSMobileAnalytics?
static let logger = ConsoleLogger()
Expand Down Expand Up @@ -69,11 +69,19 @@ public final class TSMobileAnalytics {
}

private var shouldSyncWithSifoInternetApp: Bool {
guard Storage.shared.sdkVersion != Self.sdkVersion,
let cookieString = Storage.shared.cookieString,
!cookieString.isEmpty
else { return true }


if(!isSifoInternetAppInstalled){
return false
}

if(Storage.shared.sdkVersion != Self.sdkVersion){
return true
}

if (Storage.shared.cookieString?.isEmpty ?? true){
return true
}

return false
}

Expand Down Expand Up @@ -102,8 +110,8 @@ public final class TSMobileAnalytics {
self.keychainAccessGroup = keychainAccessGroup
self.additionals = additionals

self.shouldSyncWithBackendFirst = additionals[Keys.shouldSyncWithBackendFirst] == StringBool.true.rawValue
self.shouldUseJsonUrlSchemeSyncFormat = additionals[Keys.shouldUseJsonUrlSchemeSyncFormat] == StringBool.true.rawValue
self.shouldSyncWithBackendFirst = additionals[Keys.shouldSyncWithBackendFirst] ?? "true" == StringBool.true.rawValue
self.shouldUseJsonUrlSchemeSyncFormat = additionals[Keys.shouldUseJsonUrlSchemeSyncFormat] ?? "true" == StringBool.true.rawValue

SDKIntegrationValidator.validate(applicationName: applicationName, cpid: cpid)

Expand Down Expand Up @@ -267,17 +275,14 @@ private extension TSMobileAnalytics {
guard isOldPanelUserInfoCached || isSifoInternetAppInstalled
else { return }

guard !IdentificationManager.shared.isSystemIdentifierTrackingEnabled,
!shouldSyncWithBackendFirst
else {
if (IdentificationManager.shared.isSystemIdentifierTrackingEnabled && shouldSyncWithBackendFirst) {
syncCookiesWithBackend()
return
}

if hostAppIncludesExpectedUrlScheme && shouldSyncWithSifoInternetApp {
syncTokenWithSifoInternetApp(additionals: additionals)
} else {
refreshCookies() { self.sendTagWithAppStart() }
if hostAppIncludesExpectedUrlScheme && shouldSyncWithSifoInternetApp {
syncTokenWithSifoInternetApp(additionals: additionals)
} else {
refreshCookies() { self.sendTagWithAppStart() }
}
}
}

Expand All @@ -296,10 +301,7 @@ private extension TSMobileAnalytics {
"Failed to sync with backend.",
"\(error)"],
verbosity: .error)

if !self.shouldSyncWithSifoInternetApp {
self.refreshCookies() { self.sendTagWithAppStart() }
}
onBackendSyncError()
case .success(let response):
Self.logger.log(
multipleLines: [
Expand All @@ -314,18 +316,28 @@ private extension TSMobileAnalytics {
"Failed to verify sync response.",
error.localizedDescription],
verbosity: .error)
onBackendSyncError()
return
}

Self.logger.log(
message: "Successfully synced with backend.",
verbosity: .info)

self.updateCookieString(from: response)
self.refreshCookies { self.sendTagWithAppStart() }
}
}
}

private func onBackendSyncError(){
// fallback to sync with panelist app
if self.shouldSyncWithSifoInternetApp {
syncTokenWithSifoInternetApp(additionals: additionals)
} else {
self.refreshCookies() { self.sendTagWithAppStart() }
}
}

func updateCookieString(from data: Data) {
guard let cookieString = JSONManager.urlEncodedJSON(from: data)
Expand Down
6 changes: 6 additions & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ using Kantar Sifo’s services. The SDK contains three folders:

RELEASE NOTES:

6.0.3 2024-05-23
- Fixed bug related to the SifoInternet App
- Make default values to true for attributes: shouldSyncWithBackendFirst and shouldUseJsonUrlSchemeSyncFormat
- Update license to Commercial SDK (c) 2016-2024 Kantar Media Sweden AB
- No API changes

6.0.2 2024-03-13
- Fix double encoding issue
- Maintain order of query parameters
Expand Down

0 comments on commit b7ba0ac

Please sign in to comment.