-
Notifications
You must be signed in to change notification settings - Fork 32
[FSSDK-10761] feat: make vuid as opt-in #556
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 14 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
48f7d8d
Add vuid optln feature
muzahidul-opti b799412
[WIP] Refractored vuid logic
muzahidul-opti 2cb824e
clean up
muzahidul-opti ea762f7
Test target build successfully
muzahidul-opti 7c2bd51
ODP test case updated
muzahidul-opti fde285a
OdpManager test case added
muzahidul-opti 283608e
Client updated
muzahidul-opti 4adc0a0
Test case updated
muzahidul-opti 2eeb008
WIP: VuidManager move to client
muzahidul-opti b89e594
WIP: Update odpmanager and client
muzahidul-opti 94910e2
[WIP] Update test cases
muzahidul-opti b71e65c
WIP: client release issue fixed
muzahidul-opti b835b8f
WIP: Relase test fixed
muzahidul-opti 7f49d58
WIP: clean up
muzahidul-opti 97e6447
WIP: VuidManager singleton added
muzahidul-opti b54266c
WIP: OdpVuidManager renamed as VuidManager
muzahidul-opti f916638
WIP: Make vuid optional to identifyUser method
muzahidul-opti 260673b
WIP: Decide reasons test cases changes reverted
muzahidul-opti 5b971fb
WIP: Vuid initialize method name fixed
muzahidul-opti 172a04d
WIP: VuidManager api renamed. Ignore case comparision added
muzahidul-opti 7e49835
Merge branch 'master' into muzahid/vuid-optln
muzahidul-opti 83ab331
wip: vuidmanager made public
muzahidul-opti 6b1acd8
Client initialize event sperated from odp manager
muzahidul-opti aa9c0dc
Merge branch 'master' into muzahid/vuid-optln
muzahidul-opti 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,17 @@ | |
import Foundation | ||
|
||
class OdpVuidManager { | ||
muzahidul-opti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var vuid: String = "" | ||
private var _vuid: String = "" | ||
private(set) var enabled: Bool | ||
let logger = OPTLoggerFactory.getLogger() | ||
|
||
// a single vuid should be shared for all SDK instances | ||
static let shared = OdpVuidManager() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should keep it a singleton, so can share a single vuid per device. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Declared singleton and add initialize method.
|
||
|
||
init() { | ||
self.vuid = load() | ||
init(enabled: Bool) { | ||
self.enabled = enabled | ||
if enabled { | ||
self._vuid = load() | ||
} else { | ||
self.remove() | ||
} | ||
} | ||
|
||
static var newVuid: String { | ||
|
@@ -35,7 +38,7 @@ class OdpVuidManager { | |
let vuid = (vuidFull.count <= maxLength) ? vuidFull : String(vuidFull.prefix(maxLength)) | ||
return vuid | ||
} | ||
|
||
static func isVuid(_ visitorId: String) -> Bool { | ||
return visitorId.starts(with: "vuid_") | ||
} | ||
|
@@ -45,6 +48,14 @@ class OdpVuidManager { | |
// MARK: - VUID Store | ||
|
||
extension OdpVuidManager { | ||
var vuid: String { | ||
if enabled { | ||
return _vuid | ||
} else { | ||
logger.w("VUID is not enabled.") | ||
return "" | ||
muzahidul-opti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
private var keyForVuid: String { | ||
return "optimizely-vuid" | ||
|
@@ -59,7 +70,12 @@ extension OdpVuidManager { | |
save(vuid: vuid) | ||
return vuid | ||
} | ||
|
||
|
||
private func remove() { | ||
UserDefaults.standard.set(nil, forKey: keyForVuid) | ||
UserDefaults.standard.synchronize() | ||
} | ||
|
||
private func save(vuid: String) { | ||
UserDefaults.standard.set(vuid, forKey: keyForVuid) | ||
UserDefaults.standard.synchronize() | ||
|
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
Oops, something went wrong.
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.
We also need the case covered -
vuid: nil and
user_id: valid not vuid
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.
I believe we have unit tests for all these combos. If missed, can we add one?
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.
Yah, test case is failing. Made the vuid optional to
identifyUser
.