Skip to content

Commit

Permalink
Breadcrumbs history configurable number
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsharE committed Jan 12, 2022
1 parent fd5a305 commit 79ec577
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 22 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ new Elmahio({
application: null,
filter: null,
captureConsoleMinimumLevel: 'none',
breadcrumbs: false
breadcrumbs: false,
breadcrumbsNumber: 10
});
```

Expand Down
19 changes: 14 additions & 5 deletions dist/elmahio.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/elmahio.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/elmahio.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/elmahio.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion elmah.io.javascript.nuspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>3.5.3</version>
<version>3.5.4</version>
<authors>elmah.io</authors>
<owners>elmah.io</owners>
<id>elmah.io.javascript</id>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elmah.io.javascript",
"description": "elmah.io javascript logger.",
"version": "3.5.3",
"version": "3.5.4",
"repository": "https://github.com/elmahio/elmah.io.javascript",
"license": "Apache-2.0",
"main": "dist/elmahio.js",
Expand Down
28 changes: 18 additions & 10 deletions src/elmahio.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* elmah.io Javascript Logger - version 3.5.3
* elmah.io Javascript Logger - version 3.5.4
* (c) 2018 elmah.io, Apache 2.0 License, https://elmah.io
*/

Expand Down Expand Up @@ -616,7 +616,8 @@
application: null,
filter: null,
captureConsoleMinimumLevel: 'none',
breadcrumbs: false
breadcrumbs: false,
breadcrumbsNumber: 10
};

var breadcrumbsDelay = 100;
Expand Down Expand Up @@ -1068,9 +1069,8 @@
}
gps.pinpoint(sf).then(resolve, resolveOriginal)['catch'](resolveOriginal);
});
})));
}
);
})));
});

promise.then(function(newFrames){
newFrames.forEach(function(stackFrame, i){
Expand Down Expand Up @@ -1111,12 +1111,20 @@
// Private methods

var recordBreadcrumb = function(obj) {
var crumb = merge_objects({
'dateTime': new Date().toISOString()
}, obj);

var crumb = merge_objects({'dateTime': new Date().toISOString()}, obj),
breadcrumbs_number = 10;

breadcrumbs.push(crumb);
if (breadcrumbs.length > 10) { // max 10 breadcrumbs

if(options.breadcrumbsNumber && typeof options.breadcrumbsNumber === "number" ) {
if(options.breadcrumbsNumber > 25) {
breadcrumbs_number = 25;
} else if(options.breadcrumbsNumber >= 10 && options.breadcrumbsNumber <= 25) {
breadcrumbs_number = options.breadcrumbsNumber;
}
}

if (breadcrumbs.length >= breadcrumbs_number) {
breadcrumbs.shift();
}
}
Expand Down
5 changes: 5 additions & 0 deletions typescript/elmahio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ declare namespace Elmahio {
* Log breadcrumbs
*/
breadcrumbs?: boolean;
/**
* Number of breadcrumbs to log.
* Minimum 10, maximum 25 breadcrumbs.
*/
breadcrumbsNumber?: number;
}

interface Item {
Expand Down

0 comments on commit 79ec577

Please sign in to comment.