Skip to content

Commit

Permalink
fix: client analytics for ecosystem wallet (#5643)
Browse files Browse the repository at this point in the history
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

<!-- start pr-codex -->

---

## 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}`

<!-- end pr-codex -->
  • Loading branch information
ElasticBottle committed Dec 6, 2024
1 parent 16e5347 commit 87b54c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default async function Page(props: {
const ecosystem = await getEcosystem(params.slug);
return (
<EcosystemAnalyticsPage
ecosystemId={ecosystem.id}
ecosystemSlug={ecosystem.slug}
interval={searchParams.interval || "week"}
range={searchParams.range}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions apps/dashboard/src/data/analytics/wallets/ecosystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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: {
Expand All @@ -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;
}

Expand Down

0 comments on commit 87b54c9

Please sign in to comment.