Skip to content

Commit 5296648

Browse files
committed
update data
1 parent 707570c commit 5296648

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/tracing-internal/src/browser/metrics/index.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { IdleTransaction, Transaction } from '@sentry/core';
33
import { spanToJSON } from '@sentry/core';
44
import { getActiveTransaction, setMeasurement } from '@sentry/core';
55
import type { Measurements, SpanContext } from '@sentry/types';
6-
import { browserPerformanceTimeOrigin, getComponentName, htmlTreeAsString, logger } from '@sentry/utils';
6+
import { browserPerformanceTimeOrigin, getComponentName, htmlTreeAsString, logger, parseUrl } from '@sentry/utils';
77

88
import { DEBUG_BUILD } from '../../common/debug-build';
99
import {
@@ -226,8 +226,8 @@ export function addPerformanceEntries(transaction: Transaction): void {
226226
}
227227
case 'resource': {
228228
const resourceName = (entry.name as string).replace(WINDOW.location.origin, '');
229-
const resourceOrigin = new URL(entry.name as string).origin;
230-
_addResourceSpans(transaction, entry, resourceName, resourceOrigin, startTime, duration, timeOrigin);
229+
const resourceUrl = parseUrl(entry.name as string);
230+
_addResourceSpans(transaction, entry, resourceName, resourceUrl, startTime, duration, timeOrigin);
231231
break;
232232
}
233233
default:
@@ -403,7 +403,7 @@ export function _addResourceSpans(
403403
transaction: Transaction,
404404
entry: ResourceEntry,
405405
resourceName: string,
406-
resourceOrigin: string,
406+
resourceUrl: ReturnType<typeof parseUrl>,
407407
startTime: number,
408408
duration: number,
409409
timeOrigin: number,
@@ -422,10 +422,16 @@ export function _addResourceSpans(
422422
if ('renderBlockingStatus' in entry) {
423423
data['resource.render_blocking_status'] = entry.renderBlockingStatus;
424424
}
425-
if (resourceOrigin) {
426-
data['span.domain'] = resourceOrigin;
425+
if (resourceUrl.protocol) {
426+
data['url.scheme'] = resourceUrl.protocol;
427427
}
428428

429+
if (resourceUrl.host) {
430+
data['server.address'] = resourceUrl.host;
431+
}
432+
433+
data['url.same_origin'] = resourceUrl.host === window.location.host;
434+
429435
const startTimestamp = timeOrigin + startTime;
430436
const endTimestamp = startTimestamp + duration;
431437

packages/utils/src/url.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type PartialURL = {
1+
export type PartialURL = {
22
host?: string;
33
path?: string;
44
protocol?: string;

0 commit comments

Comments
 (0)