Skip to content

Commit c7bbb57

Browse files
committed
use safeSetSpanJSONAttributes
1 parent c0c0158 commit c7bbb57

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

packages/browser/src/integrations/httpcontext.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineIntegration } from '@sentry/core';
1+
import { defineIntegration, safeSetSpanJSONAttributes } from '@sentry/core';
22
import { getHttpRequestData, WINDOW } from '../helpers';
33

44
/**
@@ -34,12 +34,13 @@ export const httpContextIntegration = defineIntegration(() => {
3434

3535
const reqData = getHttpRequestData();
3636

37-
span.attributes = {
38-
'url.full': reqData.url,
37+
safeSetSpanJSONAttributes(span, {
38+
// Coerce empty string to undefined so the helper's nullish check drops it,
39+
// rather than writing an empty `url.full` attribute onto the span.
40+
'url.full': reqData.url || undefined,
3941
'http.request.header.user_agent': reqData.headers['User-Agent'],
4042
'http.request.header.referer': reqData.headers['Referer'],
41-
...span.attributes,
42-
};
43+
});
4344
},
4445
};
4546
});

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export { createCheckInEnvelope } from './checkin';
7373
export { hasSpansEnabled } from './utils/hasSpansEnabled';
7474
export { withStreamedSpan } from './tracing/spans/beforeSendSpan';
7575
export { isStreamedBeforeSendSpanCallback } from './tracing/spans/beforeSendSpan';
76+
export { safeSetSpanJSONAttributes } from './tracing/spans/captureSpan';
7677
export { isSentryRequestUrl } from './utils/isSentryRequestUrl';
7778
export { handleCallbackErrors } from './utils/handleCallbackErrors';
7879
export { parameterize, fmt } from './utils/parameterize';

0 commit comments

Comments
 (0)