From bf36fe09e69333b6bae19a5b557044163d4952cd Mon Sep 17 00:00:00 2001 From: Kevin Pagtakhan Date: Tue, 24 Oct 2023 23:44:16 -0700 Subject: [PATCH] fix: log error trace in catch blocks --- packages/analytics-core/src/core-client.ts | 2 +- packages/analytics-core/src/plugins/destination.ts | 2 +- .../src/ga-events-forwarder.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/analytics-core/src/core-client.ts b/packages/analytics-core/src/core-client.ts index 6d2c84f93..66c739246 100644 --- a/packages/analytics-core/src/core-client.ts +++ b/packages/analytics-core/src/core-client.ts @@ -127,8 +127,8 @@ export class AmplitudeCore implements CoreClient { return result; } catch (e) { + this.config.loggerProvider.error(e); const message = String(e); - this.config.loggerProvider.error(message); const result = buildResult(event, 0, message); return result; diff --git a/packages/analytics-core/src/plugins/destination.ts b/packages/analytics-core/src/plugins/destination.ts index 76d74a7fc..df1a3a238 100644 --- a/packages/analytics-core/src/plugins/destination.ts +++ b/packages/analytics-core/src/plugins/destination.ts @@ -166,8 +166,8 @@ export class Destination implements DestinationPlugin { } this.handleResponse(res, list); } catch (e) { + this.config.loggerProvider.error(e); const errorMessage = getErrorMessage(e); - this.config.loggerProvider.error(errorMessage); this.fulfillRequest(list, 0, errorMessage); } } diff --git a/packages/plugin-ga-events-forwarder-browser/src/ga-events-forwarder.ts b/packages/plugin-ga-events-forwarder-browser/src/ga-events-forwarder.ts index 8d385fb13..b2986a000 100644 --- a/packages/plugin-ga-events-forwarder-browser/src/ga-events-forwarder.ts +++ b/packages/plugin-ga-events-forwarder-browser/src/ga-events-forwarder.ts @@ -110,9 +110,9 @@ export const gaEventsForwarderPlugin = ({ measurementIds = [] }: Options = {}): } } return true; - } catch (error) { + } catch (e) { /* istanbul ignore next */ - logger?.error(String(error)); + logger?.error(e); return false; } };