Skip to content

Commit

Permalink
Fix 'Promise is undefined' error that breaks ie11 auto-polyfill (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky authored Apr 20, 2023
1 parent a8b0fc8 commit 2b71c10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
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
15 changes: 7 additions & 8 deletions packages/browser/src/browser/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ import {

let ajsIdentifiedCSP = false

const sendErrorMetrics = (() => {
const sendErrorMetrics = (tags: string[]) => {
// this should not be instantied at the root, or it will break ie11.
const metrics = new RemoteMetrics()
return (tags: string[]) => {
metrics.increment('analytics_js.invoke.error', [
...tags,
`wk:${embeddedWriteKey()}`,
])
}
})()
metrics.increment('analytics_js.invoke.error', [
...tags,
`wk:${embeddedWriteKey()}`,
])
}

function onError(err?: unknown) {
console.error('[analytics.js]', 'Failed to load Analytics.js', err)
Expand Down

0 comments on commit 2b71c10

Please sign in to comment.