Skip to content

Commit

Permalink
Create "Bugsnag loaded" breadcrumb (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
foxyblocks authored Sep 9, 2016
1 parent 8dd5376 commit e803070
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/bugsnag.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,11 @@
trackConsoleLog();
trackNavigation();

// Leave the initial breadcrumb
if (getSetting("autoBreadcrumbs", true)) {
self.leaveBreadcrumb({ type: "navigation", name: "Bugsnag Loaded" });
}

window.Bugsnag = self;
// If people are using a javascript loader, we should integrate with it.
// We don't want to defer instrumenting their code with callbacks however,
Expand Down
20 changes: 10 additions & 10 deletions test/test.bugsnag.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ describe("Bugsnag", function () {
}
};

var actual = requestData().params.breadcrumbs[0];
var actual = requestData().params.breadcrumbs[1];

assert(actual, "no breadcrumbs present");
assert.equal(actual.type, expected.type);
Expand All @@ -455,7 +455,7 @@ describe("Bugsnag", function () {
}
};

var actual = requestData().params.breadcrumbs[0];
var actual = requestData().params.breadcrumbs[1];

assert.equal(actual.name, expected.name);
assert.deepEqual(actual.metaData, expected.metaData);
Expand All @@ -475,7 +475,7 @@ describe("Bugsnag", function () {
Bugsnag.leaveBreadcrumb(expected);
Bugsnag.notify("Something");

var actual = requestData().params.breadcrumbs[0];
var actual = requestData().params.breadcrumbs[1];

assert.deepEqual(actual, expected);
});
Expand All @@ -493,14 +493,14 @@ describe("Bugsnag", function () {
Bugsnag.notify("Something");

// Replacing an invalid breadcrumb also triggers a console log breadcrumb
var logCrumb = requestData().params.breadcrumbs[0];
var logCrumb = requestData().params.breadcrumbs[1];
assert.equal(logCrumb.type, "log");
assert.equal(
logCrumb.metaData.message,
"[Bugsnag] Converted invalid breadcrumb type 'fanciful' to 'manual'"
);

var actualCrumb = requestData().params.breadcrumbs[1];
var actualCrumb = requestData().params.breadcrumbs[2];
assert.equal(actualCrumb.type, "manual");
});

Expand All @@ -512,7 +512,7 @@ describe("Bugsnag", function () {
Bugsnag.leaveBreadcrumb(longValue);
Bugsnag.notify("Something");

var crumb = requestData().params.breadcrumbs[0];
var crumb = requestData().params.breadcrumbs[1];

assert.equal(crumb.metaData.message.length, 140);
});
Expand Down Expand Up @@ -550,7 +550,7 @@ describe("Bugsnag", function () {
}
};

var actual = requestData().params.breadcrumbs[0];
var actual = requestData().params.breadcrumbs[1];

assert(actual, "no breadcrumbs present");
assert.equal(actual.type, expected.type);
Expand All @@ -562,22 +562,22 @@ describe("Bugsnag", function () {
container.className = "blue steel";
clickOn(container);
Bugsnag.notify("Something");
var selector = requestData().params.breadcrumbs[0].metaData.targetSelector;
var selector = requestData().params.breadcrumbs[1].metaData.targetSelector;
assert.equal(selector, "DIV#container.blue.steel");
});

it("trims target text", function() {
container.textContent = "\n Hello \n\n";
clickOn(container);
Bugsnag.notify("Something");
assert.equal(requestData().params.breadcrumbs[0].metaData.targetText, "Hello");
assert.equal(requestData().params.breadcrumbs[1].metaData.targetText, "Hello");
});

it("handles invalid id attributes", function() {
container.id = "12345";
clickOn(container);
Bugsnag.notify("Something");
var selector = requestData().params.breadcrumbs[0].metaData.targetSelector;
var selector = requestData().params.breadcrumbs[1].metaData.targetSelector;
assert.equal(selector, "DIV#12345");
});
});
Expand Down

0 comments on commit e803070

Please sign in to comment.