UNPKG

@churnassassin/sentry-beacon

Version:

NPM loader for the Churn Assassin Sentry Beacon tracking agent

43 lines (39 loc) 1.63 kB
export function initSentryBeacon(config) { if (typeof window === 'undefined') { console.warn('Sentry Beacon must be run in a browser environment.') return } // Step 1: Populate global tracking data window.assassindata = { token: config.token, useragent: navigator.userAgent, activity: window.location.pathname, qs: window.location.search, company_name: config.company_name, companyid: config.companyid, enduser_email: config.enduser_email, enduser_firstname: config.enduser_firstname, enduser_lastname: config.enduser_lastname, enduserid: config.enduserid, productid: config.productid || "1", platformid: config.platformid || "2" } // Step 2: Dynamically inject churnassassin.js (Sentry Beacon) if (!document.getElementById('ca-beacon-loader')) { const beaconScript = document.createElement('script') beaconScript.src = 'https://api.churnassassin.com/static/js/churnassassin.js' beaconScript.async = true beaconScript.defer = true beaconScript.id = 'ca-beacon-loader' document.head.appendChild(beaconScript) } // Step 3: Dynamically inject engagement.js (Sentry Panel) if (!document.getElementById('ca-panel-loader')) { const panelScript = document.createElement('script') panelScript.src = 'https://api.churnassassin.com/static/js/engagement.js' panelScript.async = true panelScript.defer = true panelScript.id = 'ca-panel-loader' document.head.appendChild(panelScript) } }