From 2e3b88540282b85d9c946a93709eda3d743eaf95 Mon Sep 17 00:00:00 2001 From: Alex Klarfeld Date: Thu, 28 Sep 2023 18:39:14 -0700 Subject: [PATCH] Fixed issue with error reporting --- src/constants.ts | 2 +- src/index.ts | 6 +++--- src/utils.ts | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index a2e266f..48fdffb 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -27,7 +27,7 @@ const errors = { 'No Client Secret Provided, set SUPERGOOD_CLIENT_SECRET or pass it as an argument' }; -const TestErrorPath = '/supergood-test-error'; +const TestErrorPath = '/api/supergood-test-error'; const LocalClientId = 'local-client-id'; const LocalClientSecret = 'local-client-secret'; diff --git a/src/index.ts b/src/index.ts index 92a1f7b..de04802 100644 --- a/src/index.ts +++ b/src/index.ts @@ -83,6 +83,9 @@ const Supergood = () => { stdTTL: 0 }); + errorSinkUrl = `${baseUrl}${supergoodConfig.errorSinkEndpoint}`; + eventSinkUrl = `${baseUrl}${supergoodConfig.eventSinkEndpoint}`; + headerOptions = getHeaderOptions(clientId, clientSecret); log = logger({ errorSinkUrl, headerOptions }); @@ -149,9 +152,6 @@ const Supergood = () => { } }); - errorSinkUrl = `${baseUrl}${supergoodConfig.errorSinkEndpoint}`; - eventSinkUrl = `${baseUrl}${supergoodConfig.eventSinkEndpoint}`; - // Flushes the cache every milliseconds interval = setInterval(flushCache, supergoodConfig.flushInterval); interval.unref(); diff --git a/src/utils.ts b/src/utils.ts index abd8949..a4731fa 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -38,6 +38,7 @@ const logger = ({ JSON.stringify(payload, null, 2), error ); + console.log({ reportOut, errorSinkUrl }); if (reportOut && errorSinkUrl) { postError( errorSinkUrl,