useplunk / plunk

The Open-Source Email Platform
https://www.useplunk.com
GNU Affero General Public License v3.0
2.86k stars 127 forks source link

Link tracking broken in transactional emails #108

Open serge005 opened 2 weeks ago

serge005 commented 2 weeks ago

When sending a transactional email with a link, it properly converts it to a tracked link, but clicking that link does not register the "click".

Error in logs:

✖ error PrismaClientValidationError:
Invalid prisma_1.prisma.email.update() invocation in /app/packages/api/controllers/Webhooks/Incoming/SNS.js:61:45

58 if (body.eventType === "Bounce") { 59 signale_1.default.warn(Bounce received for ${email.contact.email} from ${project.name}); 60 } → 61 await prisma_1.prisma.email.update({ where: { messageId: "010001924a70cf24-89e0e14c-6b27-48cf-a9c9-744fd9e3ba1b-000000" }, data: { status: "CLICKED"


       }
     })

Invalid value for argument `status`. Expected EmailStatus.
    at Dn (/app/node_modules/@prisma/client/runtime/library.js:114:8082)
    at Mn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:7396)
    at Mn.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:7061)
    at Mn.request (/app/node_modules/@prisma/client/runtime/library.js:121:6745)
    at async l (/app/node_modules/@prisma/client/runtime/library.js:130:9633)
    at async SNSWebhook.receiveSNSWebhook (/app/packages/api/controllers/Webhooks/Incoming/SNS.js:61:17)
::ffff:127.0.0.1 - POST /webhooks/incoming/sns HTTP/1.1 200 - - 30.141 ms
driaug commented 1 week ago

The link is properly tagged and tracked but the reason why it fails is because this case does not have a return statement.

It creates the link record and then continues.

https://github.com/useplunk/plunk/blob/main/packages/api/src/controllers/Webhooks/Incoming/SNS.ts#L45-L50