Skip to content

Commit 269567f

Browse files
committed
feat: Remove normalization of contexts
All of the context types documented in [1] are flat objects. The new contexts.trace is the only key under contexts that may have nested objects under contexts.trace.data. That value holds the data for the Transaction Span and matches spans[].data for invidual Spans. At the moment one of the data fields is heavily limited, while the other is ignored by normalization. [1]: https://develop.sentry.dev/sdk/event-payloads/contexts/ This is the simplest to implement fix to #2646, thus what I'm doing here perhaps temporarily. Fixes #2646
1 parent db146bd commit 269567f

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

packages/apm/src/integrations/tracing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ export class Tracing implements Integration {
520520
Tracing._forceLCP();
521521
if (Tracing._lcp) {
522522
// Set the last observed LCP score.
523-
transactionSpan.setData('_sentry_extra_metrics', JSON.stringify({ lcp: Tracing._lcp }));
523+
transactionSpan.setData('_sentry_extra_metrics', { lcp: Tracing._lcp });
524524
}
525525
}
526526

packages/core/src/baseclient.ts

-4
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
289289
* Normalized keys:
290290
* - `breadcrumbs.data`
291291
* - `user`
292-
* - `contexts`
293292
* - `extra`
294293
* @param event Event
295294
* @returns Normalized event
@@ -313,9 +312,6 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
313312
...(event.user && {
314313
user: normalize(event.user, depth),
315314
}),
316-
...(event.contexts && {
317-
contexts: normalize(event.contexts, depth),
318-
}),
319315
...(event.extra && {
320316
extra: normalize(event.extra, depth),
321317
}),

packages/core/test/lib/base.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ describe('BaseClient', () => {
467467
});
468468
expect(TestBackend.instance!.event!).toEqual({
469469
breadcrumbs: [normalizedBreadcrumb, normalizedBreadcrumb, normalizedBreadcrumb],
470-
contexts: normalizedObject,
470+
contexts: fourLevelsObject,
471471
event_id: '42',
472472
extra: normalizedObject,
473473
timestamp: 2020,
@@ -512,7 +512,7 @@ describe('BaseClient', () => {
512512
});
513513
expect(TestBackend.instance!.event!).toEqual({
514514
breadcrumbs: [normalizedBreadcrumb, normalizedBreadcrumb, normalizedBreadcrumb],
515-
contexts: normalizedObject,
515+
contexts: fourLevelsObject,
516516
event_id: '42',
517517
extra: normalizedObject,
518518
timestamp: 2020,

0 commit comments

Comments
 (0)