UNPKG

@segment/analytics-next

Version:

Analytics Next (aka Analytics 2.0) is the latest version of Segment’s JavaScript SDK - enabling you to send your data to any tool without having to learn, test, or use a new API every time.

25 lines (21 loc) 636 B
declare global { interface Window { analyticsWriteKey?: string } } // This variable is used as an optional fallback for when customers // host or proxy their own analytics.js. try { window.analyticsWriteKey = '__WRITE_KEY__' } catch (_) { // @ eslint-disable-next-line } export function embeddedWriteKey(): string | undefined { if (window.analyticsWriteKey === undefined) { return undefined } // this is done so that we don't accidentally override every reference to __write_key__ return window.analyticsWriteKey !== ['__', 'WRITE', '_', 'KEY', '__'].join('') ? window.analyticsWriteKey : undefined }