Skip to content

Commit 018bb91

Browse files
committed
sdk core: load debugIds on DebugIdProvider construction
1 parent 790b329 commit 018bb91

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

packages/sdk-core/src/modules/data/BacktraceDataBuilder.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class BacktraceDataBuilder {
2424

2525
const stackTrace = this._stackTraceConverter.convert(report.stackTrace, report.message);
2626

27-
this._debugIdProvider.loadDebugIds();
2827
for (const frame of stackTrace) {
2928
frame.debug_identifier = this._debugIdProvider.getDebugId(frame.library);
3029
}

packages/sdk-core/src/sourcemaps/DebugIdProvider.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import { DebugIdMapProvider } from './interfaces/DebugIdMapProvider';
44
export const SOURCE_DEBUG_ID_VARIABLE = '_btDebugIds';
55

66
export class DebugIdProvider {
7-
private _fileDebugIds?: Record<string, string>;
7+
private readonly _fileDebugIds: Record<string, string>;
88

99
constructor(
1010
private readonly _stackTraceConverter: BacktraceStackTraceConverter,
1111
private readonly _debugIdMapProvider?: DebugIdMapProvider,
12-
) {}
12+
) {
13+
this._fileDebugIds = this.loadDebugIds();
14+
}
1315

14-
public loadDebugIds(debugIdMap?: Record<string, string>) {
15-
if (this._fileDebugIds) {
16-
return this._fileDebugIds;
17-
}
16+
public getDebugId(file: string): string | undefined {
17+
return this._fileDebugIds[file];
18+
}
1819

20+
private loadDebugIds() {
21+
const debugIdMap = this._debugIdMapProvider?.getDebugIdMap();
1922
if (!debugIdMap) {
20-
debugIdMap = this._debugIdMapProvider?.getDebugIdMap();
21-
if (!debugIdMap) {
22-
return;
23-
}
23+
return {};
2424
}
2525

2626
const message = new Error().message;
@@ -36,10 +36,6 @@ export class DebugIdProvider {
3636
result[frame.library] = debugId;
3737
}
3838

39-
return (this._fileDebugIds = result);
40-
}
41-
42-
public getDebugId(file: string): string | undefined {
43-
return this._fileDebugIds?.[file];
39+
return result;
4440
}
4541
}

0 commit comments

Comments
 (0)