Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const state = store.getState()
const { allowTracking } = state.settings
if (!allowTracking) {
console.debug('Analytics tracking disabled')
window.ga = () => {}
return
}
const clientId = process.env.GA_CLIENT_ID
if (!clientId) return
// https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
const analytics = new Analytics(clientId, {
appName: PRODUCT_NAME,
appVersion: VERSION,
clientId: localUserId()
})
window.ga = (...args: any[]) => {
try {
analytics.send(...args)
} catch (e) {
console.error(e)
} finally {
// Reset session heartbeat timer; keeps number of heartbeats sent only to
// what's absolutely necessary to keep the session alive.
startSession(store)
}
}
}
private get isPermittedBySafeBrowse() {
const media = this.props.current
// Always playback self-requested media
if (media && media.ownerId === localUserId()) {
return true
}
return this.props.safeBrowseEnabled
? this.state.permitURLOnce || SafeBrowse.getInstance().isPermittedURL(this.mediaUrl)
: true
}
private onLoadScreen() {
this.host = this.props.match.params.lobbyId === localUserId()
this.props.dispatch(initLobby({ host: this.host }))
if (!this.host || this.supportsNetworking) {
this.setupLobby()
}
}
const userJoined = (userId: string): RpcThunk => (dispatch, getState, context) => {
if (localUserId() === userId) {
return
}
const username = getUserName(getState(), userId)
const content = translateEscaped('userJoined', { userId, username })
dispatch(addChat({ content, html: true, timestamp: Date.now() }))
}
export const multi_userJoined = rpc('userJoined', RpcRealm.Multicast, userJoined)
constructor(props: PrivateProps) {
super(props)
this.host = props.match.params.lobbyId === localUserId()
}