Handle reset identities event#169
Conversation
Codecov Report
@@ Coverage Diff @@
## feature/consent #169 +/- ##
===================================================
+ Coverage 93.06% 93.96% +0.90%
===================================================
Files 24 25 +1
Lines 793 861 +68
===================================================
+ Hits 738 809 +71
+ Misses 55 52 -3 |
kevinlind
left a comment
There was a problem hiding this comment.
This looks good. However, I have questions regarding how the response payload is updated from the server response. This implementation would mean that any queued hit's stored payload would not get updated by the server response of earlier hits. That's different than what we do currently when the stored payloads are retrieved right before the hit is sent.
Also, if the hit queue is stored for a long time (app closed for a while then relaunched), there's the possibility of a stored payload timing out. Those timed out payload elements are currently removed before sending a hit, but with this change they are not. Will that cause issues with the server?
|
@kevinlind Correct, the stored payload of queued hits are not able to be updated. I'm on the fence about which approach is better. On one end I see that we should get a snapshot of the current cookies when the hit was queued and use them, but I can also see that always getting the latest cookies may be nice to have. @emdobrin thoughts? That's a good point regarding expired payloads... I would hope the server could handle it, but I made a small update to filter out expired payloads just in case. I should probably add a test for this edge case, but let me know your thoughts. |
|
I think you are right, we cannot easily update the persisted state store if they change in between hits, as you have to update certain events, but not all. One other option is to have a combination of the two approaches we discussed:
In other words:
|
|
@kevinlind @emdobrin I pushed up some changes to handle the reset event in this PR as well and took into account some of the feedback of not persisting the state store payloads. The PR isn't in final form and needs some tests added, but let me know what you think about this approach. |
emdobrin
left a comment
There was a problem hiding this comment.
can you also add some integration tests involving experience events with resetIdentitities in between?
| } else if event.isResetIdentitiesEvent { | ||
| let configurationSharedState = getSharedState(extensionName: EdgeConstants.SharedState.Configuration.STATE_OWNER_NAME, | ||
| event: event) | ||
| // use barrier to wait for EdgeIdentity to handle the reset |
There was a problem hiding this comment.
so are we still waiting for the reset request and not for the resetComplete?
There was a problem hiding this comment.
Yeah, we could listen for the event coming from edge identity notifying it has reset or use the barrier flag to wait until we know its done processing
|
|
||
| // Note: ExEdge does not return eventIndex when there is only one event in the request. | ||
| // The event handles and errrors are associated to that request event, so defaulting to 0 here. | ||
| // The event handles and errors are associated to that request event, so defaulting to 0 here. |
| private let queue = DispatchQueue(label: "test queue", | ||
| attributes: .concurrent) | ||
|
|
||
| func testAtomicWrite() { |
There was a problem hiding this comment.
We may want to add more tests in the future, but for now I think this is sufficient.
|
|
||
| /// Represents a thread-safe type for read and write operations | ||
| final class Atomic<A> { | ||
| private let queue = DispatchQueue(label: "Atomic type serial queue") |
There was a problem hiding this comment.
if there are multiple atomic objects being used in this extension, they will all be queued based on the same serial queue, did you mean to have different queues for each?
There was a problem hiding this comment.
They will all be different queues, the label is only used for debugging. I don't think it really makes sense to need to specify the queue label when creating an Atomic, so I used a general label in all cases. "Atomic type serial queue".
kevinlind
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for all the updates.
Description
Instead of just storing the
Eventwe now store the current identity shared state and the current store payloads. This will allow for easier implementation of handling the reset request event.Internal task: AMSDK-11387
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: