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.

linkTarget → linkScope

Steven Tey3b098ff899c0
diff --git a/apps/web/app/(ee)/api/cron/streams/send-link-click-webhooks/route.ts b/apps/web/app/(ee)/api/cron/streams/send-link-click-webhooks/route.ts
index b127ef893d..b69f44c3f0 100644
--- a/apps/web/app/(ee)/api/cron/streams/send-link-click-webhooks/route.ts
+++ b/apps/web/app/(ee)/api/cron/streams/send-link-click-webhooks/route.ts
@@ -101,7 +101,7 @@ const processStreamBatch = (): Promise<{
id: true,
url: true,
secret: true,
- linkTarget: true,
+ linkScope: true,
projectId: true,
},
}),
@@ -142,11 +142,11 @@ const processStreamBatch = (): Promise<{
]);
const linkTargetWebhookIds = webhooks
- .filter((w) => w.linkTarget === "links")
+ .filter((w) => w.linkScope === "links")
.map((w) => w.id);
const folderTargetWebhookIds = webhooks
- .filter((w) => w.linkTarget === "folders")
+ .filter((w) => w.linkScope === "folders")
.map((w) => w.id);
const folderIds = [
@@ -228,11 +228,11 @@ const processStreamBatch = (): Promise<{
}
const applicableWebhooks = workspaceWebhooks.filter((webhook) => {
- if (webhook.linkTarget === "workspace") {
+ if (webhook.linkScope === "workspace") {
return true;
}
- if (webhook.linkTarget === "links") {
+ if (webhook.linkScope === "links") {
return (
linkWebhooksByLinkId[event.link_id]?.some(
(r) => r.webhookId === webhook.id,
@@ -240,7 +240,7 @@ const processStreamBatch = (): Promise<{
);
}
- if (webhook.linkTarget === "folders") {
+ if (webhook.linkScope === "folders") {
return (
link.folderId != null &&
folderWebhooksByFolderId[link.folderId]?.some(
diff --git a/apps/web/app/api/webhooks/[webhookId]/route.ts b/apps/web/app/api/webhooks/[webhookId]/route.ts
index df70834bbc..cf53cead20 100644
--- a/apps/web/app/api/webhooks/[webhookId]/route.ts
+++ b/apps/web/app/api/webhooks/[webhookId]/route.ts
@@ -65,7 +65,7 @@ export const PATCH = withWorkspace(
},
});
- const { name, url, triggers, linkTarget, linkIds, folderIds } = input;
+ const { name, url, triggers, linkScope, linkIds, folderIds } = input;
// If the webhook is managed by an integration, only the linkIds & triggers can be updated manually.
if (existingWebhook.installationId && (name || url)) {
@@ -85,9 +85,9 @@ export const PATCH = withWorkspace(
);
const nextLinkTarget = hasLinkClickedTrigger
- ? linkTarget !== undefined
- ? linkTarget
- : existingWebhook.linkTarget
+ ? linkScope !== undefined
+ ? linkScope
+ : existingWebhook.linkScope
: null;
const existingLinkIds = existingWebhook.links.map(({ linkId }) => linkId);
@@ -103,7 +103,7 @@ export const PATCH = withWorkspace(
...existingWebhook,
...input,
triggers: finalTriggers,
- linkTarget: nextLinkTarget,
+ linkScope: nextLinkTarget,
...(hasLinkClickedTrigger &&
nextLinkTarget === "links" && { linkIds: nextLinkIds }),
...(hasLinkClickedTrigger &&
@@ -117,17 +117,17 @@ export const PATCH = withWorkspace(
user: session.user,
});
- const linkTargetChanged = nextLinkTarget !== existingWebhook.linkTarget;
+ const linkTargetChanged = nextLinkTarget !== existingWebhook.linkScope;
const shouldSyncLinks =
- (nextWebhook.linkTarget !== "links" && existingLinkIds.length > 0) ||
- (nextWebhook.linkTarget === "links" &&
+ (nextWebhook.linkScope !== "links" && existingLinkIds.length > 0) ||
+ (nextWebhook.linkScope === "links" &&
linkIds !== undefined &&
!arrayEqual(existingLinkIds, linkIds ?? []));
const shouldSyncFolders =
- (nextWebhook.linkTarget !== "folders" && existingFolderIds.length > 0) ||
- (nextWebhook.linkTarget === "folders" &&
+ (nextWebhook.linkScope !== "folders" && existingFolderIds.length > 0) ||
+ (nextWebhook.linkScope === "folders" &&
folderIds !== undefined &&
!arrayEqual(existingFolderIds, folderIds ?? []));
@@ -140,7 +140,7 @@ export const PATCH = withWorkspace(
...(name !== undefined && { name }),
...(url !== undefined && { url }),
...(triggers !== undefined && { triggers }),
- ...(linkTargetChanged && { linkTarget: nextWebhook.linkTarget }),
+ ...(linkTargetChanged && { linkScope: nextWebhook.linkScope }),
},
});
@@ -151,7 +151,7 @@ export const PATCH = withWorkspace(
},
});
- if (nextWebhook.linkTarget === "links" && linkIds?.length) {
+ if (nextWebhook.linkScope === "links" && linkIds?.length) {
await tx.linkWebhook.createMany({
data: linkIds.map((linkId) => ({
linkId,
@@ -168,7 +168,7 @@ export const PATCH = withWorkspace(
},
});
- if (nextWebhook.linkTarget === "folders" && folderIds?.length) {
+ if (nextWebhook.linkScope === "folders" && folderIds?.length) {
await tx.folderWebhook.createMany({
data: folderIds.map((folderId) => ({
folderId,
diff --git a/apps/web/app/api/webhooks/route.ts b/apps/web/app/api/webhooks/route.ts
index 6b2be6b580..54c8a52308 100644
--- a/apps/web/app/api/webhooks/route.ts
+++ b/apps/web/app/api/webhooks/route.ts
@@ -49,7 +49,7 @@ export const POST = withWorkspace(
user: session.user,
});
- const { name, url, triggers, linkTarget, linkIds, folderIds } = input;
+ const { name, url, triggers, linkScope, linkIds, folderIds } = input;
// Zapier use this endpoint to create webhooks from their app
const isZapierWebhook =
@@ -72,7 +72,7 @@ export const POST = withWorkspace(
url,
receiver: isZapierWebhook ? WebhookReceiver.zapier : WebhookReceiver.user,
triggers,
- linkTarget,
+ linkScope,
linkIds,
folderIds,
workspace,
diff --git a/apps/web/lib/integrations/common/ui/configure-webhook.tsx b/apps/web/lib/integrations/common/ui/configure-webhook.tsx
index db63b9a9af..5e403cb6b6 100644
--- a/apps/web/lib/integrations/common/ui/configure-webhook.tsx
+++ b/apps/web/lib/integrations/common/ui/configure-webhook.tsx
@@ -39,7 +39,7 @@ export function ConfigureWebhook({
const [triggerSelection, setTriggerSelection] =
useState<WebhookTriggerSelectorValue>({
triggers: [],
- linkTarget: "workspace",
+ linkScope: "workspace",
linkIds: [],
folderIds: [],
});
@@ -49,7 +49,7 @@ export function ConfigureWebhook({
setTriggerSelection((prev) => ({
...prev,
triggers: webhook.triggers,
- linkTarget: webhook.linkTarget ?? "workspace",
+ linkScope: webhook.linkScope ?? "workspace",
}));
}
}, [webhook]);
@@ -64,7 +64,7 @@ export function ConfigureWebhook({
setSaving(true);
- const { triggers, linkTarget, linkIds, folderIds } = triggerSelection;
+ const { triggers, linkScope, linkIds, folderIds } = triggerSelection;
const hasLinkClicked = triggers.includes(LINK_CLICK_WEBHOOK_TRIGGER);
const response = await fetch(
@@ -77,9 +77,9 @@ export function ConfigureWebhook({
body: JSON.stringify({
triggers,
...(hasLinkClicked && {
- linkTarget,
- ...(linkTarget === "links" && { linkIds }),
- ...(linkTarget === "folders" && { folderIds }),
+ linkScope,
+ ...(linkScope === "links" && { linkIds }),
+ ...(linkScope === "folders" && { folderIds }),
}),
}),
},
@@ -98,12 +98,12 @@ export function ConfigureWebhook({
await Promise.all([
mutate(
`/api/webhooks/${webhookId}/links?workspaceId=${workspaceId}`,
- result.linkTarget === "links" ? linkIds : [],
+ result.linkScope === "links" ? linkIds : [],
{ revalidate: true },
),
mutate(
`/api/webhooks/${webhookId}/folders?workspaceId=${workspaceId}`,
- result.linkTarget === "folders" ? folderIds : [],
+ result.linkScope === "folders" ? folderIds : [],
{ revalidate: true },
),
]);
@@ -139,7 +139,7 @@ export function ConfigureWebhook({
availableTriggers={availableTriggers}
disabled={!canManageWebhook}
webhookId={webhookId}
- savedLinkTarget={webhook?.linkTarget}
+ savedLinkTarget={webhook?.linkScope}
/>
</div>
diff --git a/apps/web/lib/webhook/click-webhook-workspaces.ts b/apps/web/lib/webhook/click-webhook-workspaces.ts
index 0c65b92ffc..4a59398d64 100644
--- a/apps/web/lib/webhook/click-webhook-workspaces.ts
+++ b/apps/web/lib/webhook/click-webhook-workspaces.ts
@@ -114,7 +114,7 @@ export const promoteLinkWebhooksForClick = async () => {
select: {
id: true,
triggers: true,
- linkTarget: true,
+ linkScope: true,
},
take: 100,
});
@@ -140,7 +140,7 @@ export const promoteLinkWebhooksForClick = async () => {
...((webhook.triggers as WebhookTrigger[]) ?? []),
LINK_CLICK_WEBHOOK_TRIGGER,
],
- linkTarget: webhook.linkTarget ?? "links",
+ linkScope: webhook.linkScope ?? "links",
},
}),
),
diff --git a/apps/web/lib/webhook/create-webhook.ts b/apps/web/lib/webhook/create-webhook.ts
index 7db85c8829..24934866b2 100644
--- a/apps/web/lib/webhook/create-webhook.ts
+++ b/apps/web/lib/webhook/create-webhook.ts
@@ -14,7 +14,7 @@ export async function createWebhook({
url,
secret,
triggers,
- linkTarget,
+ linkScope,
linkIds,
folderIds,
workspace,
@@ -43,11 +43,11 @@ export async function createWebhook({
installationId,
projectId: workspace.id,
secret: secret || createWebhookSecret(),
- linkTarget,
+ linkScope,
},
});
- if (linkTarget === "links" && linkIds && linkIds.length > 0) {
+ if (linkScope === "links" && linkIds && linkIds.length > 0) {
await prisma.linkWebhook.createMany({
data: linkIds.map((linkId) => ({
linkId,
@@ -56,7 +56,7 @@ export async function createWebhook({
});
}
- if (linkTarget === "folders" && folderIds && folderIds.length > 0) {
+ if (linkScope === "folders" && folderIds && folderIds.length > 0) {
await prisma.folderWebhook.createMany({
data: folderIds.map((folderId) => ({
folderId,
diff --git a/apps/web/lib/webhook/get-webhooks.ts b/apps/web/lib/webhook/get-webhooks.ts
index 461c98a55e..33d359fe60 100644
--- a/apps/web/lib/webhook/get-webhooks.ts
+++ b/apps/web/lib/webhook/get-webhooks.ts
@@ -31,7 +31,7 @@ export async function getWebhooks({
url: true,
secret: true,
triggers: true,
- linkTarget: true,
+ linkScope: true,
disabledAt: true,
receiver: true,
installationId: true,
diff --git a/apps/web/lib/webhook/validate-webhook.ts b/apps/web/lib/webhook/validate-webhook.ts
index 51640d46c6..f80ac1961d 100644
--- a/apps/web/lib/webhook/validate-webhook.ts
+++ b/apps/web/lib/webhook/validate-webhook.ts
@@ -19,7 +19,7 @@ export async function validateWebhook({
webhook?: Webhook;
user: Session["user"];
}) {
- const { url, linkTarget, linkIds, folderIds, triggers } = input;
+ const { url, linkScope, linkIds, folderIds, triggers } = input;
// payout.confirmed trigger requires external payouts enabled
if (triggers && triggers.includes("payout.confirmed")) {
@@ -64,7 +64,7 @@ export async function validateWebhook({
}
}
- if (linkTarget === "links" && linkIds && linkIds.length > 0) {
+ if (linkScope === "links" && linkIds && linkIds.length > 0) {
const folders = await getFolders({
workspaceId: workspace.id,
userId: user.id,
@@ -95,7 +95,7 @@ export async function validateWebhook({
}
}
- if (linkTarget === "folders" && folderIds && folderIds.length > 0) {
+ if (linkScope === "folders" && folderIds && folderIds.length > 0) {
const folders = await getFolders({
workspaceId: workspace.id,
userId: user.id,
diff --git a/apps/web/lib/zod/schemas/webhooks.ts b/apps/web/lib/zod/schemas/webhooks.ts
index f7282ac562..fc2ca3f1ec 100644
--- a/apps/web/lib/zod/schemas/webhooks.ts
+++ b/apps/web/lib/zod/schemas/webhooks.ts
@@ -1,6 +1,6 @@
import { MAX_WEBHOOK_FOLDERS, WEBHOOK_TRIGGERS } from "@/lib/webhook/constants";
import { WebhookTrigger } from "@/lib/webhook/types";
-import { LinkTarget } from "@prisma/client";
+import { LinkScope } from "@prisma/client";
import * as z from "zod/v4";
import { parseUrlSchema } from "./utils";
@@ -10,7 +10,7 @@ export const WebhookSchema = z.object({
url: z.string(),
secret: z.string(),
triggers: z.array(z.enum(WEBHOOK_TRIGGERS)),
- linkTarget: z.enum(LinkTarget).nullable(),
+ linkScope: z.enum(LinkScope).nullable(),
disabledAt: z.date().nullable(),
installationId: z.string().nullable(),
});
@@ -18,7 +18,7 @@ export const WebhookSchema = z.object({
const validateWebhook = (
data: {
triggers: WebhookTrigger[];
- linkTarget?: LinkTarget | null;
+ linkScope?: LinkScope | null;
linkIds?: string[] | null;
folderIds?: string[] | null;
},
@@ -30,26 +30,26 @@ const validateWebhook = (
}
if (!data.triggers.includes("link.clicked")) {
- if (data.linkTarget) {
+ if (data.linkScope) {
ctx.addIssue({
code: "custom",
- path: ["linkTarget"],
- message: `"linkTarget" can only be set when the "link.clicked" trigger is enabled.`,
+ path: ["linkScope"],
+ message: `"linkScope" can only be set when the "link.clicked" trigger is enabled.`,
});
}
return;
}
- if (!data.linkTarget) {
+ if (!data.linkScope) {
ctx.addIssue({
code: "custom",
- path: ["linkTarget"],
- message: `"linkTarget" is required when the "link.clicked" trigger is enabled.`,
+ path: ["linkScope"],
+ message: `"linkScope" is required when the "link.clicked" trigger is enabled.`,
});
return;
}
- if (data.linkTarget === "links" && data.linkIds?.length === 0) {
+ if (data.linkScope === "links" && data.linkIds?.length === 0) {
ctx.addIssue({
code: "custom",
path: ["linkIds"],
@@ -57,7 +57,7 @@ const validateWebhook = (
});
}
- if (data.linkTarget === "folders" && data.folderIds?.length === 0) {
+ if (data.linkScope === "folders" && data.folderIds?.length === 0) {
ctx.addIssue({
code: "custom",
path: ["folderIds"],
@@ -70,7 +70,7 @@ export const createWebhookSchemaBase = z.object({
name: z.string().min(1).max(40),
url: parseUrlSchema,
triggers: z.array(z.enum(WEBHOOK_TRIGGERS)),
- linkTarget: z.enum(LinkTarget).nullish(),
+ linkScope: z.enum(LinkScope).nullish(),
linkIds: z
.array(z.string())
.max(1000, {
diff --git a/apps/web/prisma/schema/webhook.prisma b/apps/web/prisma/schema/webhook.prisma
index 7550cdf9a1..18a9ce650b 100644
--- a/apps/web/prisma/schema/webhook.prisma
+++ b/apps/web/prisma/schema/webhook.prisma
@@ -6,7 +6,7 @@ enum WebhookReceiver {
segment
}
-enum LinkTarget {
+enum LinkScope {
workspace // All links in the workspace
folders // Links inside specific folders
links // Specific links
@@ -21,7 +21,7 @@ model Webhook {
url String @db.LongText
secret String
triggers Json
- linkTarget LinkTarget? // Only set for webhooks with the link.clicked trigger
+ linkScope LinkScope? // Only set for webhooks with the link.clicked trigger
consecutiveFailures Int @default(0)
lastFailedAt DateTime?
disabledAt DateTime?
diff --git a/apps/web/scripts/migrations/backfill-webhook-link-scope.ts b/apps/web/scripts/migrations/backfill-webhook-link-scope.ts
index 12f87a6e98..9a58409bfa 100644
--- a/apps/web/scripts/migrations/backfill-webhook-link-scope.ts
+++ b/apps/web/scripts/migrations/backfill-webhook-link-scope.ts
@@ -2,18 +2,18 @@ import { prisma } from "@/lib/prisma";
import "dotenv-flow/config";
// Existing link.clicked webhooks are always targeted to specific links,
-// so backfill their linkTarget to "links".
+// so backfill their linkScope to "links".
async function main() {
const { count } = await prisma.webhook.updateMany({
where: {
- linkTarget: null,
+ linkScope: null,
triggers: {
array_contains: ["link.clicked"],
},
},
data: {
- linkTarget: "links",
+ linkScope: "links",
},
});
diff --git a/apps/web/ui/webhooks/add-edit-webhook-form.tsx b/apps/web/ui/webhooks/add-edit-webhook-form.tsx
index f226a56359..58c42396ba 100644
--- a/apps/web/ui/webhooks/add-edit-webhook-form.tsx
+++ b/apps/web/ui/webhooks/add-edit-webhook-form.tsx
@@ -39,7 +39,7 @@ export default function AddEditWebhookForm({
name: webhook?.name ?? "",
url: webhook?.url ?? "",
triggers: webhook?.triggers ?? [],
- linkTarget: webhook?.linkTarget ?? "workspace",
+ linkScope: webhook?.linkScope ?? "workspace",
linkIds: [],
folderIds: [],
},
@@ -54,11 +54,11 @@ export default function AddEditWebhookForm({
formState: { isSubmitting },
} = methods;
- const [name, url, triggers, linkTarget, linkIds, folderIds] = watch([
+ const [name, url, triggers, linkScope, linkIds, folderIds] = watch([
"name",
"url",
"triggers",
- "linkTarget",
+ "linkScope",
"linkIds",
"folderIds",
]);
@@ -97,9 +97,9 @@ export default function AddEditWebhookForm({
url: data.url,
triggers: data.triggers,
...(hasLinkClicked && {
- linkTarget: data.linkTarget,
- ...(data.linkTarget === "links" && { linkIds: data.linkIds }),
- ...(data.linkTarget === "folders" && { folderIds: data.folderIds }),
+ linkScope: data.linkScope,
+ ...(data.linkScope === "links" && { linkIds: data.linkIds }),
+ ...(data.linkScope === "folders" && { folderIds: data.folderIds }),
}),
}),
});
@@ -120,12 +120,12 @@ export default function AddEditWebhookForm({
await Promise.all([
mutate(
`/api/webhooks/${result.id}/links?workspaceId=${workspaceId}`,
- result.linkTarget === "links" ? data.linkIds ?? [] : [],
+ result.linkScope === "links" ? data.linkIds ?? [] : [],
{ revalidate: true },
),
mutate(
`/api/webhooks/${result.id}/folders?workspaceId=${workspaceId}`,
- result.linkTarget === "folders" ? data.folderIds ?? [] : [],
+ result.linkScope === "folders" ? data.folderIds ?? [] : [],
{ revalidate: true },
),
]);
@@ -134,9 +134,9 @@ export default function AddEditWebhookForm({
name: result.name,
url: result.url,
triggers: result.triggers,
- linkTarget: result.linkTarget ?? "workspace",
- linkIds: result.linkTarget === "links" ? data.linkIds ?? [] : [],
- folderIds: result.linkTarget === "folders" ? data.folderIds ?? [] : [],
+ linkScope: result.linkScope ?? "workspace",
+ linkIds: result.linkScope === "links" ? data.linkIds ?? [] : [],
+ folderIds: result.linkScope === "folders" ? data.folderIds ?? [] : [],
});
}
@@ -145,7 +145,7 @@ export default function AddEditWebhookForm({
const linkTargetInvalid = isWebhookTriggerSelectionInvalid({
triggers,
- linkTarget: linkTarget ?? "workspace",
+ linkScope: linkScope ?? "workspace",
linkIds: linkIds ?? [],
folderIds: folderIds ?? [],
});
@@ -255,20 +255,20 @@ export default function AddEditWebhookForm({
<WebhookTriggerSelector
value={{
triggers,
- linkTarget: linkTarget ?? "workspace",
+ linkScope: linkScope ?? "workspace",
linkIds: linkIds ?? [],
folderIds: folderIds ?? [],
}}
onChange={(next) => {
setValue("triggers", next.triggers);
- setValue("linkTarget", next.linkTarget);
+ setValue("linkScope", next.linkScope);
setValue("linkIds", next.linkIds);
setValue("folderIds", next.folderIds);
}}
availableTriggers={allWebhookTriggers}
disabled={updateDisabled}
webhookId={webhook?.id}
- savedLinkTarget={webhook?.linkTarget}
+ savedLinkTarget={webhook?.linkScope}
/>
</div>
</div>
diff --git a/apps/web/ui/webhooks/webhook-trigger-selector.tsx b/apps/web/ui/webhooks/webhook-trigger-selector.tsx
index 5a0a6729c7..30c6355f65 100644
--- a/apps/web/ui/webhooks/webhook-trigger-selector.tsx
+++ b/apps/web/ui/webhooks/webhook-trigger-selector.tsx
@@ -8,7 +8,7 @@ import {
import type { WebhookTrigger } from "@/lib/webhook/types";
import { Checkbox, RadioGroup, RadioGroupItem } from "@dub/ui";
import { arrayEqual, cn, fetcher } from "@dub/utils";
-import { LinkTarget } from "@prisma/client";
+import { LinkScope } from "@prisma/client";
import { useEffect } from "react";
import useSWR from "swr";
import { FoldersSelector } from "./folder-selector";
@@ -31,14 +31,14 @@ const CLICK_WEBHOOK_LINK_TARGET_OPTIONS = [
description: "Trigger webhooks for the links you explicitly select",
},
] as const satisfies ReadonlyArray<{
- value: LinkTarget;
+ value: LinkScope;
label: string;
description: string;
}>;
export type WebhookTriggerSelectorValue = {
triggers: WebhookTrigger[];
- linkTarget: LinkTarget;
+ linkScope: LinkScope;
linkIds: string[];
folderIds: string[];
};
@@ -53,8 +53,8 @@ export function isWebhookTriggerSelectionInvalid(
}
return (
- (value.linkTarget === "links" && value.linkIds.length === 0) ||
- (value.linkTarget === "folders" && value.folderIds.length === 0)
+ (value.linkScope === "links" && value.linkIds.length === 0) ||
+ (value.linkScope === "folders" && value.folderIds.length === 0)
);
}
@@ -71,11 +71,11 @@ export function WebhookTriggerSelector({
availableTriggers: WebhookTrigger[];
disabled?: boolean;
webhookId?: string;
- savedLinkTarget?: LinkTarget | null;
+ savedLinkTarget?: LinkScope | null;
}) {
const { id: workspaceId } = useWorkspace();
- const { triggers, linkTarget, linkIds, folderIds } = value;
+ const { triggers, linkScope, linkIds, folderIds } = value;
const hasLinkClicked = triggers.includes(LINK_CLICK_WEBHOOK_TRIGGER);
const { data: fetchedLinkIds } = useSWR<string[]>(
@@ -93,48 +93,48 @@ export function WebhookTriggerSelector({
);
useEffect(() => {
- if (linkTarget === "links" && fetchedLinkIds) {
+ if (linkScope === "links" && fetchedLinkIds) {
if (!arrayEqual(linkIds, fetchedLinkIds)) {
onChange({
triggers,
- linkTarget,
+ linkScope,
linkIds: fetchedLinkIds,
folderIds,
});
}
- } else if (linkTarget !== "links" && linkIds.length > 0) {
+ } else if (linkScope !== "links" && linkIds.length > 0) {
onChange({
triggers,
- linkTarget,
+ linkScope,
linkIds: [],
folderIds,
});
}
- // Only sync from server when linkTarget or fetched ids change — not on manual selection
+ // Only sync from server when linkScope or fetched ids change — not on manual selection
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [linkTarget, fetchedLinkIds]);
+ }, [linkScope, fetchedLinkIds]);
useEffect(() => {
- if (linkTarget === "folders" && fetchedFolderIds) {
+ if (linkScope === "folders" && fetchedFolderIds) {
if (!arrayEqual(folderIds, fetchedFolderIds)) {
onChange({
triggers,
- linkTarget,
+ linkScope,
linkIds,
folderIds: fetchedFolderIds,
});
}
- } else if (linkTarget !== "folders" && folderIds.length > 0) {
+ } else if (linkScope !== "folders" && folderIds.length > 0) {
onChange({
triggers,
- linkTarget,
+ linkScope,
linkIds,
folderIds: [],
});
}
- // Only sync from server when linkTarget or fetched ids change — not on manual selection
+ // Only sync from server when linkScope or fetched ids change — not on manual selection
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [linkTarget, fetchedFolderIds]);
+ }, [linkScope, fetchedFolderIds]);
const toggleTrigger = (
trigger: WebhookTrigger,
@@ -152,10 +152,10 @@ export function WebhookTriggerSelector({
});
};
- const handleLinkTargetChange = (nextLinkTarget: LinkTarget) => {
+ const handleLinkTargetChange = (nextLinkTarget: LinkScope) => {
onChange({
...value,
- linkTarget: nextLinkTarget,
+ linkScope: nextLinkTarget,
linkIds: nextLinkTarget === "links" ? linkIds : [],
folderIds: nextLinkTarget === "folders" ? folderIds : [],
});
@@ -184,15 +184,15 @@ export function WebhookTriggerSelector({
{trigger === LINK_CLICK_WEBHOOK_TRIGGER && hasLinkClicked ? (
<div className="ml-6 mt-3 rounded-md border border-neutral-200 bg-neutral-50 p-4">
<RadioGroup
- value={linkTarget}
+ value={linkScope}
onValueChange={(nextValue) =>
- handleLinkTargetChange(nextValue as LinkTarget)
+ handleLinkTargetChange(nextValue as LinkScope)
}
className="flex flex-col gap-2"
disabled={disabled}
>
{CLICK_WEBHOOK_LINK_TARGET_OPTIONS.map((option) => {
- const isSelected = linkTarget === option.value;
+ const isSelected = linkScope === option.value;
return (
<div key={option.value}>
@@ -207,7 +207,7 @@ export function WebhookTriggerSelector({
>
<RadioGroupItem
value={option.value}
- id={`linkTarget-${option.value}`}
+ id={`linkScope-${option.value}`}
className="mt-0.5"
disabled={disabled}
/>