From 530af3d7d68cbd3b3e87c4adb063e5516294fa9f Mon Sep 17 00:00:00 2001 From: David Leek Date: Fri, 27 Sep 2024 14:57:26 +0200 Subject: [PATCH] fix: some integrations only counted errors not all results (#8295) --- src/lib/addons/datadog.ts | 14 +++++++------- src/lib/addons/slack-app.ts | 6 +++--- src/lib/addons/slack.ts | 14 +++++++------- src/lib/addons/teams.ts | 14 +++++++------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/lib/addons/datadog.ts b/src/lib/addons/datadog.ts index 2f1516467be1..27cf38b7d703 100644 --- a/src/lib/addons/datadog.ts +++ b/src/lib/addons/datadog.ts @@ -113,16 +113,16 @@ export default class DatadogAddon extends Addon { state = 'failed'; const failedMessage = `Datadog Events API request failed with status code: ${res.status}.`; stateDetails.push(failedMessage); - if (this.flagResolver.isEnabled('addonUsageMetrics')) { - this.eventBus.emit(ADDON_EVENTS_HANDLED, { - result: state, - destination: 'datadog', - }); - } - this.logger.warn(failedMessage); } + if (this.flagResolver.isEnabled('addonUsageMetrics')) { + this.eventBus.emit(ADDON_EVENTS_HANDLED, { + result: state, + destination: 'datadog', + }); + } + this.registerEvent({ integrationId, state, diff --git a/src/lib/addons/slack-app.ts b/src/lib/addons/slack-app.ts index 4d4ef0fed7a5..1df686f106f2 100644 --- a/src/lib/addons/slack-app.ts +++ b/src/lib/addons/slack-app.ts @@ -179,6 +179,9 @@ export default class SlackAppAddon extends Addon { stateDetails.push(eventErrorMessage); this.logger.warn(eventErrorMessage); const errorMessage = this.parseError(error); + stateDetails.push(errorMessage); + this.logger.warn(errorMessage, error); + } finally { if (this.flagResolver.isEnabled('addonUsageMetrics')) { this.eventBus.emit(ADDON_EVENTS_HANDLED, { result: state, @@ -186,9 +189,6 @@ export default class SlackAppAddon extends Addon { }); } - stateDetails.push(errorMessage); - this.logger.warn(errorMessage, error); - } finally { this.registerEvent({ integrationId, state, diff --git a/src/lib/addons/slack.ts b/src/lib/addons/slack.ts index 51f992b84e79..86567632d9f3 100644 --- a/src/lib/addons/slack.ts +++ b/src/lib/addons/slack.ts @@ -131,16 +131,16 @@ export default class SlackAddon extends Addon { state = 'successWithErrors'; const successWithErrorsMessage = `Some (${failedRequests.length} of ${results.length}) Slack webhook requests failed. Status codes: ${codes}.`; stateDetails.push(successWithErrorsMessage); - if (this.flagResolver.isEnabled('addonUsageMetrics')) { - this.eventBus.emit(ADDON_EVENTS_HANDLED, { - result: state, - destination: 'slack', - }); - } - this.logger.warn(successWithErrorsMessage); } + if (this.flagResolver.isEnabled('addonUsageMetrics')) { + this.eventBus.emit(ADDON_EVENTS_HANDLED, { + result: state, + destination: 'slack', + }); + } + this.registerEvent({ integrationId, state, diff --git a/src/lib/addons/teams.ts b/src/lib/addons/teams.ts index 52dda9127b3b..5c14d7204477 100644 --- a/src/lib/addons/teams.ts +++ b/src/lib/addons/teams.ts @@ -107,16 +107,16 @@ export default class TeamsAddon extends Addon { state = 'failed'; const failedMessage = `Teams webhook request failed with status code: ${res.status}.`; stateDetails.push(failedMessage); - if (this.flagResolver.isEnabled('addonUsageMetrics')) { - this.eventBus.emit(ADDON_EVENTS_HANDLED, { - result: state, - destination: 'teams', - }); - } - this.logger.warn(failedMessage); } + if (this.flagResolver.isEnabled('addonUsageMetrics')) { + this.eventBus.emit(ADDON_EVENTS_HANDLED, { + result: state, + destination: 'teams', + }); + } + this.registerEvent({ integrationId, state,