Closed yunapotamus closed 3 years ago
@danbosnichill @jinyius Please review at your convenience. @dtdennis28 Heads up of an upcoming change to the way IDs behave on the iOS library.
just for completeness, we should explicitly call out that request id and insertion id for impression in these highly decoupled logging contexts aren't necessary since those will be usually handled by the platform's server (rpc) context.
just for completeness, we should explicitly call out that request id and insertion id for impression in these highly decoupled logging contexts aren't necessary since those will be usually handled by the platform's server (rpc) context.
Done.
we won't expect requestID nor insertionID on impression events, and instead join using logUserID.
As of right now, yea. Eventually, we'll probably get insertionID too.
I'm not sure I understand the alternative proposal and how nextValue would work (reseting externalValue). The primary pseudo code looks good.
we won't expect requestID nor insertionID on impression events, and instead join using logUserID.
As of right now, yea. Eventually, we'll probably get insertionID too.
Thanks for pointing that out. Since insertionID
doesn't behave like the other ancestor IDs, that won't affect this proposal.
I'm not sure I understand the alternative proposal and how nextValue would work (reseting externalValue). The primary pseudo code looks good.
I updated the example and clarified the behavior.
Thanks for your reviews! I'll take this as sign-off for this proposal.
@danbosnichill moving the discussion of luid and uid being set externally here per https://github.com/promotedai/ios-metrics-sdk/issues/126#issuecomment-854891336.
should we allow for setting both uid and luid externally? iiuc, right now, setting uid externally would generate a uuid local to the ios sdk.
We discussed usage patterns over VC. This issue/PR brings up a larger theoretical question of how to handle these scenarios:
These two requirements potentially complicate the library, as these use cases could pull the API in different directions. #128 is an example of a potential mis-use of the API by supporting both use cases.
After discussion, we decided that we will only support the extremes of the spectrum. That is, either the user only does 1 or only does 2. Any mixing and matching will not be supported. Reasons for this:
As for the specific question of allowing external setting of userID
, I won't include it in the first PR to be linked to this issue, but we can continue the discussion for a subsequent PR.
Background
Certain customers have internal tracking/logging already set up for users, sessions, and views. When we want to join the events that our library generates against the IDs that customers' internal systems generate, we need to be able to set the customers' IDs in the
logUserID
,sessionID
, orviewID
fields ofMetricsLogger
.This came up in a situation where we are only logging impressions. These impression events need (at minimum)
logUserID
set in order to join them on the server side. Since we're not logging or generating user IDs, we need to setlogUserID
on those impressions to some value that the app generates.In above situation, we won't expect
requestID
norinsertionID
on impression events, and instead join usinglogUserID
.Proposal
Add the ability to set ancestor IDs in
MetricsLogger
forlogUserID
,sessionID
, andviewID
. Also expose these hooks toreact-native-metrics
. The client behavior will be as follows.MetricsLogger
will use that custom ID going forward.startSessionAndLogUser(userID:)
), then we stop using the custom ID you set, and use our own autogenerated ID.Pseudocode
An alternative would be to make this change on the
IDProducer
class.Calls from
getSessionInfo()
will readidProducer.currentOrPendingValue
, which will return pending initial values even if those ancestor values haven't been explicitly set.Calls from the logging methods on
MetricsLogger
when populating ancestor IDs will readidProducer.currentValue
. This property will return EITHER the autogenerated value OR a custom value IF THE VALUE HAS BEEN SET. Otherwise, if no value is set, this property returnsnil
and the ancestor ID is omitted on the logged event.Caveat
This approach precludes the use of custom IDs as pending ancestor IDs. That is, you can't set a custom ID and have it behave as a pending initial ID. This seems like an acceptable tradeoff as the setting of such a custom ID is a signal that the library should use that ID immediately going forward.
Usage
In the code where users sign in and their obfuscated user ID is available, we add the line:
Then in all events logged from that point forward, the
userInfo
message will containuser.id
in thelogUserId
field.If a client app does not log any ancestor events with the library (user/session or view), and also does not pass through
insertionID
to its content, then it must set at least one ancestor ID prior to logging Action or Impression events. Ideally, this would belogUserID
.Sign off
Work begins when sign-off is received from all of the following: