Skip to content

Commit 7e64b9e

Browse files
authored
fix(node): contexts cannot be overridden and culture never included (#5677)
I will do a PR to add integration tests but for now, this PR fixes two issues: - A missing `typeof` which stops the node culture detection from working entirely - The contexts are completely overwritten rather than merge any existing keys
1 parent 5efdabe commit 7e64b9e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/node/src/integrations/context.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ export class Context implements Integration {
6565
this._cachedContext = this._getContexts();
6666
}
6767

68-
event.contexts = { ...event.contexts, ...this._updateContext(await this._cachedContext) };
68+
const updatedContext = this._updateContext(await this._cachedContext);
69+
70+
event.contexts = {
71+
...event.contexts,
72+
app: { ...updatedContext.app, ...event.contexts?.app },
73+
os: { ...updatedContext.os, ...event.contexts?.os },
74+
device: { ...updatedContext.device, ...event.contexts?.device },
75+
culture: { ...updatedContext.culture, ...event.contexts?.culture },
76+
};
6977

7078
return event;
7179
}
@@ -148,7 +156,7 @@ async function getOsContext(): Promise<OsContext> {
148156
function getCultureContext(): CultureContext | undefined {
149157
try {
150158
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
151-
if ((process.versions as unknown as any).icu !== 'string') {
159+
if (typeof (process.versions as unknown as any).icu !== 'string') {
152160
// Node was built without ICU support
153161
return;
154162
}

0 commit comments

Comments
 (0)