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.

Make ProcessedLinkProps' `userId` optional

Tim Wilsone479f14bfa02
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.ts
index 3922a26ad0..bf7c67e527 100644
--- a/apps/web/lib/api/links/process-link.ts
+++ b/apps/web/lib/api/links/process-link.ts
@@ -301,7 +301,9 @@ export async function processLink<T extends Record<string, any>>({
// make sure projectId is set to the current workspace
projectId: workspace?.id || null,
// if userId is passed, set it (we don't change the userId if it's already set, e.g. when editing a link)
- userId: userId || payload.userId || null,
+ ...(userId && {
+ userId,
+ }),
},
error: null,
};
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 1dc41c5668..6744112e6e 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -163,9 +163,9 @@ export interface SAMLProviderProps {
export type NewLinkProps = z.infer<typeof createLinkBodySchema>;
-type ProcessedLinkOverrides = "domain" | "key" | "url" | "projectId" | "userId";
+type ProcessedLinkOverrides = "domain" | "key" | "url" | "projectId";
export type ProcessedLinkProps = Omit<NewLinkProps, ProcessedLinkOverrides> &
- Pick<LinkProps, ProcessedLinkOverrides>;
+ Pick<LinkProps, ProcessedLinkOverrides> & { userId?: LinkProps["userId"] };
export const plans = [
"free",