Skip to content

Commit cd52cee

Browse files
committed
react-native: allow for unlimited breadcrumbs in FileBreadcrumbsStorage
1 parent b84b04e commit cd52cee

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

packages/react-native/src/breadcrumbs/AlternatingFileWriter.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ export class AlternatingFileWriter {
1717
private readonly _fileSystem: FileSystem,
1818
private readonly _mainFile: string,
1919
private readonly _fallbackFile: string,
20-
private readonly _maxLines: number,
20+
private readonly _maxLines?: number,
2121
private readonly _maxSize?: number,
2222
) {
23-
if (this._maxLines <= 0) {
24-
throw new Error('File capacity may not be less or equal to 0.');
25-
}
2623
this._streamWriter = this._fileSystem.streamWriter;
2724
}
2825

@@ -72,11 +69,11 @@ export class AlternatingFileWriter {
7269

7370
const logLength = log.length + 1;
7471

75-
if (currentCount + 1 > this._maxLines) {
72+
if (currentCount + 1 > (this._maxLines ?? Infinity)) {
7673
break;
7774
}
7875

79-
if (this._maxSize && currentSize + logLength >= this._maxSize) {
76+
if (currentSize + logLength >= (this._maxSize ?? Infinity)) {
8077
break;
8178
}
8279

@@ -111,7 +108,7 @@ export class AlternatingFileWriter {
111108
private prepareBreadcrumbStream(newSize: number) {
112109
if (!this._streamId) {
113110
this._streamId = this._streamWriter.create(this._mainFile);
114-
} else if (this._count >= this._maxLines || (this._maxSize && this._size + newSize >= this._maxSize)) {
111+
} else if (this._count >= (this._maxLines ?? Infinity) || this._size + newSize >= (this._maxSize ?? Infinity)) {
115112
this.switchFile();
116113
}
117114
}

packages/react-native/src/breadcrumbs/FileBreadcrumbsStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class FileBreadcrumbsStorage implements BreadcrumbsStorage {
3636
_fileSystem,
3737
_mainFile,
3838
_fallbackFile,
39-
Math.floor((this._limits.maximumBreadcrumbs ?? 100) / 2),
39+
this._limits.maximumBreadcrumbs ? Math.floor(this._limits.maximumBreadcrumbs / 2) : undefined,
4040
this._limits.maximumTotalBreadcrumbsSize,
4141
);
4242
}

0 commit comments

Comments
 (0)