Skip to content

Commit

Permalink
fix: library info override when provided in context (#89)
Browse files Browse the repository at this point in the history
* fix: library info override issue when provided in context

* chore: version bumped
  • Loading branch information
MoumitaM authored Jan 13, 2023
1 parent 2f27308 commit 3221644
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ class Analytics {
lMessage.type = type;

lMessage.context = {
...lMessage.context,
library: {
name: 'analytics-node',
version,
},
...lMessage.context,
};

lMessage.channel = 'server';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 23 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,3 +766,26 @@ 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, context);
});

0 comments on commit 3221644

Please sign in to comment.