Skip to content
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

fix: add safe access to loggerProvider in session replay plugin #949

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions packages/plugin-session-replay-browser/src/session-replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class SessionReplayPlugin implements EnrichmentPlugin {

async setup(config: BrowserConfig) {
try {
config.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);
config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);

this.config = config;

Expand Down Expand Up @@ -66,7 +66,7 @@ export class SessionReplayPlugin implements EnrichmentPlugin {
experimental: this.options.experimental,
}).promise;
} catch (error) {
config.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);
config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ export class SessionReplayPlugin implements EnrichmentPlugin {

return Promise.resolve(event);
} catch (error) {
this.config.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);
this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);
return Promise.resolve(event);
}
}
Expand All @@ -123,7 +123,7 @@ export class SessionReplayPlugin implements EnrichmentPlugin {
// @ts-ignore
this.config = null;
} catch (error) {
this.config.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);
this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);
}
}

Expand Down
Loading