Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-spoons-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@segment/analytics-next': patch
---

Fix 'Promise is undefined' issue with ie11 polyfill
4 changes: 2 additions & 2 deletions packages/browser/src/browser/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ if (shouldPolyfill()) {
// load polyfills in order to get AJS to work with old browsers
const script = document.createElement('script')
script.setAttribute(
'src',
'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.7.0/polyfill.min.js'
'src', // this should map to tsconfig lib. gated means "only load polyfill if feature does not exist"
'https://polyfill.io/v3/polyfill.min.js?features=es5,es2015,es2016,es2017,es2018,es2019,es2020&flags=gated'
)

if (document.readyState === 'loading') {
Expand Down
7 changes: 4 additions & 3 deletions packages/browser/src/lib/browser-polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ export function shouldPolyfill(): boolean {
const browserVersionCompatList: { [browser: string]: number } = {
Firefox: 46,
Edge: 13,
Opera: 50,
}

const isOperaMiniExtremeMode = (window as any).operamini // compression proxy - allows for page() calls.

// Unfortunately IE doesn't follow the same pattern as other browsers, so we
// need to check `isIE11` differently.
// @ts-expect-error
Expand All @@ -14,10 +17,8 @@ export function shouldPolyfill(): boolean {

return (
isIE11 ||
isOperaMiniExtremeMode ||
(browserVersionCompatList[browser] !== undefined &&
browserVersionCompatList[browser] >= parseInt(version))
)
}

// appName = Netscape IE / Edge
// edge 13 Edge/13... same as FF