The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Replace broken SDK method with `fetch`
Tim Wilsondec33f171b31
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/referrals/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/referrals/page.tsxindex 02e42fdc5f..abdb7e51fb 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/referrals/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/referrals/page.tsx@@ -1,7 +1,7 @@+import { getEvents } from "@/lib/actions/get-events";import { getReferralLink } from "@/lib/actions/get-referral-link";import { getTotalEvents } from "@/lib/actions/get-total-events";import { EventType } from "@/lib/analytics/types";-import { dub } from "@/lib/dub";import {REFERRAL_CLICKS_QUOTA_BONUS,REFERRAL_CLICKS_QUOTA_BONUS_MAX,@@ -182,16 +182,7 @@ async function ActivityListRSC({);}- const eventsParams = {- linkId: link.id,- event,- };-- const events = await dub.events.list({- ...eventsParams,- interval: "all",- page,- });+ const events = await getEvents({ linkId: link.id, event, page });const totalEvents = await getTotalEvents(link.id);diff --git a/apps/web/lib/actions/get-events.ts b/apps/web/lib/actions/get-events.tsnew file mode 100644index 0000000000..2e8035168f--- /dev/null+++ b/apps/web/lib/actions/get-events.ts@@ -0,0 +1,35 @@+import { DUB_API_URL } from "@dub/utils";+import { unstable_cache } from "next/cache";+import { EventType } from "../analytics/types";++export const getEvents = unstable_cache(+ async ({+ linkId,+ event,+ page,+ }: {+ linkId: string;+ event: EventType;+ page: number;+ }) => {+ // const eventsParams = {+ // linkId: link.id,+ // event,+ // };++ // const events = await dub.events.list({+ // ...eventsParams,+ // interval: "all",+ // page,+ // });++ return await fetch(+ `${DUB_API_URL}/events?event=${event}&interval=all&linkId=${linkId}&page=${page}`,+ {+ headers: {+ Authorization: `Bearer ${process.env.DUB_API_KEY}`,+ },+ },+ ).then((res) => res.json());+ },+);