Skip to content

Commit 9883151

Browse files
authored
Added missing metric from older analytics packaged (#1189)
1 parent b6c4372 commit 9883151

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

.changeset/spicy-baboons-care.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+
Added missing telemetry metric.

packages/browser/src/browser/__tests__/integration.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ describe('Dispatch', () => {
650650

651651
expect(metrics.map((m) => m.metric)).toMatchInlineSnapshot(`
652652
[
653+
"analytics_js.invoke",
653654
"message_dispatched",
654655
"plugin_time",
655656
"plugin_time",
@@ -694,7 +695,9 @@ describe('Dispatch', () => {
694695
})
695696

696697
await sleep(10)
697-
expect(fetchCalls[1].url).toBe('http://new.api.io/m')
698+
expect(fetchCalls.some((call) => call.url === 'http://new.api.io/m')).toBe(
699+
true
700+
)
698701
})
699702
})
700703

packages/browser/src/core/analytics/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ export class Analytics
516516
callback?: Callback
517517
): Promise<DispatchedEvent> {
518518
const ctx = new Context(event)
519+
ctx.stats.increment('analytics_js.invoke', 1, [event.type])
519520
if (isOffline() && !this.options.retryQueue) {
520521
return ctx
521522
}

0 commit comments

Comments
 (0)