📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix: parse userId from subscription_payment_succeeded passthrough as a fallback to subId check
Blue Moused172c6d8bcd7
diff --git a/backend/apps/cloud/src/webhook/webhook.controller.ts b/backend/apps/cloud/src/webhook/webhook.controller.tsindex a5d7122e1..89c13638f 100644--- a/backend/apps/cloud/src/webhook/webhook.controller.ts+++ b/backend/apps/cloud/src/webhook/webhook.controller.ts@@ -232,12 +232,31 @@ export class WebhookController {}case 'subscription_payment_succeeded': {- const { subscription_id: subID, next_bill_date: nextBillDate } = body+ const {+ passthrough,+ subscription_id: subID,+ next_bill_date: nextBillDate,+ } = body- const subscriber = await this.userService.findOne({+ let uid+ try {+ uid = JSON.parse(passthrough)?.uid+ } catch {+ this.logger.error(+ `[subscription_payment_succeeded] Cannot parse the uid: ${JSON.stringify(body)}`,+ )+ }++ let subscriber = await this.userService.findOne({where: { subID },})+ if (!subscriber && uid) {+ subscriber = await this.userService.findOne({+ where: { id: uid },+ })+ }+if (!subscriber) {this.logger.error(`[subscription_payment_succeeded] Cannot find the subscriber with subID: ${subID}\nBody: ${JSON.stringify(@@ -267,8 +286,8 @@ export class WebhookController {}if (Object.keys(updateParams).length > 0) {- await this.userService.updateBySubID(subID, updateParams)- await this.projectService.clearProjectsRedisCacheBySubId(subID)+ await this.userService.update(subscriber.id, updateParams)+ await this.projectService.clearProjectsRedisCache(subscriber.id)}break