Skip to content

Commit 6afb605

Browse files
committed
fix: Breadcrumb tests
1 parent 8387ed3 commit 6afb605

File tree

2 files changed

+5
-109
lines changed

2 files changed

+5
-109
lines changed

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ export class Breadcrumbs implements Integration {
179179
return;
180180
}
181181

182+
if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') {
183+
// We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)
184+
return;
185+
}
186+
182187
if (handlerData.error) {
183188
getCurrentHub().addBreadcrumb(
184189
{

packages/browser/test/integration/suites/breadcrumbs.js

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -84,115 +84,6 @@ describe("breadcrumbs", function() {
8484
}
8585
);
8686

87-
it(
88-
optional(
89-
"should transform XMLHttpRequests with events to the Sentry store endpoint as sentry.event type breadcrumb",
90-
IS_LOADER
91-
),
92-
function() {
93-
return runInSandbox(sandbox, { manual: true }, function() {
94-
var store =
95-
document.location.protocol +
96-
"//" +
97-
document.location.hostname +
98-
(document.location.port ? ":" + document.location.port : "") +
99-
"/api/1/store/" +
100-
"?sentry_key=1337";
101-
102-
var xhr = new XMLHttpRequest();
103-
xhr.open("POST", store);
104-
xhr.send('{"message":"someMessage","level":"warning"}');
105-
waitForXHR(xhr, function() {
106-
Sentry.captureMessage("test");
107-
window.finalizeManualTest();
108-
});
109-
}).then(function(summary) {
110-
// The async loader doesn't wrap XHR
111-
if (IS_LOADER) {
112-
return;
113-
}
114-
assert.equal(summary.breadcrumbs.length, 1);
115-
assert.equal(summary.breadcrumbs[0].category, "sentry.event");
116-
assert.equal(summary.breadcrumbs[0].level, "warning");
117-
assert.equal(summary.breadcrumbs[0].message, "someMessage");
118-
});
119-
}
120-
);
121-
122-
it(
123-
optional(
124-
"should transform XMLHttpRequests with transactions type to the Sentry store endpoint as sentry.transaction type breadcrumb",
125-
IS_LOADER
126-
),
127-
function() {
128-
return runInSandbox(sandbox, { manual: true }, function() {
129-
var store =
130-
document.location.protocol +
131-
"//" +
132-
document.location.hostname +
133-
(document.location.port ? ":" + document.location.port : "") +
134-
"/api/1/store/" +
135-
"?sentry_key=1337";
136-
137-
var xhr = new XMLHttpRequest();
138-
xhr.open("POST", store);
139-
xhr.send(
140-
'{"message":"someMessage","transaction":"wat","level":"warning", "type": "transaction"}'
141-
);
142-
waitForXHR(xhr, function() {
143-
Sentry.captureMessage("test");
144-
window.finalizeManualTest();
145-
});
146-
}).then(function(summary) {
147-
// The async loader doesn't wrap XHR
148-
if (IS_LOADER) {
149-
return;
150-
}
151-
assert.equal(summary.breadcrumbs.length, 1);
152-
assert.equal(summary.breadcrumbs[0].category, "sentry.transaction");
153-
assert.equal(summary.breadcrumbs[0].level, "warning");
154-
assert.equal(summary.breadcrumbs[0].message, "someMessage");
155-
});
156-
}
157-
);
158-
159-
it(
160-
optional(
161-
"should not transform XMLHttpRequests with transactions attribute to the Sentry store endpoint as sentry.transaction type breadcrumb",
162-
IS_LOADER
163-
),
164-
function() {
165-
return runInSandbox(sandbox, { manual: true }, function() {
166-
var store =
167-
document.location.protocol +
168-
"//" +
169-
document.location.hostname +
170-
(document.location.port ? ":" + document.location.port : "") +
171-
"/api/1/store/" +
172-
"?sentry_key=1337";
173-
174-
var xhr = new XMLHttpRequest();
175-
xhr.open("POST", store);
176-
xhr.send(
177-
'{"message":"someMessage","transaction":"wat","level":"warning"}'
178-
);
179-
waitForXHR(xhr, function() {
180-
Sentry.captureMessage("test");
181-
window.finalizeManualTest();
182-
});
183-
}).then(function(summary) {
184-
// The async loader doesn't wrap XHR
185-
if (IS_LOADER) {
186-
return;
187-
}
188-
assert.equal(summary.breadcrumbs.length, 1);
189-
assert.equal(summary.breadcrumbs[0].category, "sentry.event");
190-
assert.equal(summary.breadcrumbs[0].level, "warning");
191-
assert.equal(summary.breadcrumbs[0].message, "someMessage");
192-
});
193-
}
194-
);
195-
19687
it("should record a fetch request", function() {
19788
return runInSandbox(sandbox, { manual: true }, function() {
19889
fetch("/base/subjects/example.json", {

0 commit comments

Comments
 (0)