Skip to content

Commit 20cb255

Browse files
committed
posthog migration: part 5
1 parent 8fe1dca commit 20cb255

File tree

108 files changed

+229
-2353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+229
-2353
lines changed

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

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,26 @@ export function reportContractDeployed(properties: {
1919
address: string;
2020
chainId: number;
2121
}) {
22-
posthog.capture("contract deployed", {
23-
address: properties.address,
24-
chainId: properties.chainId,
25-
});
22+
posthog.capture("contract deployed", properties);
23+
}
24+
25+
/**
26+
* ### Why do we need to report this event?
27+
* - To track the number of contracts published
28+
* - To understand the type of contracts published
29+
* - To understand who publishes contracts
30+
*
31+
* ### Who is responsible for this event?
32+
* @jnsdls
33+
*
34+
*/
35+
export function reportContractPublished(properties: {
36+
publisher: string;
37+
contractName: string;
38+
version: string;
39+
deployType: string | undefined;
40+
}) {
41+
posthog.capture("contract published", properties);
2642
}
2743

2844
// ----------------------------
@@ -138,3 +154,54 @@ export function reportOnboardingMembersUpsellPlanSelected(properties: {
138154
export function reportOnboardingCompleted() {
139155
posthog.capture("onboarding completed");
140156
}
157+
158+
// ----------------------------
159+
// FAUCET
160+
// ----------------------------
161+
162+
/**
163+
* ### Why do we need to report this event?
164+
* - To track which chain the faucet was used on
165+
* - To track how popular specific faucets are
166+
*
167+
* ### Who is responsible for this event?
168+
* @jnsdls
169+
*
170+
*/
171+
export function reportFaucetUsed(properties: {
172+
chainId: number;
173+
}) {
174+
posthog.capture("faucet used", {
175+
chainId: properties.chainId,
176+
});
177+
}
178+
179+
// ----------------------------
180+
// CHAIN CONFIGURATION
181+
// ----------------------------
182+
183+
/**
184+
* ### Why do we need to report this event?
185+
* - To track which custom chains customers are adding that we may want to add to the app
186+
*
187+
* ### Who is responsible for this event?
188+
* @jnsdls
189+
*
190+
*/
191+
export function reportChainConfigurationAdded(properties: {
192+
chainId: number;
193+
chainName: string;
194+
rpcURLs: readonly string[];
195+
nativeCurrency: {
196+
name: string;
197+
symbol: string;
198+
decimals: number;
199+
};
200+
}) {
201+
posthog.capture("chain configuration added", {
202+
chainId: properties.chainId,
203+
chainName: properties.chainName,
204+
rpcURLs: properties.rpcURLs,
205+
nativeCurrency: properties.nativeCurrency,
206+
});
207+
}

apps/dashboard/src/@/components/blocks/pricing-card.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Button } from "@/components/ui/button";
55
import { ToolTipLabel } from "@/components/ui/tooltip";
66
import { cn } from "@/lib/utils";
77
import { RenewSubscriptionButton } from "components/settings/Account/Billing/renew-subscription/renew-subscription-button";
8-
import { useTrack } from "hooks/analytics/useTrack";
98
import { CheckIcon, DollarSignIcon } from "lucide-react";
109
import Link from "next/link";
1110
import type React from "react";
@@ -58,7 +57,6 @@ export const PricingCard: React.FC<PricingCardProps> = ({
5857
}) => {
5958
const plan = TEAM_PLANS[billingPlan];
6059

61-
const trackEvent = useTrack();
6260
const remainingTrialDays =
6361
(activeTrialEndsAt ? remainingDays(activeTrialEndsAt) : 0) || 0;
6462

@@ -68,15 +66,6 @@ export const PricingCard: React.FC<PricingCardProps> = ({
6866
billingStatus === "noPayment" &&
6967
billingPlan === "growth";
7068

71-
const handleCTAClick = () => {
72-
cta?.onClick?.();
73-
trackEvent({
74-
category: "account",
75-
label: `${billingPlan}Plan`,
76-
action: "click",
77-
});
78-
};
79-
8069
return (
8170
<div
8271
className={cn(
@@ -163,7 +152,7 @@ export const PricingCard: React.FC<PricingCardProps> = ({
163152
buttonProps={{
164153
variant: highlighted ? "default" : "outline",
165154
className: highlighted ? undefined : "bg-background",
166-
onClick: handleCTAClick,
155+
onClick: cta.onClick,
167156
}}
168157
teamSlug={teamSlug}
169158
sku={billingPlanToSkuMap[billingPlan]}
@@ -181,7 +170,7 @@ export const PricingCard: React.FC<PricingCardProps> = ({
181170
<Link
182171
href={cta.href}
183172
target="_blank"
184-
onClick={handleCTAClick}
173+
onClick={cta.onClick}
185174
rel="noopener noreferrer"
186175
>
187176
{has7DayTrial ? "Start 7 Day Free Trial" : cta.label}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/FaucetButton.tsx

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use client";
2+
import { reportFaucetUsed } from "@/analytics/report";
23
import { CopyTextButton } from "@/components/ui/CopyTextButton";
34
import { Spinner } from "@/components/ui/Spinner/Spinner";
45
import { Button } from "@/components/ui/button";
@@ -29,7 +30,6 @@ import { Turnstile } from "@marsidev/react-turnstile";
2930
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3031
import type { CanClaimResponseType } from "app/(app)/api/testnet-faucet/can-claim/CanClaimResponseType";
3132
import { mapV4ChainToV5Chain } from "contexts/map-chains";
32-
import { useTrack } from "hooks/analytics/useTrack";
3333
import Link from "next/link";
3434
import { usePathname } from "next/navigation";
3535
import { useForm } from "react-hook-form";
@@ -95,17 +95,11 @@ export function FaucetButton({
9595
chain: definedChain,
9696
client,
9797
});
98-
const trackEvent = useTrack();
98+
9999
const queryClient = useQueryClient();
100100

101101
const claimMutation = useMutation({
102102
mutationFn: async (turnstileToken: string) => {
103-
trackEvent({
104-
category: "faucet",
105-
action: "claim",
106-
label: "attempt",
107-
chain_id: chainId,
108-
});
109103
const response = await fetch("/api/testnet-faucet/claim", {
110104
method: "POST",
111105
headers: {
@@ -124,20 +118,8 @@ export function FaucetButton({
124118
}
125119
},
126120
onSuccess: () => {
127-
trackEvent({
128-
category: "faucet",
129-
action: "claim",
130-
label: "success",
131-
chain_id: chainId,
132-
});
133-
},
134-
onError: (error) => {
135-
trackEvent({
136-
category: "faucet",
137-
action: "claim",
138-
label: "error",
139-
chain_id: chainId,
140-
errorMsg: error instanceof Error ? error.message : "Unknown error",
121+
reportFaucetUsed({
122+
chainId,
141123
});
142124
},
143125
onSettled: () => {
@@ -223,8 +205,9 @@ export function FaucetButton({
223205
{canClaimFaucetQuery.data.type === "unsupported-chain" &&
224206
"Faucet is empty right now"}
225207

208+
{/* TODO: add an upsell path here to subscribe to one of these plans */}
226209
{canClaimFaucetQuery.data.type === "paid-plan-required" &&
227-
"Faucet is only available on Starter, Growth and Pro plans."}
210+
"Faucet is only available on Starter, Growth, Scale and Pro plans."}
228211
</Button>
229212
);
230213
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/PayModal.tsx

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22
import { Button } from "@/components/ui/button";
33
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
4-
import { useTrack } from "hooks/analytics/useTrack";
54
import { defineDashboardChain } from "lib/defineDashboardChain";
65
import { useTheme } from "next-themes";
76
import type { ThirdwebClient } from "thirdweb";
@@ -14,21 +13,11 @@ export function PayModalButton(props: {
1413
client: ThirdwebClient;
1514
}) {
1615
const { theme } = useTheme();
17-
const trackEvent = useTrack();
16+
1817
return (
1918
<Dialog>
2019
<DialogTrigger asChild>
21-
<Button
22-
variant="primary"
23-
className="w-full"
24-
onClick={() => {
25-
trackEvent({
26-
category: "pay",
27-
action: "buy",
28-
label: "attempt",
29-
});
30-
}}
31-
>
20+
<Button variant="primary" className="w-full">
3221
{props.label}
3322
</Button>
3423
</DialogTrigger>
@@ -42,35 +31,6 @@ export function PayModalButton(props: {
4231
theme={getSDKTheme(theme === "dark" ? "dark" : "light")}
4332
className="!w-auto"
4433
payOptions={{
45-
// biome-ignore lint/suspicious/noExplicitAny: false positive
46-
onPurchaseSuccess(info: any) {
47-
if (
48-
info.type === "crypto" &&
49-
info.status.status !== "NOT_FOUND"
50-
) {
51-
trackEvent({
52-
category: "pay",
53-
action: "buy",
54-
label: "success",
55-
type: info.type,
56-
chainId: info.status.quote.toToken.chainId,
57-
tokenAddress: info.status.quote.toToken.tokenAddress,
58-
amount: info.status.quote.toAmount,
59-
});
60-
}
61-
62-
if (info.type === "fiat" && info.status.status !== "NOT_FOUND") {
63-
trackEvent({
64-
category: "pay",
65-
action: "buy",
66-
label: "success",
67-
type: info.type,
68-
chainId: info.status.quote.toToken.chainId,
69-
tokenAddress: info.status.quote.toToken.tokenAddress,
70-
amount: info.status.quote.estimatedToTokenAmount,
71-
});
72-
}
73-
},
7434
prefillBuy: {
7535
// Do not include local chain overrides for chain pages
7636
// eslint-disable-next-line no-restricted-syntax

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/(marketplace)/components/cancel-tab.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"use client";
22
import { TransactionButton } from "components/buttons/TransactionButton";
3-
import { useTrack } from "hooks/analytics/useTrack";
4-
import { useAllChainsData } from "hooks/chains/allChains";
53
import { toast } from "sonner";
64
import type { ThirdwebContract } from "thirdweb";
75
import { cancelAuction, cancelListing } from "thirdweb/extensions/marketplace";
@@ -20,9 +18,6 @@ export const CancelTab: React.FC<CancelTabProps> = ({
2018
isAuction,
2119
isLoggedIn,
2220
}) => {
23-
const trackEvent = useTrack();
24-
const { idToChain } = useAllChainsData();
25-
const network = idToChain.get(contract.chain.id);
2621
const transaction = isAuction
2722
? cancelAuction({ contract, auctionId: BigInt(id) })
2823
: cancelListing({ contract, listingId: BigInt(id) });
@@ -36,28 +31,8 @@ export const CancelTab: React.FC<CancelTabProps> = ({
3631
transactionCount={1}
3732
isPending={cancelQuery.isPending}
3833
onClick={() => {
39-
trackEvent({
40-
category: "marketplace",
41-
action: "cancel-listing",
42-
label: "attempt",
43-
});
4434
const promise = cancelQuery.mutateAsync(transaction, {
45-
onSuccess: () => {
46-
trackEvent({
47-
category: "marketplace",
48-
action: "cancel-listing",
49-
label: "success",
50-
network,
51-
});
52-
},
5335
onError: (error) => {
54-
trackEvent({
55-
category: "marketplace",
56-
action: "cancel-listing",
57-
label: "error",
58-
network,
59-
error,
60-
});
6136
console.error(error);
6237
},
6338
});

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/(marketplace)/components/list-form.tsx

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import {
1515
import { TransactionButton } from "components/buttons/TransactionButton";
1616
import { CurrencySelector } from "components/shared/CurrencySelector";
1717
import { SolidityInput } from "contract-ui/components/solidity-inputs";
18-
import { useTrack } from "hooks/analytics/useTrack";
19-
import { useAllChainsData } from "hooks/chains/allChains";
2018
import { useTxNotifications } from "hooks/useTxNotifications";
2119
import { isAlchemySupported } from "lib/wallet/nfts/isAlchemySupported";
2220
import { isMoralisSupported } from "lib/wallet/nfts/isMoralisSupported";
@@ -107,10 +105,8 @@ export const CreateListingsForm: React.FC<CreateListingsFormProps> = ({
107105
mode,
108106
isInsightSupported,
109107
}) => {
110-
const trackEvent = useTrack();
111108
const chainId = contract.chain.id;
112-
const { idToChain } = useAllChainsData();
113-
const network = idToChain.get(chainId);
109+
114110
const [isFormLoading, setIsFormLoading] = useState(false);
115111

116112
const isSupportedChain =
@@ -418,23 +414,8 @@ export const CreateListingsForm: React.FC<CreateListingsFormProps> = ({
418414

419415
await sendAndConfirmTx.mutateAsync(transaction, {
420416
onSuccess: () => {
421-
trackEvent({
422-
category: "marketplace",
423-
action: "add-listing",
424-
label: "success",
425-
network,
426-
});
427417
setOpen(false);
428418
},
429-
onError: (error) => {
430-
trackEvent({
431-
category: "marketplace",
432-
action: "add-listing",
433-
label: "error",
434-
network,
435-
error,
436-
});
437-
},
438419
});
439420
auctionNotifications.onSuccess();
440421
}

0 commit comments

Comments
 (0)