Skip to content

Commit 2ed77d1

Browse files
committed
[MNY-211] Dashboard: Add chainId and is_tesnet properties in reported events
1 parent 777aed1 commit 2ed77d1

File tree

17 files changed

+80
-50
lines changed

17 files changed

+80
-50
lines changed

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

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export function reportContractDeployed(properties: {
2424
publisher: string | undefined;
2525
contractName: string | undefined;
2626
deploymentType?: "asset";
27+
is_testnet: boolean | undefined;
2728
}) {
2829
posthog.capture("contract deployed", properties);
2930
}
@@ -40,6 +41,7 @@ export function reportContractDeployed(properties: {
4041
export function reportContractDeployFailed(properties: {
4142
errorMessage: string;
4243
chainId: number;
44+
is_testnet: boolean | undefined;
4345
publisher: string | undefined;
4446
contractName: string | undefined;
4547
}) {
@@ -171,9 +173,7 @@ export function reportOnboardingCompleted() {
171173
*
172174
*/
173175
export function reportFaucetUsed(properties: { chainId: number }) {
174-
posthog.capture("faucet used", {
175-
chainId: properties.chainId,
176-
});
176+
posthog.capture("faucet used", properties);
177177
}
178178

179179
// ----------------------------
@@ -197,12 +197,7 @@ export function reportChainConfigurationAdded(properties: {
197197
decimals: number;
198198
};
199199
}) {
200-
posthog.capture("chain configuration added", {
201-
chainId: properties.chainId,
202-
chainName: properties.chainName,
203-
nativeCurrency: properties.nativeCurrency,
204-
rpcURLs: properties.rpcURLs,
205-
});
200+
posthog.capture("chain configuration added", properties);
206201
}
207202

208203
// ----------------------------
@@ -227,12 +222,9 @@ export function reportAssetBuySuccessful(properties: {
227222
chainId: number;
228223
contractType: AssetContractType | undefined;
229224
assetType: "nft" | "coin";
225+
is_testnet: boolean | undefined;
230226
}) {
231-
posthog.capture("asset buy successful", {
232-
assetType: properties.assetType,
233-
chainId: properties.chainId,
234-
contractType: properties.contractType,
235-
});
227+
posthog.capture("asset buy successful", properties);
236228
}
237229

238230
type TokenSwapParams = {
@@ -349,16 +341,12 @@ export function reportTokenSwapCancelled(properties: TokenSwapParams) {
349341
*/
350342
export function reportAssetBuyFailed(properties: {
351343
chainId: number;
344+
is_testnet: boolean | undefined;
352345
contractType: AssetContractType | undefined;
353346
assetType: "nft" | "coin";
354347
error: string;
355348
}) {
356-
posthog.capture("asset buy failed", {
357-
assetType: properties.assetType,
358-
chainId: properties.chainId,
359-
contractType: properties.contractType,
360-
error: properties.error,
361-
});
349+
posthog.capture("asset buy failed", properties);
362350
}
363351

364352
/**
@@ -371,14 +359,11 @@ export function reportAssetBuyFailed(properties: {
371359
*/
372360
export function reportAssetBuyCancelled(properties: {
373361
chainId: number;
362+
is_testnet: boolean | undefined;
374363
contractType: AssetContractType | undefined;
375364
assetType: "nft" | "coin";
376365
}) {
377-
posthog.capture("asset buy cancelled", {
378-
assetType: properties.assetType,
379-
chainId: properties.chainId,
380-
contractType: properties.contractType,
381-
});
366+
posthog.capture("asset buy cancelled", properties);
382367
}
383368

384369
// Assets Landing Page ----------------------------
@@ -423,10 +408,7 @@ export function reportAssetCreationStepConfigured(
423408
step: "coin-info" | "token-distribution" | "launch-coin";
424409
},
425410
) {
426-
posthog.capture("asset creation step configured", {
427-
assetType: properties.assetType,
428-
step: properties.step,
429-
});
411+
posthog.capture("asset creation step configured", properties);
430412
}
431413

432414
/**
@@ -440,11 +422,10 @@ export function reportAssetCreationStepConfigured(
440422
export function reportAssetCreationSuccessful(properties: {
441423
assetType: "nft" | "coin";
442424
contractType: AssetContractType;
425+
chainId: number;
426+
is_testnet: boolean | undefined;
443427
}) {
444-
posthog.capture("asset creation successful", {
445-
assetType: properties.assetType,
446-
contractType: properties.contractType,
447-
});
428+
posthog.capture("asset creation successful", properties);
448429
}
449430

450431
type CoinCreationStep =
@@ -466,7 +447,12 @@ type CoinCreationStep =
466447
* @MananTank
467448
*/
468449
export function reportAssetCreationFailed(
469-
properties: { contractType: AssetContractType; error: string } & (
450+
properties: {
451+
contractType: AssetContractType;
452+
error: string;
453+
is_testnet: boolean | undefined;
454+
chainId: number;
455+
} & (
470456
| {
471457
assetType: "nft";
472458
step:
@@ -481,12 +467,7 @@ export function reportAssetCreationFailed(
481467
}
482468
),
483469
) {
484-
posthog.capture("asset creation failed", {
485-
assetType: properties.assetType,
486-
contractType: properties.contractType,
487-
error: properties.error,
488-
step: properties.step,
489-
});
470+
posthog.capture("asset creation failed", properties);
490471
}
491472

492473
type UpsellParams = {
@@ -582,6 +563,7 @@ export function reportPaymentLinkBuyFailed(properties: {
582563
export function reportAssetPageview(properties: {
583564
assetType: "nft" | "coin";
584565
chainId: number;
566+
is_testnet: boolean | undefined;
585567
}) {
586568
posthog.capture("asset pageview", properties);
587569
}
@@ -593,7 +575,10 @@ export function reportAssetPageview(properties: {
593575
* ### Who is responsible for this event?
594576
* @MananTank
595577
*/
596-
export function reportChainPageview(properties: { chainId: number }) {
578+
export function reportChainPageview(properties: {
579+
chainId: number;
580+
is_testnet: boolean | undefined;
581+
}) {
597582
posthog.capture("chain pageview", properties);
598583
}
599584

@@ -686,10 +671,7 @@ export function reportProductFeedback(properties: {
686671
feedback: string;
687672
source: "desktop" | "mobile";
688673
}) {
689-
posthog.capture("product feedback submitted", {
690-
feedback: properties.feedback,
691-
source: properties.source,
692-
});
674+
posthog.capture("product feedback submitted", properties);
693675
}
694676

695677
/**

apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function BuyAndSwapEmbed(props: {
3434
tokenAddress: string | undefined;
3535
buyAmount: string | undefined;
3636
pageType: PageType;
37+
isTestnet: boolean | undefined;
3738
}) {
3839
const { theme } = useTheme();
3940
const [tab, setTab] = useState<"buy" | "swap">("swap");
@@ -116,6 +117,7 @@ export function BuyAndSwapEmbed(props: {
116117
chainId: props.chain.id,
117118
error: errorMessage,
118119
contractType: undefined,
120+
is_testnet: props.isTestnet,
119121
});
120122
}
121123
}}
@@ -141,6 +143,7 @@ export function BuyAndSwapEmbed(props: {
141143
assetType: "coin",
142144
chainId: props.chain.id,
143145
contractType: undefined,
146+
is_testnet: props.isTestnet,
144147
});
145148
}
146149
}}
@@ -166,6 +169,7 @@ export function BuyAndSwapEmbed(props: {
166169
assetType: "coin",
167170
chainId: props.chain.id,
168171
contractType: undefined,
172+
is_testnet: props.isTestnet,
169173
});
170174
}
171175
}}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export function BuyFundsSection(props: { chain: ChainMetadata }) {
88
return (
99
<GridPatternEmbedContainer>
1010
<BuyAndSwapEmbed
11+
isTestnet={props.chain.testnet}
1112
// eslint-disable-next-line no-restricted-syntax
1213
chain={defineDashboardChain(props.chain.chainId, props.chain)}
1314
buyAmount={undefined}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
import { reportChainPageview } from "@/analytics/report";
33
import { useEffectOnce } from "@/hooks/useEffectOnce";
44

5-
export function ChainPageView(props: { chainId: number }) {
5+
export function ChainPageView(props: { chainId: number; is_testnet: boolean }) {
66
useEffectOnce(() => {
77
reportChainPageview({
88
chainId: props.chainId,
9+
is_testnet: props.is_testnet,
910
});
1011
});
1112

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default async function ChainPageLayout(props: {
8686

8787
return (
8888
<div className="flex grow flex-col">
89-
<ChainPageView chainId={chain.chainId} />
89+
<ChainPageView chainId={chain.chainId} is_testnet={chain.testnet} />
9090
<div className="border-border border-b bg-card">
9191
<TeamHeader />
9292
</div>

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/asset-page-view.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { useEffectOnce } from "@/hooks/useEffectOnce";
55
export function AssetPageView(props: {
66
assetType: "nft" | "coin";
77
chainId: number;
8+
is_testnet: boolean;
89
}) {
910
useEffectOnce(() => {
1011
reportAssetPageview({
1112
assetType: props.assetType,
1213
chainId: props.chainId,
14+
is_testnet: props.is_testnet,
1315
});
1416
});
1517

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_components/claim-tokens/claim-tokens-ui.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export function TokenDropClaim(props: {
122122
chainId: props.contract.chain.id,
123123
contractType: "DropERC20",
124124
error: errorMessage,
125+
is_testnet: props.chainMetadata.testnet,
125126
});
126127

127128
toast.error("Failed to approve spending", {
@@ -160,6 +161,7 @@ export function TokenDropClaim(props: {
160161
chainId: props.contract.chain.id,
161162
contractType: "DropERC20",
162163
error: errorMessage,
164+
is_testnet: props.chainMetadata.testnet,
163165
});
164166

165167
toast.error("Failed to buy tokens", {
@@ -172,6 +174,7 @@ export function TokenDropClaim(props: {
172174
assetType: "coin",
173175
chainId: props.contract.chain.id,
174176
contractType: "DropERC20",
177+
is_testnet: props.chainMetadata.testnet,
175178
});
176179

177180
setStepsUI({

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/erc20.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ export async function ERC20PublicPage(props: {
7676

7777
return (
7878
<div className="flex grow flex-col">
79-
<AssetPageView assetType="coin" chainId={props.chainMetadata.chainId} />
79+
<AssetPageView
80+
assetType="coin"
81+
chainId={props.chainMetadata.chainId}
82+
is_testnet={props.chainMetadata.testnet}
83+
/>
8084
<PageHeader containerClassName="max-w-7xl" />
8185

8286
<div className="border-b border-dashed">
@@ -199,6 +203,7 @@ function BuyEmbed(props: {
199203
tokenAddress={props.clientContract.address}
200204
buyAmount={undefined}
201205
pageType="asset"
206+
isTestnet={props.chainMetadata.testnet}
202207
/>
203208
);
204209
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/nft/nft-page-layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export function NFTPublicPageLayout(props: {
1818
}) {
1919
return (
2020
<div className="flex grow flex-col">
21-
<AssetPageView assetType="nft" chainId={props.chainMetadata.chainId} />
21+
<AssetPageView
22+
assetType="nft"
23+
chainId={props.chainMetadata.chainId}
24+
is_testnet={props.chainMetadata.testnet}
25+
/>
2226
<PageHeader containerClassName="max-w-8xl" />
2327
<div className="border-b">
2428
<div className="container max-w-8xl">

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/nft/overview/buy-edition-drop/buy-edition-drop.client.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export function BuyEditionDrop(props: BuyEditionDropProps) {
120120
chainId: props.contract.chain.id,
121121
contractType: "DropERC1155",
122122
error: errorMessage,
123+
is_testnet: props.chainMetadata.testnet,
123124
});
124125

125126
console.error(errorMessage);
@@ -147,6 +148,7 @@ export function BuyEditionDrop(props: BuyEditionDropProps) {
147148
assetType: "nft",
148149
chainId: props.contract.chain.id,
149150
contractType: "DropERC1155",
151+
is_testnet: props.chainMetadata.testnet,
150152
});
151153

152154
props.onSuccess?.();
@@ -163,6 +165,7 @@ export function BuyEditionDrop(props: BuyEditionDropProps) {
163165
chainId: props.contract.chain.id,
164166
contractType: "DropERC1155",
165167
error: errorMessage,
168+
is_testnet: props.chainMetadata.testnet,
166169
});
167170

168171
return;
@@ -180,6 +183,7 @@ export function BuyEditionDrop(props: BuyEditionDropProps) {
180183
chainId: props.contract.chain.id,
181184
contractType: "DropERC1155",
182185
error: errorMessage,
186+
is_testnet: props.chainMetadata.testnet,
183187
});
184188
}
185189
});

0 commit comments

Comments
 (0)