Files
calendar/packages/features/auth/lib/dub.ts
T
f411c6ed11 feat: Use dub.customer.list to issue dual-sided incentives (#18452)
* [FEAT] Use dub.customer to issue dual-sided incentives

* update dub implementation

* uncommit yarn.lock

* Update yarn.lock

* account for self-hosting

* remove comments

---------

Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
2025-01-17 21:33:33 +00:00

19 lines
374 B
TypeScript

import { Dub } from "dub";
export const dub = new Dub({
token: process.env.DUB_API_KEY,
});
export const getDubCustomer = async (userId: string) => {
if (!process.env.DUB_API_KEY) {
return null;
}
const customer = await dub.customers.list({
externalId: userId,
includeExpandedFields: true,
});
return customer.length > 0 ? customer[0] : null;
};