Skip to content

Instantly share code, notes, and snippets.

@steven-tey
Created January 28, 2025 17:36
Show Gist options
  • Save steven-tey/9bef11aa3ba6bf9bdd7ec8a34333e8c1 to your computer and use it in GitHub Desktop.
Save steven-tey/9bef11aa3ba6bf9bdd7ec8a34333e8c1 to your computer and use it in GitHub Desktop.
Get links by tenantId and their analytics
const links = await dub.links.list({
tenantId: "xxx"
}).then((res) => res.result)
// if you need all time stats, the links array should have `clicks`, `leads` and `sales`
// for a certain timeframe
const analytics = await Promise.all(links.map(async (link) => {
return await dub.analytics.retrieve({
event: "composite", // to get clicks, leads, sales, and saleAmount
linkId: link.id,
start: "2024-01-01",
end: "2024-01-31",
});
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment