Skip to content

ref(hub): remove hard cap from maxBreadcrumbs #5873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/hub/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ import {
import { updateSession } from './session';

/**
* Absolute maximum number of breadcrumbs added to an event.
* The `maxBreadcrumbs` option cannot be higher than this value.
* Default value for maximum number of breadcrumbs added to an event.
*/
const MAX_BREADCRUMBS = 100;
const DEFAULT_MAX_BREADCRUMBS = 100;

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

// No data has been changed, so don't notify scope listeners
if (maxCrumbs <= 0) {
Expand Down
6 changes: 3 additions & 3 deletions packages/hub/test/scope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ describe('Scope', () => {
expect((scope as any)._breadcrumbs).toHaveLength(5);
});

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

test('setLevel', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp

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

Expand Down