Skip to content

Commit 40237b8

Browse files
committed
react-native: remove storage from BacktraceFileAttachment [INT-355]
1 parent 686bada commit 40237b8

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

packages/react-native/src/attachment/BacktraceFileAttachment.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import {
2-
type BacktraceSyncStorage,
3-
type BacktraceFileAttachment as CoreBacktraceFileAttachment,
4-
} from '@backtrace/sdk-core';
5-
import { Platform } from 'react-native';
1+
import { type BacktraceAttachment } from '@backtrace/sdk-core';
2+
import { NativeModules, Platform } from 'react-native';
3+
import type { ReactNativeFileProvider } from '../storage';
64
import { type FileLocation } from '../types/FileLocation';
7-
export class BacktraceFileAttachment implements CoreBacktraceFileAttachment<FileLocation> {
5+
export class BacktraceFileAttachment implements BacktraceAttachment<FileLocation> {
6+
private readonly _fileSystemProvider: ReactNativeFileProvider = NativeModules.BacktraceFileSystemProvider;
7+
88
public readonly name: string;
99
public readonly mimeType: string;
1010

1111
private readonly _uploadUri: string;
1212
constructor(
13-
private readonly _storage: BacktraceSyncStorage,
1413
public readonly filePath: string,
1514
name?: string,
1615
mimeType?: string,
@@ -21,8 +20,7 @@ export class BacktraceFileAttachment implements CoreBacktraceFileAttachment<File
2120
}
2221

2322
public get(): FileLocation | undefined {
24-
const exists = this._storage.hasSync(this.filePath);
25-
23+
const exists = this._fileSystemProvider.existsSync(this.filePath);
2624
if (!exists) {
2725
return undefined;
2826
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class FileBreadcrumbsStorage implements BreadcrumbsStorage {
3636

3737
constructor(
3838
session: SessionFiles,
39-
private readonly _storage: BacktraceStorage & BacktraceSyncStorage & BacktraceStreamStorage,
39+
private readonly _storage: BacktraceStorage & BacktraceStreamStorage,
4040
private readonly _limits: BreadcrumbsStorageLimits,
4141
) {
4242
this._sink = new FileChunkSink({
@@ -83,9 +83,7 @@ export class FileBreadcrumbsStorage implements BreadcrumbsStorage {
8383

8484
public getAttachments(): BacktraceFileAttachment[] {
8585
const files = [...this._sink.files].map((f) => f.path);
86-
return files.map(
87-
(f, i) => new BacktraceFileAttachment(this._storage, f, `bt-breadcrumbs-${i}`, 'application/json'),
88-
);
86+
return files.map((f, i) => new BacktraceFileAttachment(f, `bt-breadcrumbs-${i}`, 'application/json'));
8987
}
9088

9189
public getAttachmentProviders(): BacktraceAttachmentProvider[] {

0 commit comments

Comments
 (0)