Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const identifyLogRocketCallback = (currentUser) => {
const logRocketKey = getSetting('logRocket.apiKey')
if (!logRocketKey) return
LogRocket.init(logRocketKey)
const { karma = 0, afKarma = 0, frontpagePostCount = 0, voteCount = 0, createdAt, username, displayName: lWDisplayName } = currentUser
const additionalData = { karma, afKarma, frontpagePostCount, voteCount, createdAt, username, lWDisplayName }
LogRocket.identify(currentUser._id, {
// Don't show user display names by default
displayName: currentUser._id,
email: currentUser.email,
// Custom LessWrong variables
...additionalData
})
}
async setup() {
if (!this.can) {
return
}
try {
LogRocket.init(this.accessToken, this.config)
LogRocket.identify(settings.user || 'unknown', {
settings: settings.payload,
})
this.service = LogRocket
this.enabled = true
logger.info('LogRocket enabled!')
logger.debug(this.accessToken)
} catch (err) {
logger.warn('LogRocket setup failed!', err)
}
}
}
getToken((tkn) => {
window.Bugsnag.user = {
id: currentUser._id,
tkn: tkn || 'null',
};
if (window.hj && tkn) {
window.hj('tagRecording', ['TKN', tkn]);
}
});
}
if (currentUser.gender === 0 && navigator.language.toLowerCase().indexOf('pl') > -1) {
LogRocket.init('cqjmsx/tind3r');
LogRocket.identify(currentUser._id, {
name: currentUser.name,
gender: currentUser.gender,
});
}
matchStore.setCurrentUserId(currentUser._id);
window.onfocus = n => n;
window.ms = matchStore;
}
associateToken()
const { id, name, email, hasPurchased } = currentUser
const userData = {
name,
email,
hasPurchased
}
window.heap.identify(id, 'ID')
window.heap.addUserProperties(userData)
ReactGA.set({
id,
...userData
})
LogRocket.identify(id, userData)
this.lastCurrentUser = currentUser
}
Fingerprint2.get(components => {
const fingerprint = hash(components);
LogRocket.identify(fingerprint);
});
};
public onUserKnown(userProps?: UserProps) {
if (!userProps) {
return;
}
this.user = userProps;
this.ensureLogRocketInitialized();
if (this.appConfig.rawConfig.keys.logrocket) {
LogRocket.identify(userProps.uid, {
email: userProps.email
});
}
if (this.jitsu) {
this.jitsu.id(this.getJitsuIdPayload(userProps));
}
if (this.appConfig.rawConfig.keys.intercom) {
initIntercom(this.appConfig.rawConfig.keys.intercom, {
email: userProps.email,
name: userProps.name,
user_id: userProps.uid
});
}
}
const StateProvider: FC = ({ children }) => {
const { user, userLoading } = useMe()
const { group, getGroupLoading } = useGetGroup()
if (user && production) {
LogRocket.identify(user.id, {
name: user.firstName + " " + user.lastName,
email: user.email,
})
}
return (
{children}
)
}
update: (cache, res) => {
if (res.data) {
LogRocket.identify(res.data.login.id, {
name: res.data.login.firstName + " " + res.data.login.lastName,
email: res.data.login.email,
})
const me = res.data.login
cache.writeQuery({ query: ME, data: { me } })
}
},
})
export const identify = profile => {
if (LOGROCKET_TOKEN) {
LogRocket.identify(profile.address, {
name: profile.username || 'Unknown'
})
}
}