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.

fix links display, fix cancellation feedback

Steven Teyc22cd8cb70b6
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/links/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/links/page.tsx
index 4256ef43ef..8827a0a285 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/links/page.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/links/page.tsx
@@ -1,10 +1,12 @@
-import AdminLinksClient from "app/app.dub.co/(dashboard)/[slug]/links/page-client";
+import { WorkspaceLinksList } from "app/app.dub.co/(dashboard)/[slug]/links/page-client";
import { Suspense } from "react";
export default function AdminLinks() {
return (
<Suspense>
- <AdminLinksClient />
+ <div className="pb-12 pt-4">
+ <WorkspaceLinksList />
+ </div>
</Suspense>
);
}
diff --git a/apps/web/app/(ee)/api/admin/links/route.ts b/apps/web/app/(ee)/api/admin/links/route.ts
index 4491a64359..c5f0e216cf 100644
--- a/apps/web/app/(ee)/api/admin/links/route.ts
+++ b/apps/web/app/(ee)/api/admin/links/route.ts
@@ -1,7 +1,7 @@
import { transformLink } from "@/lib/api/links";
import { withAdmin } from "@/lib/auth";
import { prisma } from "@dub/prisma";
-import { LEGAL_USER_ID } from "@dub/utils";
+import { DUB_DOMAINS_ARRAY, LEGAL_USER_ID } from "@dub/utils";
import { NextResponse } from "next/server";
// GET /api/admin/links
@@ -20,8 +20,10 @@ export const GET = withAdmin(async ({ searchParams }) => {
const response = await prisma.link.findMany({
where: {
- ...(domain && { domain }),
...(!search && {
+ domain: {
+ in: DUB_DOMAINS_ARRAY,
+ },
createdAt: {
gte: new Date(Date.now() - 1000 * 60 * 60 * 24 * 30), // 30 days ago
},
diff --git a/apps/web/app/(ee)/api/stripe/webhook/customer-subscription-deleted.ts b/apps/web/app/(ee)/api/stripe/webhook/customer-subscription-deleted.ts
index b9ca0f875f..3319901253 100644
--- a/apps/web/app/(ee)/api/stripe/webhook/customer-subscription-deleted.ts
+++ b/apps/web/app/(ee)/api/stripe/webhook/customer-subscription-deleted.ts
@@ -6,7 +6,6 @@ import { includeTags } from "@/lib/api/links/include-tags";
import { stripAdvancedRewardModifiersForProgram } from "@/lib/api/partners/strip-advanced-reward-modifiers";
import { deactivateProgram } from "@/lib/api/programs/deactivate-program";
import { tokenCache } from "@/lib/auth/token-cache";
-import { isBlacklistedEmail } from "@/lib/edge-config/is-blacklisted-email";
import { wouldLoseAdvancedFeatures } from "@/lib/plans/would-lose-advanced-features";
import { stripe } from "@/lib/stripe";
import { recordLink } from "@/lib/tinybird";
@@ -101,10 +100,6 @@ export async function customerSubscriptionDeleted(
const workspaceLinks = workspace.links;
const workspaceUsers = workspace.users.map(({ user }) => user);
- const isBlacklistedCancellation = await isBlacklistedEmail(
- workspaceUsers.filter(({ email }) => email).map(({ email }) => email!),
- );
-
await prisma.project.update({
where: {
stripeId,
@@ -174,17 +169,14 @@ export async function customerSubscriptionDeleted(
workspace.slug +
"`* deleted their *`" +
capitalize(workspace.plan) +
- "`* subscription" +
- (isBlacklistedCancellation ? " (blacklisted / banned)" : ""),
+ "`* subscription",
type: "cron",
mention: true,
}),
- // Don't send feedback if the user was blacklisted / banned
- !isBlacklistedCancellation &&
- sendCancellationFeedback({
- owners: workspaceUsers,
- }),
+ sendCancellationFeedback({
+ owners: workspaceUsers,
+ }),
// Disable the webhooks
prisma.webhook.updateMany({
diff --git a/apps/web/app/(ee)/api/stripe/webhook/utils/send-cancellation-feedback.ts b/apps/web/app/(ee)/api/stripe/webhook/utils/send-cancellation-feedback.ts
index df7ae4adc9..f42a358534 100644
--- a/apps/web/app/(ee)/api/stripe/webhook/utils/send-cancellation-feedback.ts
+++ b/apps/web/app/(ee)/api/stripe/webhook/utils/send-cancellation-feedback.ts
@@ -1,3 +1,4 @@
+import { isBlacklistedEmail } from "@/lib/edge-config";
import { sendEmail } from "@dub/email";
import Stripe from "stripe";
@@ -21,6 +22,15 @@ export async function sendCancellationFeedback({
}[];
reason?: Stripe.Subscription.CancellationDetails.Feedback | null;
}) {
+ const isBlacklistedCancellation = await isBlacklistedEmail(
+ owners.filter(({ email }) => email).map(({ email }) => email!),
+ );
+
+ if (isBlacklistedCancellation) {
+ console.log("Blacklisted cancellation, skipping feedback email...");
+ return;
+ }
+
const reasonText = reason ? cancellationReasonMap[reason] : "";
return await Promise.all(
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx
index 7ecef563ee..264c68a883 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx
@@ -66,7 +66,7 @@ export default function WorkspaceLinksClient() {
}
>
<LinksDisplayProvider>
- <WorkspaceLinks />
+ <WorkspaceLinksList />
</LinksDisplayProvider>
</PageContentWithSidePanel>
);
@@ -85,7 +85,7 @@ export function WorkspaceLinksPageControls() {
);
}
-function WorkspaceLinks() {
+export function WorkspaceLinksList() {
const router = useRouter();
const { isValidating } = useLinks();
const searchParams = useSearchParams();
diff --git a/apps/web/lib/links/links-display.ts b/apps/web/lib/links/links-display.ts
index d57e8f1d0e..b0419209c0 100644
--- a/apps/web/lib/links/links-display.ts
+++ b/apps/web/lib/links/links-display.ts
@@ -7,6 +7,10 @@ export const linksSortOptions = [
display: "Date created",
slug: "createdAt",
},
+ {
+ display: "Total revenue",
+ slug: "saleAmount",
+ },
{
display: "Total clicks",
slug: "clicks",
@@ -15,10 +19,6 @@ export const linksSortOptions = [
display: "Last clicked",
slug: "lastClicked",
},
- {
- display: "Total sales",
- slug: "saleAmount",
- },
] as const;
export type LinksSortSlug = (typeof linksSortOptions)[number]["slug"];
diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsx
index c38e0594ea..c31361cf80 100644
--- a/apps/web/ui/links/link-card.tsx
+++ b/apps/web/ui/links/link-card.tsx
@@ -5,6 +5,7 @@ import {
CardList,
ExpandingArrow,
useClickHandlers,
+ useCurrentSubdomain,
useIntersectionObserver,
useRouterStuff,
} from "@dub/ui";
@@ -56,15 +57,20 @@ const LinkCardInner = memo(({ link }: { link: ResponseLink }) => {
const { folderId: currentFolderId } = useCurrentFolderId();
const { slug } = useWorkspace();
const { queryParams } = useRouterStuff();
+ const { subdomain } = useCurrentSubdomain();
// only show the folder icon if:
// - loading is complete
// - the link has a folder id AND the currentFolderId is not the same as the link's folder id
+ // - not the admin dashboard
const showFolderIcon = useMemo(() => {
return Boolean(
- !loading && link.folderId && currentFolderId !== link.folderId,
+ !loading &&
+ link.folderId &&
+ currentFolderId !== link.folderId &&
+ subdomain !== "admin",
);
- }, [loading, link.folderId, currentFolderId]);
+ }, [loading, link.folderId, currentFolderId, subdomain]);
const { folder } = useFolder({
folderId: link.folderId,
diff --git a/apps/web/ui/links/link-title-column.tsx b/apps/web/ui/links/link-title-column.tsx
index dacc7146eb..857cb8f2e8 100644
--- a/apps/web/ui/links/link-title-column.tsx
+++ b/apps/web/ui/links/link-title-column.tsx
@@ -15,6 +15,7 @@ import {
TimestampTooltip,
Tooltip,
TooltipContent,
+ useCurrentSubdomain,
useInViewport,
} from "@dub/ui";
import {
@@ -85,13 +86,17 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {
const hasQuickViewSettings = quickViewSettings.some(({ key }) => link?.[key]);
+ const { subdomain } = useCurrentSubdomain();
const { folderId: currentFolderId } = useCurrentFolderId();
const showFolderIcon = useMemo(() => {
return Boolean(
- !loading && link.folderId && currentFolderId !== link.folderId,
+ !loading &&
+ link.folderId &&
+ currentFolderId !== link.folderId &&
+ subdomain !== "admin",
);
- }, [loading, link.folderId, currentFolderId]);
+ }, [loading, link.folderId, currentFolderId, subdomain]);
const { folder } = useFolder({
folderId: link.folderId,