Skip to content

Commit

Permalink
ref: Move node version to runtime context (#2507)
Browse files Browse the repository at this point in the history
  • Loading branch information
xpicio committed Mar 23, 2020
1 parent 124e71e commit fd26d9f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@
},
"resolutions": {
"**/agent-base": "5"
}
},
"version": "0.0.0"
}
9 changes: 6 additions & 3 deletions packages/node/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,12 @@ export function parseRequest(
};

if (options.version) {
event.extra = {
...event.extra,
node: global.process.version,
event.contexts = {
...event.contexts,
runtime: {
name: 'node',
version: global.process.version,
},
};
}

Expand Down
19 changes: 19 additions & 0 deletions packages/node/test/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ describe('parseRequest', () => {
},
};

describe('parseRequest.contexts runtime', () => {
test('runtime name must contain node', () => {
const parsedRequest: Event = parseRequest({}, mockReq);
expect(parsedRequest.contexts.runtime.name).toEqual('node');
});

test('runtime version must contain current node version', () => {
const parsedRequest: Event = parseRequest({}, mockReq);
expect(parsedRequest.contexts.runtime.version).toEqual(process.version);
});

test('runtime disbaled by options', () => {
const parsedRequest: Event = parseRequest({}, mockReq, {
version: false,
});
expect(parsedRequest).not.toHaveProperty('contexts.runtime');
});
});

describe('parseRequest.user properties', () => {
const DEFAULT_USER_KEYS = ['id', 'username', 'email'];
const CUSTOM_USER_KEYS = ['custom_property'];
Expand Down

0 comments on commit fd26d9f

Please sign in to comment.