2022-09-27 17:02:03 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
// @ts-nocheck
|
|
|
|
// Integrate Sprig
|
|
|
|
|
|
|
|
import { ENV_CONFIG } from 'common/envs/constants'
|
2022-10-03 16:59:18 +00:00
|
|
|
import { PROD_CONFIG } from 'common/envs/prod'
|
2022-09-27 17:02:03 +00:00
|
|
|
|
2022-10-06 20:23:51 +00:00
|
|
|
if (ENV_CONFIG.domain === PROD_CONFIG.domain && typeof window !== 'undefined') {
|
2022-10-05 23:36:32 +00:00
|
|
|
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]
|
2022-10-06 20:23:51 +00:00
|
|
|
ENV_CONFIG.domain === PROD_CONFIG.domain &&
|
|
|
|
p.parentNode.insertBefore(a, p)
|
2022-10-05 23:36:32 +00:00
|
|
|
})(document, 'https://cdn.sprig.com/shim.js', ENV_CONFIG.sprigEnvironmentId)
|
|
|
|
} catch (error) {
|
|
|
|
console.log('Error initializing Sprig, please complain to Barak', error)
|
|
|
|
}
|
2022-09-27 17:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function setUserId(userId: string): void {
|
2022-10-05 23:36:32 +00:00
|
|
|
if (window.Sprig) window.Sprig('setUserId', userId)
|
2022-09-27 17:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function setAttributes(attributes: Record<string, unknown>): void {
|
2022-10-05 23:36:32 +00:00
|
|
|
if (window.Sprig) window.Sprig('setAttributes', attributes)
|
2022-09-27 17:02:03 +00:00
|
|
|
}
|