From 517201d24808e4a31234ecfa8ee75e496a952b97 Mon Sep 17 00:00:00 2001 From: meriadec Date: Mon, 2 Jul 2018 12:03:06 +0200 Subject: [PATCH] Prevent loading fs via analytics in storybook --- src/analytics/segment.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/analytics/segment.js b/src/analytics/segment.js index 0d34366b..26e6a305 100644 --- a/src/analytics/segment.js +++ b/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