Skip to content

Commit 341b07c

Browse files
committed
react-native: implement FileBreadcrumbsStorage.getAttachmentProviders
1 parent 0143fbb commit 341b07c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
TimeHelper,
66
jsonEscaper,
77
type BacktraceAttachment,
8+
type BacktraceAttachmentProvider,
89
type Breadcrumb,
910
type BreadcrumbsStorage,
1011
type BreadcrumbsStorageFactory,
@@ -56,6 +57,19 @@ export class FileBreadcrumbsStorage implements BreadcrumbsStorage {
5657
];
5758
}
5859

60+
public getAttachmentProviders(): BacktraceAttachmentProvider[] {
61+
return [
62+
{
63+
get: () => new BacktraceFileAttachment(this._fileSystem, this._mainFile, 'bt-breadcrumbs-0'),
64+
type: 'dynamic',
65+
},
66+
{
67+
get: () => new BacktraceFileAttachment(this._fileSystem, this._fallbackFile, 'bt-breadcrumbs-1'),
68+
type: 'dynamic',
69+
},
70+
];
71+
}
72+
5973
public add(rawBreadcrumb: RawBreadcrumb): number {
6074
const breadcrumbType = BreadcrumbType[rawBreadcrumb.type];
6175
if (!breadcrumbType) {
@@ -79,9 +93,9 @@ export class FileBreadcrumbsStorage implements BreadcrumbsStorage {
7993
};
8094

8195
const breadcrumbJson = JSON.stringify(breadcrumb, jsonEscaper());
82-
const jsonLength = breadcrumbJson.length + 1; // newline
8396
const sizeLimit = this._limits.maximumTotalBreadcrumbsSize;
8497
if (sizeLimit !== undefined) {
98+
const jsonLength = breadcrumbJson.length + 1; // newline
8599
if (jsonLength > sizeLimit) {
86100
return id;
87101
}

0 commit comments

Comments
 (0)