Skip to content

Commit

Permalink
Capture "sentry" breadcrumb (previous msgs, errors)
Browse files Browse the repository at this point in the history
  • Loading branch information
benvinegar committed Apr 1, 2016
1 parent 5ec0aaa commit f1c6c38
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ Raven.prototype = {
var self = this;
return function () {
self.captureBreadcrumb({
type: "ui_event",
type: 'ui_event',
data: {
type: evt,
target: elem.outerHTML
Expand Down Expand Up @@ -1127,6 +1127,14 @@ Raven.prototype = {
auth.sentry_secret = this._globalSecret;
}

this.captureBreadcrumb({
type: 'sentry',
data: {
message: data.message,
eventId: data.event_id
}
});

var url = this._globalEndpoint;
(globalOptions.transport || this._makeRequest).call(this, {
url: url,
Expand Down
13 changes: 8 additions & 5 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,7 @@ describe('globals', function() {
logger: 'javascript',
maxMessageLength: 100
};
Raven._breadcrumbs = [
{ type: 'request', data: { method: 'POST', url: 'http://example.org/api/0/auth/' }}
];
Raven._breadcrumbs = [{type: 'request', timestamp: 0.1, data: {method: 'POST', url: 'http://example.org/api/0/auth/'}}];

Raven._send({message: 'bar'});
assert.deepEqual(Raven._makeRequest.lastCall.args[0].data, {
Expand All @@ -736,7 +734,12 @@ describe('globals', function() {
event_id: 'abc123',
message: 'bar',
extra: {'session:duration': 100},
breadcrumbs: [{ type: 'request', data: { method: 'POST', url: 'http://example.org/api/0/auth/' }}]
breadcrumbs: {
values: [
{ type: 'request', timestamp: 0.1, data: { method: 'POST', url: 'http://example.org/api/0/auth/' }},
{ type: 'sentry', timestamp: 0.1, /* 100ms */ data: { message: 'bar', eventId: 'abc123' }}
]
}
});
});

Expand Down Expand Up @@ -2180,7 +2183,7 @@ describe('Raven (public API)', function() {
{ id: 3 },
{ id: 4 },
{ id: 5 },
{ id: 6, timestamp: 100 }
{ id: 6, timestamp: 0.1 }
]);
});
});
Expand Down

0 comments on commit f1c6c38

Please sign in to comment.