From 87b54c91c20be4867cd5922c774f7b8f3b79bf0b Mon Sep 17 00:00:00 2001 From: ElasticBottle Date: Fri, 6 Dec 2024 22:33:24 +0000 Subject: [PATCH] fix: client analytics for ecosystem wallet (#5643) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://linear.app/thirdweb/issue/CNCT-2526/analytics-discrepancy-after-migration-to-ecosystem-wallets This fixes for all queries from Nov onwards. We have to think of a solution to backfill for data stretching before Nov if customers ask for it --- ## PR-Codex overview This PR focuses on refactoring the handling of ecosystem identifiers in the codebase, changing from using `ecosystemId` to `ecosystemSlug` for better clarity and consistency across various components and functions. ### Detailed summary - Changed prop from `ecosystemId` to `ecosystemSlug` in `EcosystemAnalyticsPage`. - Updated `getEcosystemWalletUsage` calls to use `ecosystemSlug` instead of `ecosystemId` in `EcosystemSlugLayout` and `EcosystemAnalyticsPage`. - Adjusted the parameter type in `EcosystemAnalyticsPage` and `getEcosystemWalletUsage` to reflect the new `ecosystemSlug` usage. - Modified the fetch URL in `getEcosystemWalletUsage` to use `ecosystemSlug` for API requests. - Updated error message in `getEcosystemWalletUsage` to specify "ecosystem wallet stats". > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../analytics/components/EcosystemAnalyticsPage.tsx | 6 +++--- .../(team)/~/ecosystem/[slug]/(active)/analytics/page.tsx | 2 +- .../[slug]/(active)/components/EcosystemSlugLayout.tsx | 4 ++-- apps/dashboard/src/data/analytics/wallets/ecosystem.ts | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx index 63a4179fa0c..0433316c8c2 100644 --- a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx @@ -7,16 +7,16 @@ import { getEcosystemWalletUsage } from "data/analytics/wallets/ecosystem"; import { EcosystemWalletUsersChartCard } from "./EcosystemWalletUsersChartCard"; export async function EcosystemAnalyticsPage({ - ecosystemId, + ecosystemSlug, interval, range, -}: { ecosystemId: string; interval: "day" | "week"; range?: Range }) { +}: { ecosystemSlug: string; interval: "day" | "week"; range?: Range }) { if (!range) { range = getLastNDaysRange("last-120"); } const stats = await getEcosystemWalletUsage({ - ecosystemId, + ecosystemSlug, from: range.from, to: range.to, period: interval, diff --git a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/page.tsx b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/page.tsx index 0dd293b987c..0b3f809d281 100644 --- a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/page.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/page.tsx @@ -22,7 +22,7 @@ export default async function Page(props: { const ecosystem = await getEcosystem(params.slug); return ( diff --git a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/EcosystemSlugLayout.tsx b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/EcosystemSlugLayout.tsx index e66d848ded0..90149874100 100644 --- a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/EcosystemSlugLayout.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/EcosystemSlugLayout.tsx @@ -33,14 +33,14 @@ export async function EcosystemLayoutSlug({ } const allTimeStatsPromise = getEcosystemWalletUsage({ - ecosystemId: ecosystem.id, + ecosystemSlug: ecosystem.slug, from: new Date(2022, 0, 1), to: new Date(), period: "all", }); const monthlyStatsPromise = getEcosystemWalletUsage({ - ecosystemId: ecosystem.id, + ecosystemSlug: ecosystem.slug, from: new Date(new Date().getFullYear(), new Date().getMonth(), 1), to: new Date(), period: "month", diff --git a/apps/dashboard/src/data/analytics/wallets/ecosystem.ts b/apps/dashboard/src/data/analytics/wallets/ecosystem.ts index 7ee299a825d..877ea142b25 100644 --- a/apps/dashboard/src/data/analytics/wallets/ecosystem.ts +++ b/apps/dashboard/src/data/analytics/wallets/ecosystem.ts @@ -2,12 +2,12 @@ import type { EcosystemWalletStats } from "types/analytics"; import { fetchAnalytics } from "../fetch-analytics"; export async function getEcosystemWalletUsage(args: { - ecosystemId: string; + ecosystemSlug: string; from?: Date; to?: Date; period?: "day" | "week" | "month" | "year" | "all"; }) { - const { ecosystemId, from, to, period } = args; + const { ecosystemSlug, from, to, period } = args; const searchParams = new URLSearchParams(); if (from) { @@ -20,7 +20,7 @@ export async function getEcosystemWalletUsage(args: { searchParams.append("period", period); } const res = await fetchAnalytics( - `v1/wallets/ecosystem/${ecosystemId}?${searchParams.toString()}`, + `v1/wallets/ecosystem/${ecosystemSlug}?${searchParams.toString()}`, { method: "GET", headers: { @@ -30,7 +30,7 @@ export async function getEcosystemWalletUsage(args: { ); if (res?.status !== 200) { - console.error("Failed to fetch in-app wallet stats"); + console.error("Failed to fetch ecosystem wallet stats"); return null; }