From 8df12ddf795667c7c89c6d51ad616f1b897425f6 Mon Sep 17 00:00:00 2001 From: g-tejas Date: Wed, 10 Jul 2024 20:59:51 +0800 Subject: [PATCH] fix: remove dd tag setting from controllers --- src/app/modules/form/admin-form/admin-form.controller.ts | 5 ----- .../form/admin-form/admin-form.payments.controller.ts | 2 -- src/app/modules/form/public-form/public-form.controller.ts | 3 --- .../email-submission/email-submission.controller.ts | 3 +-- src/app/modules/submission/submission.controller.ts | 4 ---- src/app/modules/verification/verification.controller.ts | 6 +----- 6 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/app/modules/form/admin-form/admin-form.controller.ts b/src/app/modules/form/admin-form/admin-form.controller.ts index be66e4834b..f699b732a0 100644 --- a/src/app/modules/form/admin-form/admin-form.controller.ts +++ b/src/app/modules/form/admin-form/admin-form.controller.ts @@ -65,7 +65,6 @@ import { DatabaseValidationError, } from '../../core/core.errors' import { ControllerHandler } from '../../core/core.types' -import { setErrorCode } from '../../datadog/datadog.utils' import * as FeedbackService from '../../feedback/feedback.service' import * as EmailSubmissionMiddleware from '../../submission/email-submission/email-submission.middleware' import * as EmailSubmissionService from '../../submission/email-submission/email-submission.service' @@ -1733,7 +1732,6 @@ export const submitEncryptPreview: ControllerHandler< }) }) .mapErr((error) => { - setErrorCode(error) const { errorMessage, statusCode } = mapSubmissionError(error) return res.status(statusCode).json({ message: errorMessage }) }) @@ -1786,7 +1784,6 @@ export const submitEmailPreview: ControllerHandler< meta: logMeta, error: formResult.error, }) - setErrorCode(formResult.error) const { errorMessage, statusCode } = mapEmailSubmissionError( formResult.error, ) @@ -1804,7 +1801,6 @@ export const submitEmailPreview: ControllerHandler< meta: logMeta, error: parsedResponsesResult.error, }) - setErrorCode(parsedResponsesResult.error) const { errorMessage, statusCode } = mapEmailSubmissionError( parsedResponsesResult.error, ) @@ -1857,7 +1853,6 @@ export const submitEmailPreview: ControllerHandler< meta: logMeta, error: sendAdminEmailResult.error, }) - setErrorCode(sendAdminEmailResult.error) const { statusCode, errorMessage } = mapEmailSubmissionError( sendAdminEmailResult.error, ) diff --git a/src/app/modules/form/admin-form/admin-form.payments.controller.ts b/src/app/modules/form/admin-form/admin-form.payments.controller.ts index 937e4721ea..6daa26832a 100644 --- a/src/app/modules/form/admin-form/admin-form.payments.controller.ts +++ b/src/app/modules/form/admin-form/admin-form.payments.controller.ts @@ -18,7 +18,6 @@ import { createReqMeta } from '../../../utils/request' import { getFormAfterPermissionChecks } from '../../auth/auth.service' import * as AuthService from '../../auth/auth.service' import { ControllerHandler } from '../../core/core.types' -import { setErrorCode } from '../../datadog/datadog.utils' import { getStripeOauthUrl, unlinkStripeAccountFromForm, @@ -265,7 +264,6 @@ const _handleUpdatePayments: ControllerHandler< meta: logMeta, error, }) - setErrorCode(error) const { errorMessage, statusCode } = mapRouteError(error) return res.status(statusCode).json({ message: errorMessage }) }) diff --git a/src/app/modules/form/public-form/public-form.controller.ts b/src/app/modules/form/public-form/public-form.controller.ts index c93ff2b637..e30fec669b 100644 --- a/src/app/modules/form/public-form/public-form.controller.ts +++ b/src/app/modules/form/public-form/public-form.controller.ts @@ -20,7 +20,6 @@ import { createReqMeta, getRequestIp } from '../../../utils/request' import { getFormIfPublic } from '../../auth/auth.service' import * as BillingService from '../../billing/billing.service' import { ControllerHandler } from '../../core/core.types' -import { setErrorCode } from '../../datadog/datadog.utils' import { MYINFO_AUTH_CODE_COOKIE_NAME, MYINFO_AUTH_CODE_COOKIE_OPTIONS, @@ -97,8 +96,6 @@ export const handleGetPublicForm: ControllerHandler< } const { errorMessage, statusCode } = mapRouteError(error) - setErrorCode(error) - // Specialized error response for PrivateFormError. // This is to maintain backwards compatibility with the middleware implementation if (error instanceof PrivateFormError) { diff --git a/src/app/modules/submission/email-submission/email-submission.controller.ts b/src/app/modules/submission/email-submission/email-submission.controller.ts index e0488c7c04..fea4a06be8 100644 --- a/src/app/modules/submission/email-submission/email-submission.controller.ts +++ b/src/app/modules/submission/email-submission/email-submission.controller.ts @@ -18,7 +18,7 @@ import * as TurnstileMiddleware from '../../../services/turnstile/turnstile.midd import * as TurnstileService from '../../../services/turnstile/turnstile.service' import { createReqMeta, getRequestIp } from '../../../utils/request' import { ControllerHandler } from '../../core/core.types' -import { setErrorCode, setFormTags } from '../../datadog/datadog.utils' +import { setFormTags } from '../../datadog/datadog.utils' import * as FormService from '../../form/form.service' import { MYINFO_LOGIN_COOKIE_NAME, @@ -452,7 +452,6 @@ export const submitEmailModeForm: ControllerHandler< }, ) .mapErr((error) => { - setErrorCode(error) const { errorMessage, statusCode } = mapRouteError(error) return res .status(statusCode) diff --git a/src/app/modules/submission/submission.controller.ts b/src/app/modules/submission/submission.controller.ts index 9b4b3fd8ff..8fe6890875 100644 --- a/src/app/modules/submission/submission.controller.ts +++ b/src/app/modules/submission/submission.controller.ts @@ -21,7 +21,6 @@ import { createReqMeta } from '../../utils/request' import { getFormAfterPermissionChecks } from '../auth/auth.service' import { DatabaseError } from '../core/core.errors' import { ControllerHandler } from '../core/core.types' -import { setErrorCode } from '../datadog/datadog.utils' import { PermissionLevel } from '../form/admin-form/admin-form.types' import { PaymentNotFoundError } from '../payments/payments.errors' import { getPopulatedUserById } from '../user/user.service' @@ -128,7 +127,6 @@ export const getMetadata: ControllerHandler< meta: logMeta, error, }) - setErrorCode(error) const { statusCode, errorMessage } = mapRouteError(error) return res.status(statusCode).json({ message: errorMessage, @@ -263,7 +261,6 @@ export const handleGetEncryptedResponse: ControllerHandler< meta: logMeta, error, }) - setErrorCode(error) const { statusCode, errorMessage } = mapRouteError(error) return res.status(statusCode).json({ message: errorMessage, @@ -346,7 +343,6 @@ export const streamEncryptedResponses: ControllerHandler< meta: logMeta, error: cursorResult.error, }) - setErrorCode(cursorResult.error) const { statusCode, errorMessage } = mapRouteError(cursorResult.error) return res.status(statusCode).json({ message: errorMessage, diff --git a/src/app/modules/verification/verification.controller.ts b/src/app/modules/verification/verification.controller.ts index 7db68ceb65..f7b560ff6c 100644 --- a/src/app/modules/verification/verification.controller.ts +++ b/src/app/modules/verification/verification.controller.ts @@ -12,7 +12,7 @@ import { createLoggerWithLabel } from '../../config/logger' import { generateOtpWithHash } from '../../utils/otp' import { createReqMeta, getRequestIp } from '../../utils/request' import { ControllerHandler } from '../core/core.types' -import { setErrorCode, setFormTags } from '../datadog/datadog.utils' +import { setFormTags } from '../datadog/datadog.utils' import * as FormService from '../form/form.service' import { MyInfoService } from '../myinfo/myinfo.service' import * as MyInfoUtil from '../myinfo/myinfo.util' @@ -60,7 +60,6 @@ export const handleCreateVerificationTransaction: ControllerHandler< meta: logMeta, error, }) - setErrorCode(error) const { errorMessage, statusCode } = mapRouteError(error) return res.status(statusCode).json({ message: errorMessage }) }) @@ -204,7 +203,6 @@ export const _handleGenerateOtp: ControllerHandler< meta: logMeta, error, }) - setErrorCode(error) const { errorMessage, statusCode } = mapRouteError(error) return res.status(statusCode).json({ message: errorMessage }) }) @@ -274,7 +272,6 @@ export const _handleOtpVerification: ControllerHandler< meta: logMeta, error, }) - setErrorCode(error) const { statusCode, errorMessage } = mapRouteError(error) return res.status(statusCode).json({ message: errorMessage }) }) @@ -337,7 +334,6 @@ export const handleResetFieldVerification: ControllerHandler< meta: logMeta, error, }) - setErrorCode(error) const { errorMessage, statusCode } = mapRouteError(error) return res.status(statusCode).json({ message: errorMessage }) })