From 4162cca3ff4bceff8f93a9eca3e35b9679864d97 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 6 Oct 2022 15:23:51 -0500 Subject: [PATCH] Wrap sprig init in check for window --- web/lib/service/sprig.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/lib/service/sprig.ts b/web/lib/service/sprig.ts index f89a9678..7a478d77 100644 --- a/web/lib/service/sprig.ts +++ b/web/lib/service/sprig.ts @@ -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)