1
- import { GLOBAL_OBJ } from '@sentry/utils' ;
1
+ import { GLOBAL_OBJ , parseUrl } from '@sentry/utils' ;
2
2
import { Transaction } from '../../../src' ;
3
3
import type { ResourceEntry } from '../../../src/browser/metrics' ;
4
4
import { _addMeasureSpans , _addResourceSpans } from '../../../src/browser/metrics' ;
5
5
import { WINDOW } from '../../../src/browser/types' ;
6
6
7
7
const mockWindowLocation = {
8
8
ancestorOrigins : { } ,
9
- href : "https://github .com/getsentry/sentry-javascript/pull/10205/files " ,
10
- origin : "https://github .com" ,
9
+ href : "https://example .com/path/to/something " ,
10
+ origin : "https://example .com" ,
11
11
protocol : "https:" ,
12
- host : "github .com" ,
13
- hostname : "github .com" ,
12
+ host : "example .com" ,
13
+ hostname : "example .com" ,
14
14
port : "" ,
15
- pathname : "/getsentry/sentry-javascript/pull/10205/files " ,
15
+ pathname : "/path/to/something " ,
16
16
search : "" ,
17
17
hash : ""
18
18
} as Window [ 'location' ] ;
19
19
20
20
WINDOW . location = mockWindowLocation ;
21
21
22
+ const resourceEntryName = 'https://example.com/assets/to/css' ;
23
+
22
24
describe ( '_addMeasureSpans' , ( ) => {
23
25
// eslint-disable-next-line deprecation/deprecation
24
26
const transaction = new Transaction ( { op : 'pageload' , name : '/' } ) ;
@@ -73,7 +75,7 @@ describe('_addResourceSpans', () => {
73
75
decodedBodySize : 256 ,
74
76
renderBlockingStatus : 'non-blocking' ,
75
77
} ;
76
- _addResourceSpans ( transaction , entry , '/assets/to/me' , 123 , 456 , 100 ) ;
78
+ _addResourceSpans ( transaction , entry , resourceEntryName , 123 , 456 , 100 ) ;
77
79
78
80
// eslint-disable-next-line @typescript-eslint/unbound-method, deprecation/deprecation
79
81
expect ( transaction . startChild ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -87,7 +89,7 @@ describe('_addResourceSpans', () => {
87
89
decodedBodySize : 256 ,
88
90
renderBlockingStatus : 'non-blocking' ,
89
91
} ;
90
- _addResourceSpans ( transaction , entry , '/assets/to/me' , 123 , 456 , 100 ) ;
92
+ _addResourceSpans ( transaction , entry , 'https://example.com /assets/to/me' , 123 , 456 , 100 ) ;
91
93
92
94
// eslint-disable-next-line @typescript-eslint/unbound-method, deprecation/deprecation
93
95
expect ( transaction . startChild ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -106,7 +108,7 @@ describe('_addResourceSpans', () => {
106
108
const startTime = 23 ;
107
109
const duration = 356 ;
108
110
109
- _addResourceSpans ( transaction , entry , '/assets/to/css' , startTime , duration , timeOrigin ) ;
111
+ _addResourceSpans ( transaction , entry , resourceEntryName , startTime , duration , timeOrigin ) ;
110
112
111
113
// eslint-disable-next-line @typescript-eslint/unbound-method, deprecation/deprecation
112
114
expect ( transaction . startChild ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -117,9 +119,9 @@ describe('_addResourceSpans', () => {
117
119
[ 'http.response_content_length' ] : entry . encodedBodySize ,
118
120
[ 'http.response_transfer_size' ] : entry . transferSize ,
119
121
[ 'resource.render_blocking_status' ] : entry . renderBlockingStatus ,
120
- [ 'url.scheme' ] : WINDOW . location . protocol ,
121
- [ 'server.address' ] : WINDOW . location . host ,
122
- [ 'url.same_origin' ] : false ,
122
+ [ 'url.scheme' ] : 'https:' ,
123
+ [ 'server.address' ] : 'example.com' ,
124
+ [ 'url.same_origin' ] : true ,
123
125
} ,
124
126
description : '/assets/to/css' ,
125
127
endTimestamp : timeOrigin + startTime + duration ,
@@ -157,7 +159,7 @@ describe('_addResourceSpans', () => {
157
159
const entry : ResourceEntry = {
158
160
initiatorType,
159
161
} ;
160
- _addResourceSpans ( transaction , entry , '/assets/to/me' , 123 , 234 , 465 ) ;
162
+ _addResourceSpans ( transaction , entry , 'https://example.com /assets/to/me' , 123 , 234 , 465 ) ;
161
163
162
164
// eslint-disable-next-line @typescript-eslint/unbound-method, deprecation/deprecation
163
165
expect ( transaction . startChild ) . toHaveBeenLastCalledWith (
@@ -177,7 +179,7 @@ describe('_addResourceSpans', () => {
177
179
renderBlockingStatus : 'non-blocking' ,
178
180
} ;
179
181
180
- _addResourceSpans ( transaction , entry , '/assets/to/css' , 100 , 23 , 345 ) ;
182
+ _addResourceSpans ( transaction , entry , resourceEntryName , 100 , 23 , 345 ) ;
181
183
182
184
// eslint-disable-next-line @typescript-eslint/unbound-method, deprecation/deprecation
183
185
expect ( transaction . startChild ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -189,6 +191,7 @@ describe('_addResourceSpans', () => {
189
191
[ 'http.response_content_length' ] : entry . encodedBodySize ,
190
192
[ 'http.response_transfer_size' ] : entry . transferSize ,
191
193
[ 'resource.render_blocking_status' ] : entry . renderBlockingStatus ,
194
+ [ 'resource.render_blocking_status' ] : entry . renderBlockingStatus ,
192
195
} ,
193
196
} ) ,
194
197
) ;
@@ -202,7 +205,7 @@ describe('_addResourceSpans', () => {
202
205
decodedBodySize : 2147483647 ,
203
206
} ;
204
207
205
- _addResourceSpans ( transaction , entry , '/assets/to/css' , 100 , 23 , 345 ) ;
208
+ _addResourceSpans ( transaction , entry , resourceEntryName , 100 , 23 , 345 ) ;
206
209
207
210
// eslint-disable-next-line @typescript-eslint/unbound-method, deprecation/deprecation
208
211
expect ( transaction . startChild ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -224,7 +227,7 @@ describe('_addResourceSpans', () => {
224
227
decodedBodySize : null ,
225
228
} as unknown as ResourceEntry ;
226
229
227
- _addResourceSpans ( transaction , entry , '/assets/to/css' , 100 , 23 , 345 ) ;
230
+ _addResourceSpans ( transaction , entry , resourceEntryName , 100 , 23 , 345 ) ;
228
231
229
232
// eslint-disable-next-line @typescript-eslint/unbound-method, deprecation/deprecation
230
233
expect ( transaction . startChild ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments