-
Notifications
You must be signed in to change notification settings - Fork 78
persistent deviceId #910
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
Open
Kuhash
wants to merge
1
commit into
Iterable:master
Choose a base branch
from
flip-shop:persistent-deviceId
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
persistent deviceId #910
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -10,8 +10,8 @@ class LocalStorageTests: XCTestCase { | |
override func setUp() { | ||
super.setUp() | ||
|
||
LocalStorageTests.clearTestUserDefaults() | ||
LocalStorageTests.clearTestKeychain() | ||
Self.clearTestUserDefaults() | ||
Self.clearTestKeychain() | ||
} | ||
|
||
static let localStorageTestSuiteName = "localstorage.tests" | ||
|
@@ -37,7 +37,7 @@ class LocalStorageTests: XCTestCase { | |
} | ||
|
||
func testUserIdAndEmail() throws { | ||
var localStorage = LocalStorage(userDefaults: LocalStorageTests.getTestUserDefaults()) | ||
var localStorage = LocalStorage(userDefaults: Self.getTestUserDefaults()) | ||
let userId = "zeeUserId" | ||
let email = "[email protected]" | ||
localStorage.userId = userId | ||
|
@@ -48,7 +48,7 @@ class LocalStorageTests: XCTestCase { | |
} | ||
|
||
func testAuthDataInKeychain() { | ||
let testUserDefaults = LocalStorageTests.getTestUserDefaults() | ||
let testUserDefaults = Self.getTestUserDefaults() | ||
let testKeychain = IterableKeychain.init(wrapper: KeychainWrapper.init(serviceName: "test-localstorage")) | ||
|
||
var localStorage = LocalStorage(userDefaults: testUserDefaults, | ||
|
@@ -80,7 +80,7 @@ class LocalStorageTests: XCTestCase { | |
} | ||
|
||
func testDDLChecked() throws { | ||
var localStorage = LocalStorage(userDefaults: LocalStorageTests.getTestUserDefaults()) | ||
var localStorage = LocalStorage(userDefaults: Self.getTestUserDefaults()) | ||
localStorage.ddlChecked = true | ||
XCTAssertTrue(localStorage.ddlChecked) | ||
|
||
|
@@ -90,7 +90,7 @@ class LocalStorageTests: XCTestCase { | |
|
||
func testAttributionInfo() throws { | ||
let mockDateProvider = MockDateProvider() | ||
let localStorage = LocalStorage(userDefaults: LocalStorageTests.getTestUserDefaults()) | ||
let localStorage = LocalStorage(userDefaults: Self.getTestUserDefaults()) | ||
let attributionInfo = IterableAttributionInfo(campaignId: 1, templateId: 2, messageId: "3") | ||
let currentDate = Date() | ||
let expiration = Calendar.current.date(byAdding: Calendar.Component.hour, value: 24, to: currentDate)! | ||
|
@@ -109,21 +109,27 @@ class LocalStorageTests: XCTestCase { | |
} | ||
|
||
func testDeviceId() { | ||
var localStorage = LocalStorage(userDefaults: LocalStorageTests.getTestUserDefaults()) | ||
let deviceId = UUID().uuidString | ||
localStorage.deviceId = deviceId | ||
let localStorage = LocalStorage(userDefaults: Self.getTestUserDefaults()) | ||
let deviceId = "AAAABBBB-CCCC-DDDD-EEEE-FFFFGGGGHHHH" | ||
IterableUserDefaults(userDefaults: Self.getTestUserDefaults()).deviceId = deviceId | ||
XCTAssertEqual(localStorage.deviceId, deviceId) | ||
} | ||
|
||
func testKeychainDeviceId() { | ||
let localStorage = LocalStorage(userDefaults: Self.getTestUserDefaults()) | ||
let deviceId = IterableKeychain().deviceId | ||
XCTAssertEqual(localStorage.deviceId, deviceId) | ||
} | ||
|
||
func testSdkVersion() { | ||
var localStorage = LocalStorage(userDefaults: LocalStorageTests.getTestUserDefaults()) | ||
var localStorage = LocalStorage(userDefaults: Self.getTestUserDefaults()) | ||
let sdkVersion = "6.0.2" | ||
localStorage.sdkVersion = sdkVersion | ||
XCTAssertEqual(localStorage.sdkVersion, sdkVersion) | ||
} | ||
|
||
func testAuthToken() { | ||
var localStorage = LocalStorage(userDefaults: LocalStorageTests.getTestUserDefaults()) | ||
var localStorage = LocalStorage(userDefaults: Self.getTestUserDefaults()) | ||
let authToken = "03.10.11" | ||
localStorage.authToken = authToken | ||
XCTAssertEqual(localStorage.authToken, authToken) | ||
|
@@ -151,7 +157,7 @@ class LocalStorageTests: XCTestCase { | |
|
||
private func testLocalStorage<T>(saver: (LocalStorageProtocol, T) -> Void, | ||
retriever: (LocalStorageProtocol) -> T?, value: T) where T: Equatable { | ||
let localStorage = LocalStorage(userDefaults: LocalStorageTests.getTestUserDefaults()) | ||
let localStorage = LocalStorage(userDefaults: Self.getTestUserDefaults()) | ||
saver(localStorage, value) | ||
let retrievedLocalStorage = LocalStorage(userDefaults: LocalStorageTests.getTestUserDefaults()) | ||
let retrieved = retriever(retrievedLocalStorage) | ||
|
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.
The getter for 'deviceId' modifies state by writing to user defaults and keychain, which may lead to unexpected side effects. Consider refactoring this logic so that state mutations occur in an explicit initialization or setter method rather than within a property getter.
Copilot uses AI. Check for mistakes.
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.
No, provided code's logic is correct, we want to filter out first non nil from array of values, but if it fails generateUUID will be called, also you deleted persistency to UserDefaults and/or Keychain