7ba19c274b
* basic sprig integration with possible page URL events * iteration 0 * iteration 1 * run prettier; attempt to remove expect error * readd expect error messages * typescript comment fixes * add identify * remove package-lock.json * extract to separate file * fix linting * fix lint * fix lint * fix missing config
34 lines
911 B
TypeScript
34 lines
911 B
TypeScript
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-nocheck
|
|
// Integrate Sprig
|
|
|
|
import { ENV_CONFIG } from 'common/envs/constants'
|
|
|
|
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)
|
|
}
|
|
|
|
export function setAttributes(attributes: Record<string, unknown>): void {
|
|
window.Sprig.setAttributes(attributes)
|
|
}
|