Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/dashboard/src/@/analytics/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,31 @@ export function reportUpsellClicked(properties: UpsellParams) {
export function reportPaymentCardClick(properties: { id: string }) {
posthog.capture("payment card clicked", properties);
}

/**
* ### Why do we need to report this event?
* - To track payment link usage
*
* ### Who is responsible for this event?
* @greg
*/
export function reportPaymentLinkVisited(properties: {
linkId: string;
clientId: string;
}) {
posthog.capture("payment link visited", properties);
}

/**
* ### Why do we need to report this event?
* - To track payment link usage
*
* ### Who is responsible for this event?
* @greg
*/
export function reportPaymentLinkCompleted(properties: {
linkId: string;
clientId: string;
}) {
posthog.capture("payment link completed", properties);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { TableRow } from "./PaymentsTableRow";
export function RecentPaymentsSection(props: {
client: ThirdwebClient;
projectClientId: string;
teamSlug: string;
projectSlug: string;
teamId: string;
}) {
const { data: payPurchaseData, isLoading } = useQuery<
Expand Down Expand Up @@ -95,7 +97,10 @@ export function RecentPaymentsSection(props: {
className="flex items-center gap-2"
asChild
>
<Link href="/pay" target="_blank">
<Link
href={`/team/${props.teamSlug}/${props.projectSlug}/payments/links`}
target="_blank"
>
Create Payment Link
<ArrowRightIcon className="size-4" />
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export default async function Page(props: {
client={client}
projectClientId={project.publishableKey}
teamId={project.teamId}
projectSlug={params.project_slug}
teamSlug={params.team_slug}
/>
<div className="h-12" />
<QuickStartSection
Expand Down
6 changes: 6 additions & 0 deletions apps/dashboard/src/app/pay/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { defineChain, getContract } from "thirdweb";
import { getCurrencyMetadata } from "thirdweb/extensions/erc20";
import { checksumAddress } from "thirdweb/utils";
import { reportPaymentLinkVisited } from "@/analytics/report";
import { getPaymentLink } from "@/api/universal-bridge/links";
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
import { PayPageWidget } from "../components/client/PayPageWidget.client";
Expand Down Expand Up @@ -32,6 +33,11 @@ export default async function PayPage({
paymentId: id,
});

reportPaymentLinkVisited({
linkId: id,
clientId: paymentLink.clientId,
});

const tokenContract = getContract({
address: paymentLink.destinationToken.address, // for this RPC call, use the dashboard client
// eslint-disable-next-line no-restricted-syntax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEffect } from "react";
import { createThirdwebClient, NATIVE_TOKEN_ADDRESS, toTokens } from "thirdweb";
import { AutoConnect, CheckoutWidget } from "thirdweb/react";
import { checksumAddress } from "thirdweb/utils";
import { reportPaymentLinkCompleted } from "@/analytics/report";
import { useV5DashboardChain } from "@/hooks/chains/v5-adapter";

export function PayPageWidget({
Expand Down Expand Up @@ -60,6 +61,12 @@ export function PayPageWidget({
onSuccess={() => {
if (!redirectUri) return;
const url = new URL(redirectUri);
if (paymentLinkId && clientId) {
reportPaymentLinkCompleted({
linkId: paymentLinkId,
clientId: clientId,
});
}
return window.open(url.toString());
}}
paymentLinkId={paymentLinkId}
Expand Down
Loading