diff --git a/web/lib/service/sprig.ts b/web/lib/service/sprig.ts index b827253f..f89a9678 100644 --- a/web/lib/service/sprig.ts +++ b/web/lib/service/sprig.ts @@ -5,30 +5,32 @@ import { ENV_CONFIG } from 'common/envs/constants' import { PROD_CONFIG } from 'common/envs/prod' -try { - ;(function (l, e, a, p) { - if (window.Sprig) return - window.Sprig = function (...args) { - S._queue.push(args) - } - const S = window.Sprig - S.appId = a - S._queue = [] - window.UserLeap = S - a = l.createElement('script') - a.async = 1 - a.src = e + '?id=' + S.appId - p = l.getElementsByTagName('script')[0] - ENV_CONFIG.domain === PROD_CONFIG.domain && p.parentNode.insertBefore(a, p) - })(document, 'https://cdn.sprig.com/shim.js', ENV_CONFIG.sprigEnvironmentId) -} catch (error) { - console.log('Error initializing Sprig, please complain to Barak', error) +if (ENV_CONFIG.domain === PROD_CONFIG.domain) { + try { + ;(function (l, e, a, p) { + if (window.Sprig) return + window.Sprig = function (...args) { + S._queue.push(args) + } + const S = window.Sprig + S.appId = a + S._queue = [] + window.UserLeap = S + a = l.createElement('script') + a.async = 1 + a.src = e + '?id=' + S.appId + p = l.getElementsByTagName('script')[0] + p.parentNode.insertBefore(a, p) + })(document, 'https://cdn.sprig.com/shim.js', ENV_CONFIG.sprigEnvironmentId) + } catch (error) { + console.log('Error initializing Sprig, please complain to Barak', error) + } } export function setUserId(userId: string): void { - window.Sprig('setUserId', userId) + if (window.Sprig) window.Sprig('setUserId', userId) } export function setAttributes(attributes: Record): void { - window.Sprig('setAttributes', attributes) + if (window.Sprig) window.Sprig('setAttributes', attributes) }