From 3a9aa1a72b39b90d83df885d543a1ad8d8ee103f Mon Sep 17 00:00:00 2001 From: MananTank Date: Sat, 2 Aug 2025 02:10:19 +0000 Subject: [PATCH] Dashboard: Fix Payment link buy completion tracking (#7783) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR focuses on simplifying the `reportPaymentLinkBuySuccessful` and `reportPaymentLinkBuyFailed` functions by removing unnecessary parameters and adjusting their calls accordingly. ### Detailed summary - Removed `linkId` and `clientId` parameters from the `reportPaymentLinkBuySuccessful` function. - Adjusted the call to `reportPaymentLinkBuySuccessful` in `PayPageWidget.client.tsx` to no longer pass parameters. - Simplified the call to `reportPaymentLinkBuyFailed` by removing `linkId` and `clientId` parameters and retaining only `errorMessage`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit * **Refactor** * Streamlined payment reporting by simplifying success and failure event tracking. Payment success is now always reported without additional details, and payment failure reports only include the error message. No impact on payment or redirect flows. --- apps/dashboard/src/@/analytics/report.ts | 9 ++------- .../components/client/PayPageWidget.client.tsx | 18 +++++------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/apps/dashboard/src/@/analytics/report.ts b/apps/dashboard/src/@/analytics/report.ts index 1f3352e90ea..f0a0246529a 100644 --- a/apps/dashboard/src/@/analytics/report.ts +++ b/apps/dashboard/src/@/analytics/report.ts @@ -435,11 +435,8 @@ export function reportPaymentLinkCreated(properties: { * ### Who is responsible for this event? * @greg */ -export function reportPaymentLinkBuySuccessful(properties: { - linkId: string; - clientId: string; -}) { - posthog.capture("payment link buy successful", properties); +export function reportPaymentLinkBuySuccessful() { + posthog.capture("payment link buy successful"); } /** @@ -451,8 +448,6 @@ export function reportPaymentLinkBuySuccessful(properties: { * @greg */ export function reportPaymentLinkBuyFailed(properties: { - linkId: string; - clientId: string; errorMessage: string; }) { posthog.capture("payment link buy failed", properties); diff --git a/apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx b/apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx index f52b2ed3aa4..58e4a73fe58 100644 --- a/apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx +++ b/apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx @@ -62,24 +62,16 @@ export function PayPageWidget({ image={image} name={name} onSuccess={() => { + reportPaymentLinkBuySuccessful(); + if (!redirectUri) return; const url = new URL(redirectUri); - if (paymentLinkId && clientId) { - reportPaymentLinkBuySuccessful({ - linkId: paymentLinkId, - clientId: clientId, - }); - } return window.open(url.toString()); }} onError={(error) => { - if (paymentLinkId && clientId) { - reportPaymentLinkBuyFailed({ - linkId: paymentLinkId, - clientId: clientId, - errorMessage: error.message, - }); - } + reportPaymentLinkBuyFailed({ + errorMessage: error.message, + }); }} paymentLinkId={paymentLinkId} purchaseData={purchaseData}