Closed yunapotamus closed 3 years ago
@danbosnichill @jinyius @dtdennis28
i guess i'd like to strongly point out/reference #124 such that this issue calls out that it sets at least one ancestor id for any non-user/session event. we should never be in a state where there's no ancestor context. the luid (ours or the platforms) or uid (theirs) should be there on all events as an invariant. without being able to at least map to a unifying user concept, there's lots of issues for event flattening.
i guess i'd like to strongly point out/reference #124 such that this issue calls out that it sets at least one ancestor id for any non-user/session event. we should never be in a state where there's no ancestor context. the luid (ours or the platforms) or uid (theirs) should be there on all events as an invariant. without being able to at least map to a unifying user concept, there's lots of issues for event flattening.
Do you mean that if no ancestor IDs are specified when you try to log an event, and there's no insertionID, then it should be an error in the logging library? ie:
func logImpression(insertionID: String?) throws {
if ancestorLogUserID == nil && ancestorSessionID == nil &&
ancestorViewID == nil && insertionID == nil {
throw Error("Need at least one ancestor ID")
}
// else log the event
}
// Same check at start of logAction
tl;dr: net client sdk requirement:
non-user/session related log events should always populate some ancestor id. worst-case, it should be user/session related (either luid, uid, session) that is consistent with other log event sources. if the client app/sdk is not the source for the ancestor event and the client app does not provide the sdk with the ancestor id value, then the client sdk should omit the parent it. it should be an error if we try to log these non-user/session log events without any ancestor id set.
i guess i'd like to strongly point out/reference #124 such that this issue calls out that it sets at least one ancestor id for any non-user/session event. we should never be in a state where there's no ancestor context. the luid (ours or the platforms) or uid (theirs) should be there on all events as an invariant. without being able to at least map to a unifying user concept, there's lots of issues for event flattening.
I think we're in agreement on what to do in the case where we don't have ancestor IDs. Could you look at the pseudocode in my comment above and see if it handles this case?
Do you prefer if the library doesn't log an event at all if missing ancestor IDs, or that we log a (potentially useless) event that is missing ancestor IDs?
for the currently impacted platform, remove session id b/c it's not tied to any other event logging sources afaiu. generally applies as well since dan may want to move the session concept entirely out of the platform context and strictly in our backend.
i'll leave the question of what to do w/ these orphan events to @danbosnichill. imo, it should be handled in event api to dump into an orphan kafka topic so we can at least report on this as an issue via manager later.
Gotcha. So the updated proposal is:
func logImpression(insertionID: String?) {
if ancestorLogUserID == nil && ancestorViewID == nil && insertionID == nil {
warning("Need at least one ancestor ID")
}
// Log the event
}
// Same check at start of logAction
Can change the warning to an error (that doesn't log the event) per your preferences.
I'll open a new issue/PR for this behavior. Thanks!
Opened #126
func logImpression(insertionID: String?) { if ancestorLogUserID == nil && ancestorViewID == nil && insertionID == nil { warning("Need at least one ancestor ID") } // Log the event } // Same check at start of logAction
@danbosnichill, are you ok omitting userId from this check? if we include it, we'll have to prioritize doing uid based joining to get a consistent luid (can also extend to session and client hints) if we accept uid as a join key. basically, the inferred user stuff at the limit. i'm fine omitting for now to avoid signing us up to prioritize this work.
are you ok omitting userId from this check?
I moved this discussion to #126. :-)
Background
If the client does not set up a given ancestor ID in
MetricsLogger
, then we should not emit that ancestor ID in events going forward.This is a slight departure from a previous requirement where certain RPCs required the initial set of pending ancestor IDs, prior to the events for those IDs being logged.
Motivation is a case where we are not tracking users/sessions or views. We should not log those IDs in Impression events.
Proposal
Change the behavior of pending ancestor ID generation as follows:
Interaction with existing pending ancestor ID/
getSessionInfo()
functionality:logUserID
,sessionID
, andviewID
as before. These values will be available in memory.MetricsLogger
, saylogger.logUserID
, then we return the aforementioned initial value. The allows thegetSessionInfo()
call inreact-native-metrics
to behave as before.Here's a flowchart indicating which value is returned for an ancestor ID. The "Who is reading?" distinction is the most important.
getSessionInfo()
, then it's being read by a client external to the Promoted logging library. For example, when populating ancestor IDs for an RPC prior to logging those ancestors being logged.MetricsLogger.logEvent()
methods, then it's being read as an ancestor ID for a logged event.Examples
Suppose we call
logger.logImpression(content)
without calling any other methods to set up ancestor IDs first. The expected logged batch event is:The above example differs from previous behavior in that it does not include pending values for
userInfo.logUserID
,impression.sessionID
, orimpression.viewID
.Suppose that now we set
logger.logUserID = "foobar"
andlogger.sessionID = "batman"
. Then we calllogger.logImpression(content)
again. The expected logged batch event is:Now suppose we call
logger.logView(viewController: robinViewController)
. Then we calllogger.logImpression(content)
again. The expected logged batch event is: