Browse Source

Prevent loading fs via analytics in storybook

master
meriadec 7 years ago
parent
commit
517201d248
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 7
      src/analytics/segment.js

7
src/analytics/segment.js

@ -3,13 +3,17 @@
import uuid from 'uuid/v4' import uuid from 'uuid/v4'
import logger from 'logger' import logger from 'logger'
import invariant from 'invariant' import invariant from 'invariant'
import user from 'helpers/user'
import { langAndRegionSelector } from 'reducers/settings' import { langAndRegionSelector } from 'reducers/settings'
import { getSystemLocale } from 'helpers/systemLocale' import { getSystemLocale } from 'helpers/systemLocale'
import { load } from './inject-in-window' import { load } from './inject-in-window'
invariant(typeof window !== 'undefined', 'analytics/segment must be called on renderer thread') invariant(typeof window !== 'undefined', 'analytics/segment must be called on renderer thread')
let user = null
if (!process.env.STORYBOOK_ENV) {
user = require('helpers/user').default
}
const sessionId = uuid() const sessionId = uuid()
const getContext = store => { const getContext = store => {
@ -31,6 +35,7 @@ const getContext = store => {
let storeInstance // is the redux store. it's also used as a flag to know if analytics is on or off. let storeInstance // is the redux store. it's also used as a flag to know if analytics is on or off.
export const start = (store: *) => { export const start = (store: *) => {
if (!user) return
const { id } = user() const { id } = user()
logger.analyticsStart(id) logger.analyticsStart(id)
storeInstance = store storeInstance = store

Loading…
Cancel
Save