Skip to content

Commit 943cd1b

Browse files
authored
Chore: Payment links tracking (#7769)
1 parent ed65f4c commit 943cd1b

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

apps/dashboard/src/@/analytics/report.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,31 @@ export function reportUpsellClicked(properties: UpsellParams) {
428428
export function reportPaymentCardClick(properties: { id: string }) {
429429
posthog.capture("payment card clicked", properties);
430430
}
431+
432+
/**
433+
* ### Why do we need to report this event?
434+
* - To track payment link usage
435+
*
436+
* ### Who is responsible for this event?
437+
* @greg
438+
*/
439+
export function reportPaymentLinkVisited(properties: {
440+
linkId: string;
441+
clientId: string;
442+
}) {
443+
posthog.capture("payment link visited", properties);
444+
}
445+
446+
/**
447+
* ### Why do we need to report this event?
448+
* - To track payment link usage
449+
*
450+
* ### Who is responsible for this event?
451+
* @greg
452+
*/
453+
export function reportPaymentLinkCompleted(properties: {
454+
linkId: string;
455+
clientId: string;
456+
}) {
457+
posthog.capture("payment link completed", properties);
458+
}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/components/RecentPaymentsSection.client.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { TableRow } from "./PaymentsTableRow";
1919
export function RecentPaymentsSection(props: {
2020
client: ThirdwebClient;
2121
projectClientId: string;
22+
teamSlug: string;
23+
projectSlug: string;
2224
teamId: string;
2325
}) {
2426
const { data: payPurchaseData, isLoading } = useQuery<
@@ -95,7 +97,10 @@ export function RecentPaymentsSection(props: {
9597
className="flex items-center gap-2"
9698
asChild
9799
>
98-
<Link href="/pay" target="_blank">
100+
<Link
101+
href={`/team/${props.teamSlug}/${props.projectSlug}/payments/links`}
102+
target="_blank"
103+
>
99104
Create Payment Link
100105
<ArrowRightIcon className="size-4" />
101106
</Link>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export default async function Page(props: {
4545
client={client}
4646
projectClientId={project.publishableKey}
4747
teamId={project.teamId}
48+
projectSlug={params.project_slug}
49+
teamSlug={params.team_slug}
4850
/>
4951
<div className="h-12" />
5052
<QuickStartSection

apps/dashboard/src/app/pay/[id]/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
22
import { defineChain, getContract } from "thirdweb";
33
import { getCurrencyMetadata } from "thirdweb/extensions/erc20";
44
import { checksumAddress } from "thirdweb/utils";
5+
import { reportPaymentLinkVisited } from "@/analytics/report";
56
import { getPaymentLink } from "@/api/universal-bridge/links";
67
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
78
import { PayPageWidget } from "../components/client/PayPageWidget.client";
@@ -32,6 +33,11 @@ export default async function PayPage({
3233
paymentId: id,
3334
});
3435

36+
reportPaymentLinkVisited({
37+
linkId: id,
38+
clientId: paymentLink.clientId,
39+
});
40+
3541
const tokenContract = getContract({
3642
address: paymentLink.destinationToken.address, // for this RPC call, use the dashboard client
3743
// eslint-disable-next-line no-restricted-syntax

apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEffect } from "react";
55
import { createThirdwebClient, NATIVE_TOKEN_ADDRESS, toTokens } from "thirdweb";
66
import { AutoConnect, CheckoutWidget } from "thirdweb/react";
77
import { checksumAddress } from "thirdweb/utils";
8+
import { reportPaymentLinkCompleted } from "@/analytics/report";
89
import { useV5DashboardChain } from "@/hooks/chains/v5-adapter";
910

1011
export function PayPageWidget({
@@ -60,6 +61,12 @@ export function PayPageWidget({
6061
onSuccess={() => {
6162
if (!redirectUri) return;
6263
const url = new URL(redirectUri);
64+
if (paymentLinkId && clientId) {
65+
reportPaymentLinkCompleted({
66+
linkId: paymentLinkId,
67+
clientId: clientId,
68+
});
69+
}
6370
return window.open(url.toString());
6471
}}
6572
paymentLinkId={paymentLinkId}

0 commit comments

Comments
 (0)