Feature request
Persist user info across sessions, set by Datadog.setUserInfo(id:name:email:)
Description
It appears that the user's info (id
, name
, email
) is only stored in memory, and not persisted across sessions.
This is problematic when logging launch time sequence events: in my application, I am asynchronously loading user information from my Apollo SQL cache in order to speed up the time to first layout pass for a better experience.
That information is then set on Datadog
for future logging, by that happens on another thread. See this sample code:
context.workspaceRepository.users
.distinctUntilChanged(WorkspaceUserInfo.isMeEqual)
.observeOn(ConcurrentDispatchQueueScheduler(qos: .background))
.subscribe(onNext: { [weak self] result in
switch result {
case .success(let users):
guard let me = users.me else {
...
return
}
log.info("Setting up Datadog", .app)
Datadog.setUserInfo(id: me.id, name: me.profile.displayName, email: me.profile.email)
case .failure(let error):
...
}
})
.disposed(by: bag)
The consequence is that the first milliseconds of my launch sequence logging are not attributed to any users.
This is especially confusing when filtering logs with email: [email protected]
for instance, because it filters-out early launch!
โ๏ธ In the log explorer, I am not seeing ๐ฑ Will finishlaunching
๐ Which is present in my console output locally:
This has been problematic for me to debug my session tracking code for instance.
Possible solutions
I could persist it myself as a one-off, say in UserDefaults
and set it synchronously, but I was expecting Datadog
would do this for me and only clear user info when explicitly set back to nil
.
Would you consider Datadog
persisting this info directly?
Library such as AppCenter do this themselves for instance, see code here
Let me know if this makes sense!