Wrap sprig init in check for window

This commit is contained in:
James Grugett 2022-10-06 15:23:51 -05:00
parent 91da39370f
commit 4162cca3ff

View File

@ -5,7 +5,7 @@
import { ENV_CONFIG } from 'common/envs/constants'
import { PROD_CONFIG } from 'common/envs/prod'
if (ENV_CONFIG.domain === PROD_CONFIG.domain) {
if (ENV_CONFIG.domain === PROD_CONFIG.domain && typeof window !== 'undefined') {
try {
;(function (l, e, a, p) {
if (window.Sprig) return
@ -20,7 +20,8 @@ if (ENV_CONFIG.domain === PROD_CONFIG.domain) {
a.async = 1
a.src = e + '?id=' + S.appId
p = l.getElementsByTagName('script')[0]
p.parentNode.insertBefore(a, p)
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)