From cb57309baa378044f0809883179188a25a5710f8 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 29 Jul 2024 14:22:24 +0000 Subject: [PATCH 1/2] fix(browser): Guard for `this._flushOutcomes` if old `BaseClient`s are floating around --- packages/browser/src/client.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/browser/src/client.ts b/packages/browser/src/client.ts index 177d787a438d..7eac62095ec9 100644 --- a/packages/browser/src/client.ts +++ b/packages/browser/src/client.ts @@ -65,7 +65,11 @@ export class BrowserClient extends BaseClient { if (opts.sendClientReports && WINDOW.document) { WINDOW.document.addEventListener('visibilitychange', () => { if (WINDOW.document.visibilityState === 'hidden') { - this._flushOutcomes(); + // Theoretically and strictly speaking this check is unnecessary use people that have old BaseClients floating + // around may not have the method. We guard for its existence to prevent these users from throwing here and eating up quota. + if (this._flushOutcomes) { + this._flushOutcomes(); + } } }); } From 5144b5a5a7de209ac0056100385ba9ec600e6645 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 29 Jul 2024 16:35:11 +0200 Subject: [PATCH 2/2] Update client.ts Co-authored-by: Lukas Stracke --- packages/browser/src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser/src/client.ts b/packages/browser/src/client.ts index 7eac62095ec9..dbb252116adb 100644 --- a/packages/browser/src/client.ts +++ b/packages/browser/src/client.ts @@ -65,7 +65,7 @@ export class BrowserClient extends BaseClient { if (opts.sendClientReports && WINDOW.document) { WINDOW.document.addEventListener('visibilitychange', () => { if (WINDOW.document.visibilityState === 'hidden') { - // Theoretically and strictly speaking this check is unnecessary use people that have old BaseClients floating + // Theoretically and strictly speaking this check is unnecessary but people that have old BaseClients floating // around may not have the method. We guard for its existence to prevent these users from throwing here and eating up quota. if (this._flushOutcomes) { this._flushOutcomes();