Browse Source
Merge pull request #795 from meriadec/fix-storybook
Prevent loading fs via analytics in storybook
master
Gaëtan Renaudeau
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
1 deletions
-
src/analytics/segment.js
|
|
@ -3,13 +3,17 @@ |
|
|
|
import uuid from 'uuid/v4' |
|
|
|
import logger from 'logger' |
|
|
|
import invariant from 'invariant' |
|
|
|
import user from 'helpers/user' |
|
|
|
import { langAndRegionSelector } from 'reducers/settings' |
|
|
|
import { getSystemLocale } from 'helpers/systemLocale' |
|
|
|
import { load } from './inject-in-window' |
|
|
|
|
|
|
|
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 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.
|
|
|
|
|
|
|
|
export const start = (store: *) => { |
|
|
|
if (!user) return |
|
|
|
const { id } = user() |
|
|
|
logger.analyticsStart(id) |
|
|
|
storeInstance = store |
|
|
|