@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.
15 lines (11 loc) • 547 B
text/typescript
import { getGlobal } from '../../lib/get-global'
import type { Analytics } from '../analytics'
const env = getGlobal()
// The code below assumes the inspector extension will use Object.assign
// to add the inspect interface on to this object reference (unless the
// extension code ran first and has already set up the variable)
const inspectorHost: {
attach: (analytics: Analytics) => void
} = ((env as any)['__SEGMENT_INSPECTOR__'] ??= {})
export const attachInspector = (analytics: Analytics) =>
inspectorHost.attach?.(analytics as any)