diff --git a/History.md b/History.md index 979c3607..49114a74 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +## [v2.0.1](https://github.com/rudderlabs/rudder-sdk-node/compare/v2.0.0...v2.0.1) + +### Fixes + +- library info override when provided in context [`#89`](https://github.com/rudderlabs/rudder-sdk-node/pull/89) + ## [v2.0.0](https://github.com/rudderlabs/rudder-sdk-node/compare/v1.1.4...v2.0.0) ### Features @@ -26,7 +32,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). ### BREAKING CHANGES -- Allow dataPlaneUrl to be be passed in options instead as an argument in initialization. [`#81`](https://github.com/rudderlabs/rudder-sdk-node/pull/81) +- Allow dataPlaneUrl to be passed in options instead as an argument in initialization and must no longer include '/v1/batch' part. [`#81`](https://github.com/rudderlabs/rudder-sdk-node/pull/81) ## [v1.1.4](https://github.com/rudderlabs/rudder-sdk-node/compare/v1.1.3...v1.1.4) diff --git a/index.js b/index.js index 07373ab7..57aeefe9 100644 --- a/index.js +++ b/index.js @@ -514,11 +514,11 @@ class Analytics { lMessage.type = type; lMessage.context = { + ...lMessage.context, library: { name: 'analytics-node', version, }, - ...lMessage.context, }; lMessage.channel = 'server'; diff --git a/package-lock.json b/package-lock.json index 5f4b97d0..1c59ef02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9529,9 +9529,9 @@ } }, "node_modules/decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", "dev": true, "engines": { "node": ">=0.10" @@ -17411,9 +17411,9 @@ } }, "node_modules/luxon": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.1.1.tgz", - "integrity": "sha512-Ah6DloGmvseB/pX1cAmjbFvyU/pKuwQMQqz7d0yvuDlVYLTs2WeDHQMpC8tGjm1da+BriHROW/OEIT/KfYg6xw==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.2.1.tgz", + "integrity": "sha512-QrwPArQCNLAKGO/C+ZIilgIuDnEnKx5QYODdDtbFaxzsbZcc/a7WFq7MhsVYgRlwawLtvOUESTlfJ+hc/USqPg==", "optional": true, "engines": { "node": ">=12" @@ -33764,9 +33764,9 @@ } }, "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", "dev": true }, "decompress-response": { @@ -39681,9 +39681,9 @@ } }, "luxon": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.1.1.tgz", - "integrity": "sha512-Ah6DloGmvseB/pX1cAmjbFvyU/pKuwQMQqz7d0yvuDlVYLTs2WeDHQMpC8tGjm1da+BriHROW/OEIT/KfYg6xw==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.2.1.tgz", + "integrity": "sha512-QrwPArQCNLAKGO/C+ZIilgIuDnEnKx5QYODdDtbFaxzsbZcc/a7WFq7MhsVYgRlwawLtvOUESTlfJ+hc/USqPg==", "optional": true }, "madge": { diff --git a/package.json b/package.json index b68f9f5b..f4d425f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/rudder-sdk-node", - "version": "2.0.0", + "version": "2.0.1", "description": "Rudder Node SDK", "license": "", "repository": "rudderlabs/rudder-sdk-node", diff --git a/test.js b/test.js index e0bb74f8..60d8e8c3 100644 --- a/test.js +++ b/test.js @@ -766,3 +766,62 @@ test('ensure other axios clients are not impacted by axios-retry', async (t) => server.close(); }); + +test('ensure library information not overridden if provided in context object', (t) => { + const client = createClient(); + const customContext = { + library: { + name: 'random-sdk', + version: '1234', + }, + }; + + client.enqueue( + 'type', + { + event: 'test', + context: customContext, + }, + noop, + ); + + const actualContext = client.queue[0].message.context; + + t.deepEqual(actualContext.library, context.library); +}); + +test('ensure library information not overridden if provided null in context object', (t) => { + const client = createClient(); + const customContext = null; + + client.enqueue( + 'type', + { + event: 'test', + context: customContext, + }, + noop, + ); + + const actualContext = client.queue[0].message.context; + + t.deepEqual(actualContext.library, context.library); +}); + +test('ensure library information not overridden if provided undefined in context object', (t) => { + const client = createClient(); + const customContext = undefined; + + client.enqueue( + 'type', + { + event: 'test', + context: customContext, + }, + noop, + ); + + const actualContext = client.queue[0].message.context; + + t.deepEqual(actualContext.library, context.library); +});