Skip to content

Commit 05eb53e

Browse files
authored
show actual package version in node request body (#678)
1 parent c71311c commit 05eb53e

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

packages/node/src/__tests__/http-integration.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const fetcher = jest.fn()
22
jest.mock('../lib/fetch', () => fetcher)
33

44
import { createSuccess } from './test-helpers/factories'
5+
import { version } from '../../package.json'
56
import { Analytics } from '..'
67
import { resolveCtx } from './test-helpers/resolve-ctx'
78

@@ -50,6 +51,7 @@ describe('Analytics Node', () => {
5051
`
5152
)
5253
const body = JSON.parse(httpRes.body)
54+
5355
expect(body).toMatchInlineSnapshot(
5456
{
5557
batch: [
@@ -58,12 +60,6 @@ describe('Analytics Node', () => {
5860
_metadata: {
5961
nodeVersion: expect.any(String),
6062
},
61-
62-
context: {
63-
library: {
64-
version: expect.any(String),
65-
},
66-
},
6763
},
6864
],
6965
},
@@ -77,7 +73,7 @@ describe('Analytics Node', () => {
7773
"context": Object {
7874
"library": Object {
7975
"name": "AnalyticsNode",
80-
"version": Any<String>,
76+
"version": "${version}",
8177
},
8278
},
8379
"integrations": Object {},

packages/node/src/plugins/segmentio/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { CoreContext, CorePlugin } from '@segment/analytics-core'
22
import { Publisher, PublisherProps } from './publisher'
3+
import { version } from '../../../package.json'
34

45
function normalizeEvent(ctx: CoreContext) {
56
ctx.updateEvent('context.library.name', 'AnalyticsNode')
6-
ctx.updateEvent('context.library.version', '1.0.0')
7+
ctx.updateEvent('context.library.version', version)
78
ctx.updateEvent('_metadata.nodeVersion', process.versions.node)
89
}
910

0 commit comments

Comments
 (0)