Skip to content

Commit 7304215

Browse files
authored
ref(hub): Remove hard cap from maxBreadcrumbs (#5873)
- Remove the hard cap of a maximum number of 100 breadcrumbs per event. As of this change, the `maxBreadcrumbs` option will no longer be overridden if it is set to >100. - Adjust JSDoc of the option to clarify that events >1MB will be dropped - Adjust and add tests
1 parent fcde2a8 commit 7304215

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

packages/hub/src/scope.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ import {
3434
import { updateSession } from './session';
3535

3636
/**
37-
* Absolute maximum number of breadcrumbs added to an event.
38-
* The `maxBreadcrumbs` option cannot be higher than this value.
37+
* Default value for maximum number of breadcrumbs added to an event.
3938
*/
40-
const MAX_BREADCRUMBS = 100;
39+
const DEFAULT_MAX_BREADCRUMBS = 100;
4140

4241
/**
4342
* Holds additional event information. {@link Scope.applyToEvent} will be
@@ -392,7 +391,7 @@ export class Scope implements ScopeInterface {
392391
* @inheritDoc
393392
*/
394393
public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this {
395-
const maxCrumbs = typeof maxBreadcrumbs === 'number' ? Math.min(maxBreadcrumbs, MAX_BREADCRUMBS) : MAX_BREADCRUMBS;
394+
const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;
396395

397396
// No data has been changed, so don't notify scope listeners
398397
if (maxCrumbs <= 0) {

packages/hub/test/scope.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ describe('Scope', () => {
7575
expect((scope as any)._breadcrumbs).toHaveLength(5);
7676
});
7777

78-
test('addBreadcrumb cannot go over MAX_BREADCRUMBS value', () => {
78+
test('addBreadcrumb can go over DEFAULT_MAX_BREADCRUMBS value', () => {
7979
const scope = new Scope();
80-
for (let i = 0; i < 111; i++) {
80+
for (let i = 0; i < 120; i++) {
8181
scope.addBreadcrumb({ message: 'test' }, 111);
8282
}
83-
expect((scope as any)._breadcrumbs).toHaveLength(100);
83+
expect((scope as any)._breadcrumbs).toHaveLength(111);
8484
});
8585

8686
test('setLevel', () => {

packages/types/src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
9393

9494
/**
9595
* The maximum number of breadcrumbs sent with events. Defaults to 100.
96-
* Values over 100 will be ignored and 100 used instead.
96+
* Sentry has a maximum payload size of 1MB and any events exceeding that payload size will be dropped.
9797
*/
9898
maxBreadcrumbs?: number;
9999

0 commit comments

Comments
 (0)