From 7ca97d4606c26d5b9aae94ad292bfe053002696c Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 4 Oct 2022 08:17:05 +0200 Subject: [PATCH] :children_crossing: (sendEmail) Better result logging --- apps/viewer/package.json | 1 + .../[typebotId]/integrations/email.tsx | 13 +++++- pnpm-lock.yaml | 41 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/apps/viewer/package.json b/apps/viewer/package.json index 166350f5c5a..85395fbedfe 100644 --- a/apps/viewer/package.json +++ b/apps/viewer/package.json @@ -49,6 +49,7 @@ "google-auth-library": "8.5.2", "models": "workspace:*", "next-transpile-modules": "9.0.0", + "node-fetch": "^3.2.10", "papaparse": "5.3.2", "typescript": "4.8.4", "uglify-js": "3.17.2", diff --git a/apps/viewer/pages/api/typebots/[typebotId]/integrations/email.tsx b/apps/viewer/pages/api/typebots/[typebotId]/integrations/email.tsx index 2ef34e4bc41..0c343123c94 100644 --- a/apps/viewer/pages/api/typebots/[typebotId]/integrations/email.tsx +++ b/apps/viewer/pages/api/typebots/[typebotId]/integrations/email.tsx @@ -112,7 +112,13 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { } try { const info = await transporter.sendMail(email) - await saveSuccessLog(resultId, 'Email successfully sent') + await saveSuccessLog(resultId, 'Email successfully sent', { + transportConfig: { + ...transportConfig, + auth: { user: transportConfig.auth.user, pass: '******' }, + }, + email, + }) return res.status(200).send({ message: 'Email sent!', info, @@ -120,7 +126,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { }) } catch (err) { await saveErrorLog(resultId, 'Email not sent', { - transportConfig, + transportConfig: { + ...transportConfig, + auth: { user: transportConfig.auth.user, pass: '******' }, + }, email, error: err, }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 92287ff8492..196f3b62de4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -349,6 +349,7 @@ importers: models: workspace:* next: 12.3.1 next-transpile-modules: 9.0.0 + node-fetch: ^3.2.10 nodemailer: 6.8.0 papaparse: 5.3.2 qs: 6.11.0 @@ -397,6 +398,7 @@ importers: google-auth-library: 8.5.2 models: link:../../packages/models next-transpile-modules: 9.0.0 + node-fetch: 3.2.10 papaparse: 5.3.2 typescript: 4.8.4 uglify-js: 3.17.2 @@ -8565,6 +8567,11 @@ packages: resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} dev: true + /data-uri-to-buffer/4.0.0: + resolution: {integrity: sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==} + engines: {node: '>= 12'} + dev: true + /data-urls/3.0.2: resolution: {integrity: sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==} engines: {node: '>=12'} @@ -10019,6 +10026,14 @@ packages: xml-js: 1.6.11 dev: false + /fetch-blob/3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.2.1 + dev: true + /figures/2.0.0: resolution: {integrity: sha512-Oa2M9atig69ZkfwiApY8F2Yy+tzMbazyvqv21R0NsSC8floSOC09BbT1ITWAdoMGQvJ/aZnR1KMwdx9tvHnTNA==} engines: {node: '>=4'} @@ -10202,6 +10217,13 @@ packages: mime-types: 2.1.35 dev: true + /formdata-polyfill/4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + dependencies: + fetch-blob: 3.2.0 + dev: true + /forwarded/0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -13532,6 +13554,11 @@ packages: tslib: 2.4.0 dev: false + /node-domexception/1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + dev: true + /node-emoji/1.11.0: resolution: {integrity: sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A==} dependencies: @@ -13549,6 +13576,15 @@ packages: dependencies: whatwg-url: 5.0.0 + /node-fetch/3.2.10: + resolution: {integrity: sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + data-uri-to-buffer: 4.0.0 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + dev: true + /node-forge/1.3.1: resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==} engines: {node: '>= 6.13.0'} @@ -17669,6 +17705,11 @@ packages: transitivePeerDependencies: - encoding + /web-streams-polyfill/3.2.1: + resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==} + engines: {node: '>= 8'} + dev: true + /webidl-conversions/3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==}