You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My company integrated analytics.js (the old version, not 2.0) into our code base a few years ago. Now we want to clear the traits of users when they log out because we don't want to store the personal information of users in local storage. Through reading the documentation, I am aware that we can clear the traits in the cache by passing an empty object into the traits method:
You can pass an empty object to the traits object to clear all cached traits for a User or Group.
Traits are cached by default when you call the Identify and Group methods. You can clear the traits object for the user or group by passing traits an empty object:
analytics.user().traits({});
analytics.group().traits({});
I'm aware that this is from Analytics.js 2.0 documentation, but I have checked the source code of Analytics.js (the archive repo) and I noticed that the old version also exposes the user() method, which I assume that we can use that method to access to current user:
However, I don't see such method listed in the analytic.js snippet
...snippet
// A list of the methods in Analytics.js to stub.
analytics.methods = [
'trackSubmit',
'trackClick',
'trackLink',
'trackForm',
'pageview',
'identify',
'reset',
'group',
'track',
'ready',
'alias',
'debug',
'page',
'once',
'off',
'on',
'addSourceMiddleware',
'addIntegrationMiddleware',
'setAnonymousId',
'addDestinationMiddleware'
];
...
So can we clear the user trait by passing in an empty object like the documentation said, or is that feature only available in Analytic.js 2.0? Thank you.
The text was updated successfully, but these errors were encountered:
The snippet methods are not relevant if you call analytics.ready(() => analytcs.user.... That said, I am not sure, and I recommend you test to find out.
The old version of analytics.js has been end of lifed for well over a year; this repo is just for analytics next, as such, this is not a place for classic support. I strongly urge you to upgrade.
Please contact Segment support through the website if you have further questions about migration.
My company integrated
analytics.js
(the old version, not 2.0) into our code base a few years ago. Now we want to clear the traits of users when they log out because we don't want to store the personal information of users in local storage. Through reading the documentation, I am aware that we can clear the traits in the cache by passing an empty object into the traits method:I'm aware that this is from Analytics.js 2.0 documentation, but I have checked the source code of Analytics.js (the archive repo) and I noticed that the old version also exposes the user() method, which I assume that we can use that method to access to current user:
However, I don't see such method listed in the analytic.js snippet
So can we clear the user trait by passing in an empty object like the documentation said, or is that feature only available in Analytic.js 2.0? Thank you.
The text was updated successfully, but these errors were encountered: