Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

useProgramRevenue

Steven Teya5a68e14f9d9
diff --git a/apps/web/app/api/programs/[programId]/analytics/route.ts b/apps/web/app/api/programs/[programId]/revenue/route.ts
similarity index 97%
rename from apps/web/app/api/programs/[programId]/analytics/route.ts
rename to apps/web/app/api/programs/[programId]/revenue/route.ts
index e2fcc38c36..22aff540ef 100644
--- a/apps/web/app/api/programs/[programId]/analytics/route.ts
+++ b/apps/web/app/api/programs/[programId]/revenue/route.ts
@@ -24,7 +24,7 @@ interface CommissionData {
saleAmount: number;
}
-// GET /api/programs/[programId]/analytics - get analytics for a program
+// GET /api/programs/[programId]/revenue - get revenue timeseries for a program
export const GET = withWorkspace(
async ({ workspace, params, searchParams }) => {
const { programId } = params;
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/overview-chart.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/overview-chart.tsx
index ada0fd27f1..ed2fa77cb7 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/overview-chart.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/overview-chart.tsx
@@ -1,6 +1,6 @@
import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";
import { IntervalOptions } from "@/lib/analytics/types";
-import useProgramAnalytics from "@/lib/swr/use-program-analytics";
+import useProgramRevenue from "@/lib/swr/use-program-analytics";
import useProgramMetrics from "@/lib/swr/use-program-metrics";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
import { useRouterStuff } from "@dub/ui";
@@ -33,7 +33,7 @@ export function OverviewChart() {
const { metrics } = useProgramMetrics();
- const { data: timeseries, error } = useProgramAnalytics({
+ const { data: timeseries, error } = useProgramRevenue({
event: "sales",
groupBy: "timeseries",
interval,
diff --git a/apps/web/lib/swr/use-program-analytics.ts b/apps/web/lib/swr/use-program-analytics.ts
index 9a25271459..6aa60b61a2 100644
--- a/apps/web/lib/swr/use-program-analytics.ts
+++ b/apps/web/lib/swr/use-program-analytics.ts
@@ -4,12 +4,12 @@ import useSWR from "swr";
import { PartnerAnalyticsFilters } from "../analytics/types";
import useWorkspace from "./use-workspace";
-export default function useProgramAnalytics(params?: PartnerAnalyticsFilters) {
+export default function useProgramRevenue(params?: PartnerAnalyticsFilters) {
const { programId } = useParams();
const { id: workspaceId } = useWorkspace();
const { data, error } = useSWR<any>(
- `/api/programs/${programId}/analytics?${new URLSearchParams({
+ `/api/programs/${programId}/revenue?${new URLSearchParams({
event: params?.event ?? "composite",
...(params?.start && params?.end
? {