Skip to content

Commit 2384854

Browse files
committed
test: Add test for sentry.event and sentry.transaction breadcrumbs
1 parent 3a1f885 commit 2384854

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

packages/browser/test/integration/common/init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function initSDK() {
4848
}
4949

5050
// One of the tests use manually created breadcrumb without eventId and we want to let it through
51-
if (breadcrumb.category === "sentry" && breadcrumb.event_id) {
51+
if (breadcrumb.category.indexOf("sentry" === 0) && breadcrumb.event_id) {
5252
return null;
5353
}
5454

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

+39-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("breadcrumbs", function() {
8686

8787
it(
8888
optional(
89-
"should transform XMLHttpRequests to the Sentry store endpoint as sentry type breadcrumb",
89+
"should transform XMLHttpRequests with events to the Sentry store endpoint as sentry.event type breadcrumb",
9090
IS_LOADER
9191
),
9292
function() {
@@ -112,7 +112,44 @@ describe("breadcrumbs", function() {
112112
return;
113113
}
114114
assert.equal(summary.breadcrumbs.length, 1);
115-
assert.equal(summary.breadcrumbs[0].category, "sentry");
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 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"}'
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");
116153
assert.equal(summary.breadcrumbs[0].level, "warning");
117154
assert.equal(summary.breadcrumbs[0].message, "someMessage");
118155
});

0 commit comments

Comments
 (0)