1
1
import { expect , test } from '@playwright/test' ;
2
- import axios , { AxiosError } from 'axios' ;
3
2
import { ReplayRecordingData } from './fixtures/ReplayRecordingData' ;
4
3
5
4
const EVENT_POLLING_TIMEOUT = 90_000 ;
@@ -22,23 +21,12 @@ test('Sends an exception to Sentry', async ({ page }) => {
22
21
await expect
23
22
. poll (
24
23
async ( ) => {
25
- try {
26
- const response = await axios . get (
27
- `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ exceptionEventId } XXX/` ,
28
- { headers : { Authorization : `Bearer ${ authToken } ` } } ,
29
- ) ;
30
- return response . status ;
31
- } catch ( e ) {
32
- if ( e instanceof AxiosError && e . response ) {
33
- if ( e . response . status !== 404 ) {
34
- throw e ;
35
- } else {
36
- return e . response . status ;
37
- }
38
- } else {
39
- throw e ;
40
- }
41
- }
24
+ const response = await fetch (
25
+ `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ exceptionEventId } /` ,
26
+ { headers : { Authorization : `Bearer ${ authToken } ` } } ,
27
+ ) ;
28
+
29
+ return response . status ;
42
30
} ,
43
31
{
44
32
timeout : EVENT_POLLING_TIMEOUT ,
@@ -72,28 +60,20 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
72
60
await expect
73
61
. poll (
74
62
async ( ) => {
75
- try {
76
- const response = await axios . get (
77
- `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ transactionEventId } /` ,
78
- { headers : { Authorization : `Bearer ${ authToken } ` } } ,
79
- ) ;
63
+ const response = await fetch (
64
+ `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ transactionEventId } /` ,
65
+ { headers : { Authorization : `Bearer ${ authToken } ` } } ,
66
+ ) ;
80
67
81
- if ( response . data . contexts . trace . op === 'pageload' ) {
82
- hadPageLoadTransaction = true ;
83
- }
68
+ if ( response . ok ) {
69
+ const data = await response . json ( ) ;
84
70
85
- return response . status ;
86
- } catch ( e ) {
87
- if ( e instanceof AxiosError && e . response ) {
88
- if ( e . response . status !== 404 ) {
89
- throw e ;
90
- } else {
91
- return e . response . status ;
92
- }
93
- } else {
94
- throw e ;
71
+ if ( data . contexts . trace . op === 'pageload' ) {
72
+ hadPageLoadTransaction = true ;
95
73
}
96
74
}
75
+
76
+ return response . status ;
97
77
} ,
98
78
{
99
79
timeout : EVENT_POLLING_TIMEOUT ,
@@ -137,28 +117,19 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
137
117
await expect
138
118
. poll (
139
119
async ( ) => {
140
- try {
141
- const response = await axios . get (
142
- `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ transactionEventId } /` ,
143
- { headers : { Authorization : `Bearer ${ authToken } ` } } ,
144
- ) ;
145
-
146
- if ( response . data . contexts . trace . op === 'navigation' ) {
120
+ const response = await fetch (
121
+ `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ transactionEventId } /` ,
122
+ { headers : { Authorization : `Bearer ${ authToken } ` } } ,
123
+ ) ;
124
+
125
+ if ( response . ok ) {
126
+ const data = await response . json ( ) ;
127
+ if ( data . contexts . trace . op === 'navigation' ) {
147
128
hadPageNavigationTransaction = true ;
148
129
}
149
-
150
- return response . status ;
151
- } catch ( e ) {
152
- if ( e instanceof AxiosError && e . response ) {
153
- if ( e . response . status !== 404 ) {
154
- throw e ;
155
- } else {
156
- return e . response . status ;
157
- }
158
- } else {
159
- throw e ;
160
- }
161
130
}
131
+
132
+ return response . status ;
162
133
} ,
163
134
{
164
135
timeout : EVENT_POLLING_TIMEOUT ,
@@ -195,24 +166,12 @@ test('Sends a Replay recording to Sentry', async ({ browser }) => {
195
166
await expect
196
167
. poll (
197
168
async ( ) => {
198
- try {
199
- const response = await axios . get (
200
- `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /replays/${ replayId } /` ,
201
- { headers : { Authorization : `Bearer ${ authToken } ` } } ,
202
- ) ;
203
-
204
- return response . status ;
205
- } catch ( e ) {
206
- if ( e instanceof AxiosError && e . response ) {
207
- if ( e . response . status !== 404 ) {
208
- throw e ;
209
- } else {
210
- return e . response . status ;
211
- }
212
- } else {
213
- throw e ;
214
- }
215
- }
169
+ const response = await fetch (
170
+ `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /replays/${ replayId } /` ,
171
+ { headers : { Authorization : `Bearer ${ authToken } ` } } ,
172
+ ) ;
173
+
174
+ return response . status ;
216
175
} ,
217
176
{
218
177
timeout : EVENT_POLLING_TIMEOUT ,
@@ -224,24 +183,17 @@ test('Sends a Replay recording to Sentry', async ({ browser }) => {
224
183
await expect
225
184
. poll (
226
185
async ( ) => {
227
- try {
228
- const response = await axios . get (
229
- `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /replays/${ replayId } /recording-segments/?cursor=100%3A0%3A1` ,
230
- { headers : { Authorization : `Bearer ${ authToken } ` } } ,
231
- ) ;
232
-
233
- return response . status === 200 ? response . data [ 0 ] : response . status ;
234
- } catch ( e ) {
235
- if ( e instanceof AxiosError && e . response ) {
236
- if ( e . response . status !== 404 ) {
237
- throw e ;
238
- } else {
239
- return e . response . status ;
240
- }
241
- } else {
242
- throw e ;
243
- }
186
+ const response = await fetch (
187
+ `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /replays/${ replayId } /recording-segments/?cursor=100%3A0%3A1` ,
188
+ { headers : { Authorization : `Bearer ${ authToken } ` } } ,
189
+ ) ;
190
+
191
+ if ( response . ok ) {
192
+ const data = await response . json ( ) ;
193
+ return data [ 0 ] ;
244
194
}
195
+
196
+ return response . status ;
245
197
} ,
246
198
{
247
199
timeout : EVENT_POLLING_TIMEOUT ,
0 commit comments