Skip to content

Commit 60b19d2

Browse files
committed
fix Promise is undefined issue with ie11 polyfill
1 parent a8b0fc8 commit 60b19d2

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

.changeset/khaki-spoons-laugh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@segment/analytics-next': patch
3+
---
4+
5+
Fix 'Promise is undefined' issue with ie11 polyfill

packages/browser/src/browser/standalone.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,14 @@ import {
3131

3232
let ajsIdentifiedCSP = false
3333

34-
const sendErrorMetrics = (() => {
34+
const sendErrorMetrics = (tags: string[]) => {
35+
// this should not be instantied at the root, or it will break ie11.
3536
const metrics = new RemoteMetrics()
36-
return (tags: string[]) => {
37-
metrics.increment('analytics_js.invoke.error', [
38-
...tags,
39-
`wk:${embeddedWriteKey()}`,
40-
])
41-
}
42-
})()
37+
metrics.increment('analytics_js.invoke.error', [
38+
...tags,
39+
`wk:${embeddedWriteKey()}`,
40+
])
41+
}
4342

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

0 commit comments

Comments
 (0)