Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const setup = () => {
if (LOGROCKET_TOKEN) {
LogRocket.init(LOGROCKET_TOKEN)
}
// add to rollbar
if (typeof window.Rollbar === 'undefined') {
console.warn(
'Rollbar not setup, so cannot assign LogRocket session to Rollbar instance!'
)
} else {
LogRocket.getSessionURL(sessionURL => {
window.Rollbar.configure({
transform: obj => {
obj.sessionURL = sessionURL
}
})
})
}
}
componentDidMount() {
/* Analytics */
// Temporary method until we do dynamic now configs
if (isProduction && window.location.host.includes('operationcode.org')) {
Sentry.init({ dsn: clientTokens.SENTRY_DSN, release: `front-end@${version}` });
LogRocket.init(`${clientTokens.LOGROCKET}/operation-code`);
ReactGA.initialize(clientTokens.GOOGLE_ANALYTICS);
// Every crash report will have a LogRocket session URL.
LogRocket.getSessionURL(sessionURL => {
Sentry.configureScope(scope => {
scope.setExtra('sessionURL', sessionURL);
});
});
setupLogRocketReact(LogRocket);
// Per library docs, Fingerprint2 should not run immediately
if (window.requestIdleCallback) {
requestIdleCallback(setLogRocketFingerprint);
} else {
setTimeout(setLogRocketFingerprint, 500);
}
ReactGA.set({ page: window.location.pathname });
}