@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.
17 lines (16 loc) • 342 B
text/typescript
// This an imperfect polyfill for globalThis
export const getGlobal = () => {
if (typeof globalThis !== 'undefined') {
return globalThis
}
if (typeof self !== 'undefined') {
return self
}
if (typeof window !== 'undefined') {
return window
}
if (typeof global !== 'undefined') {
return global
}
return null
}