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
}
})
})
}
}
import reducers from '../reducers/reducers'
import { addLocaleData } from 'react-intl'
import messagesBr from '../translations/result/br.json'
import messagesEn from '../translations/result/en.json'
import localeEn from 'react-intl/locale-data/en'
import localeBr from 'react-intl/locale-data/br'
addLocaleData([...localeEn, ...localeBr])
if (process.env.NODE_ENV === 'production') {
ReactGA.initialize('UA-114655639-1')
ReactGA.pageview(window.location.pathname + window.location.search)
LogRocket.init('ie8a2g/gitpay')
setupLogRocketReact(LogRocket)
}
const messages = {
'br': messagesBr,
'en': messagesEn
}
const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
}) : compose
const enhancer = composeEnhancers(
applyMiddleware(thunkMiddleware),
window.react = React;
window['react-dom'] = ReactDOM;
// eslint-disable-next-line global-require
window.antd = require('antd');
// Error log statistic
window.addEventListener('error', function onError(e) {
// Ignore ResizeObserver error
if (e.message === 'ResizeObserver loop limit exceeded') {
e.stopPropagation();
e.stopImmediatePropagation();
}
});
if (process.env.NODE_ENV === 'production') {
LogRocket.init('kpuw4z/ant-design');
setupLogRocketReact(LogRocket);
}
}
let isMobile = false;
enquireScreen(b => {
isMobile = b;
});
export default class Layout extends React.Component {
static contextTypes = {
router: PropTypes.object.isRequired,
};
static childContextTypes = {
isMobile: PropTypes.bool,
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
})
}
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);
initializeLogRocket = () => {
const { currentUser } = this.props
const logRocketKey = getSetting('logRocket.apiKey')
if (logRocketKey) {
// If the user is logged in, always log their sessions
if (currentUser) {
LogRocket.init(logRocketKey)
return
}
// If the user is not logged in, only track 1/5 of the sessions
const clientId = this.getUniqueClientId()
const hash = hashCode(clientId)
if (hash % getSetting('logRocket.sampleDensity') === 0) {
LogRocket.init(logRocketKey)
}
}
}
import 'hammerjs';
import * as LogRocket from 'logrocket';
import {enableProdMode} from '@angular/core';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app/app.module';
import {environment} from './environments/environment';
if (environment.production) {
enableProdMode();
LogRocket.init('buymic/devintent-dev-demo');
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
if (window.Bugsnag) {
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;
}
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)
}
}
}