Skip to content

Commit 8e2aaf6

Browse files
committed
posthog migration: part 5
1 parent ec8dc42 commit 8e2aaf6

File tree

108 files changed

+177
-2349
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

+177
-2349
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ export function reportContractDeployFailed(properties: {
3939
posthog.capture("contract deploy failed", properties);
4040
}
4141

42+
/**
43+
* ### Why do we need to report this event?
44+
* - To track the number of contracts published
45+
* - To understand the type of contracts published
46+
* - To understand who publishes contracts
47+
*
48+
* ### Who is responsible for this event?
49+
* @jnsdls
50+
*
51+
*/
52+
export function reportContractPublished(properties: {
53+
publisher: string;
54+
contractName: string;
55+
version: string;
56+
deployType: string | undefined;
57+
}) {
58+
posthog.capture("contract published", properties);
59+
}
60+
4261
// ----------------------------
4362
// ONBOARDING (TEAM)
4463
// ----------------------------

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
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/index.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
MenuList,
1818
} from "@chakra-ui/react";
1919
import { TransactionButton } from "components/buttons/TransactionButton";
20-
import { useTrack } from "hooks/analytics/useTrack";
2120
import { useTxNotifications } from "hooks/useTxNotifications";
2221
import { CircleHelpIcon, PlusIcon } from "lucide-react";
2322
import { Fragment, createContext, useContext, useMemo, useState } from "react";
@@ -204,7 +203,6 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
204203
// if neither 1155 or 20 then it's 721
205204
const isErc721 = !isErc20 && !isErc1155;
206205
const walletAddress = useActiveAccount()?.address;
207-
const trackEvent = useTrack();
208206

209207
const isAdmin = useIsAdmin(contract);
210208
const [openSnapshotIndex, setOpenSnapshotIndex] = useState(-1);
@@ -359,13 +357,6 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
359357
});
360358

361359
const handleFormSubmit = form.handleSubmit(async (d) => {
362-
const category = isErc20 ? "token" : "nft";
363-
364-
trackEvent({
365-
category,
366-
action: "set-claim-conditions",
367-
label: "attempt",
368-
});
369360
if (isErc20 && !tokenDecimals.data) {
370361
return toast.error(
371362
`Could not fetch token decimals for contract ${contract.address}`,
@@ -385,11 +376,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
385376
d.phases,
386377
);
387378
await sendTx.mutateAsync(tx);
388-
trackEvent({
389-
category,
390-
action: "set-claim-conditions",
391-
label: "success",
392-
});
379+
393380
saveClaimPhaseNotification.onSuccess();
394381

395382
const newPhases = d.phases.map((phase) => ({
@@ -401,11 +388,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
401388
form.setValue("phases", newPhases);
402389
} catch (error) {
403390
console.error(error);
404-
trackEvent({
405-
category,
406-
action: "set-claim-conditions",
407-
label: "error",
408-
});
391+
409392
if (error instanceof ZodError) {
410393
// biome-ignore lint/complexity/noForEach: FIXME
411394
error.errors.forEach((e) => {

0 commit comments

Comments
 (0)