How should an SPA clear an identified user on logout? #4439
Unanswered
timohausmann
asked this question in
Q&A
Replies: 1 comment
|
You are reading the tracker right and const getPayload = () => ({
...
id: identity ? identity : undefined,
})Empty string is falsy so Two caveats worth knowing
const nextIdentity = typeof id === 'string' ? id : id.idAlso clearing is forward looking only For an SPA logout this is the safest shape today function onLogout() {
window.umami?.identify('')
}An explicit |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hey, our web app has a login feature. I call
umami.identify(userId);to identity users upon login.On logout, I could not find a documented
resetorunidentifyAPI, so I callumami.identify('');.Looking at the tracker source, this appears to set the module-scoped identity to an empty string, reset the cache, and omit the identity from subsequent payloads because an empty identity is treated as absent.
Is
umami.identify('')the intended and supported way to clear an identified user, or are we relying on an implementation detail?If the empty-string approach is not intended, what is the recommended logout flow for an SPA? Would you consider adding an explicit
resetIdentity()orunidentify()API?All reactions