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.

Conditionally hide badge, fix loading state

Steven Teyf054c80258c7
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/page-client.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/page-client.tsx
index 8b2fad5603..30335cc52f 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/page-client.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/page-client.tsx
@@ -201,18 +201,20 @@ export function ReferralsEmbedPageClient({
<ProgramRewardList rewards={rewards} discount={discount} />
</div>
</div>
- <div className="mt-4 flex justify-center md:absolute md:bottom-3 md:right-3 md:mt-0">
- <a
- href="https://dub.co/partners"
- target="_blank"
- className="hover:text-content-default text-content-subtle bg-bg-default border-border-subtle flex w-fit items-center gap-1.5 rounded-md border px-2 py-1 transition-colors duration-75"
- >
- <p className="whitespace-nowrap text-xs font-medium leading-none">
- Powered by
- </p>
- <Wordmark className="text-content-emphasis h-3.5" />
- </a>
- </div>
+ {!programEmbedData?.hidePoweredByBadge && (
+ <div className="mt-4 flex justify-center md:absolute md:bottom-3 md:right-3 md:mt-0">
+ <a
+ href="https://dub.co/partners"
+ target="_blank"
+ className="hover:text-content-default text-content-subtle bg-bg-default border-border-subtle flex w-fit items-center gap-1.5 rounded-md border px-2 py-1 transition-colors duration-75"
+ >
+ <p className="whitespace-nowrap text-xs font-medium leading-none">
+ Powered by
+ </p>
+ <Wordmark className="text-content-emphasis h-3.5" />
+ </a>
+ </div>
+ )}
</div>
<div className="mt-4 grid gap-2 sm:h-32 sm:grid-cols-3">
<ReferralsEmbedActivity {...stats} />
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/page.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/page.tsx
index 810b2d468a..7be2d75d03 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/page.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/page.tsx
@@ -1,5 +1,5 @@
import { HeroBackground } from "@/ui/partners/hero-background";
-import { Button, Copy, Wordmark } from "@dub/ui";
+import { Button, Copy } from "@dub/ui";
import { Suspense } from "react";
import { DynamicHeightMessenger } from "./dynamic-height-messenger";
import { ReferralsEmbedPageClient } from "./page-client";
@@ -70,7 +70,7 @@ function EmbedInlineLoading({ themeOptions }: { themeOptions: ThemeOptions }) {
Referral link
</span>
<div className="xs:flex-row relative mt-3 flex flex-col items-center gap-2">
- <div className="xs:w-60 border-border-default bg-bg-muted h-10 w-full rounded-md border" />
+ <div className="xs:w-72 border-border-default bg-bg-muted h-10 w-full rounded-md border" />
<Button
icon={<Copy className="size-4" />}
text="Copy link"
@@ -81,18 +81,7 @@ function EmbedInlineLoading({ themeOptions }: { themeOptions: ThemeOptions }) {
<span className="mt-12 text-base font-semibold text-neutral-800">
Rewards
</span>
- <div className="relative mt-2 flex flex-col gap-2">
- <div className="bg-bg-muted h-6 w-60 rounded-md" />
- <div className="bg-bg-muted h-6 w-40 rounded-md" />
- </div>
- <a
- href="https://dub.co/partners"
- target="_blank"
- className="hover:text-content-default text-content-subtle mt-4 flex items-center justify-center gap-1.5 transition-colors duration-75 md:absolute md:bottom-3 md:right-3 md:mt-0 md:translate-x-0"
- >
- <p className="text-xs font-medium">Powered by</p>
- <Wordmark className="text-content-emphasis h-3.5" />
- </a>
+ <div className="bg-bg-default border-border-subtle mt-2 h-20 w-[28rem] rounded-md border" />
</div>
<div className="mt-4 grid gap-2 sm:h-32 sm:grid-cols-3">
<div className="border-border-subtle bg-bg-muted h-full w-full rounded-lg border sm:col-span-2" />
diff --git a/apps/web/lib/api/conversions/track-sale.ts b/apps/web/lib/api/conversions/track-sale.ts
index a330d757a5..1c4ab55099 100644
--- a/apps/web/lib/api/conversions/track-sale.ts
+++ b/apps/web/lib/api/conversions/track-sale.ts
@@ -58,20 +58,11 @@ export const trackSale = async ({
// Return idempotent response if invoiceId is already processed
if (invoiceId) {
- // TODO: remove oldKeyValue stuff after 7 days (on Sep 18)
- const [newKeyValue, oldKeyValue] = await redis.mget([
+ const cachedResponse = await redis.get(
`trackSale:${workspace.id}:invoiceId:${invoiceId}`,
- `dub_sale_events:invoiceId:${invoiceId}`,
- ]);
-
- if (newKeyValue) {
- return newKeyValue;
- } else if (oldKeyValue) {
- return {
- eventName,
- customer: null,
- sale: null,
- };
+ );
+ if (cachedResponse) {
+ return cachedResponse;
}
}
diff --git a/apps/web/lib/zod/schemas/program-embed.ts b/apps/web/lib/zod/schemas/program-embed.ts
index c4bd0b7c5f..32d9354f0b 100644
--- a/apps/web/lib/zod/schemas/program-embed.ts
+++ b/apps/web/lib/zod/schemas/program-embed.ts
@@ -9,5 +9,6 @@ export const programEmbedSchema = z
mode: z.enum(["enabled", "disabled"]).default("enabled"),
})
.nullish(),
+ hidePoweredByBadge: z.boolean().default(false),
})
.nullish();