The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
rename WORKFLOW_ATTRIBUTE_LABELS → PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[attribute]
Steven Tey6d157328df8b
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/route.tsindex 16b471d239..f4d999fde5 100644--- a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts@@ -1,6 +1,7 @@import { recordAuditLog } from "@/lib/api/audit-logs/record-audit-log";import { generatePerformanceBountyName } from "@/lib/api/bounties/generate-performance-bounty-name";import { getBountyWithDetails } from "@/lib/api/bounties/get-bounty-with-details";+import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "@/lib/api/bounties/performance-bounty-scope-attributes";import { validateBounty } from "@/lib/api/bounties/validate-bounty";import { DubApiError } from "@/lib/api/errors";import { throwIfInvalidGroupIds } from "@/lib/api/groups/throw-if-invalid-group-ids";@@ -15,7 +16,6 @@ import {BountySchemaExtended,updateBountySchema,} from "@/lib/zod/schemas/bounties";-import { WORKFLOW_ATTRIBUTE_LABELS } from "@/lib/zod/schemas/workflows";import { prisma } from "@dub/prisma";import { APP_DOMAIN_WITH_NGROK, arrayEqual } from "@dub/utils";import { PartnerGroup, Prisma } from "@prisma/client";@@ -124,7 +124,7 @@ export const PATCH = withWorkspace() {throw new DubApiError({code: "bad_request",- message: `You cannot change the performance condition from "${WORKFLOW_ATTRIBUTE_LABELS[currentCondition.attribute].toLowerCase()}" to "${WORKFLOW_ATTRIBUTE_LABELS[performanceCondition.attribute].toLowerCase()}" because the bounty has submissions.`,+ message: `You cannot change the performance condition from "${PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[currentCondition.attribute].toLowerCase()}" to "${PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[performanceCondition.attribute].toLowerCase()}" because the bounty has submissions.`,});}}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsxindex 1b7dc88cc0..ba1904fd98 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx@@ -1,11 +1,11 @@"use client";+import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "@/lib/api/bounties/performance-bounty-scope-attributes";import { isCurrencyAttribute } from "@/lib/api/workflows/utils";import useBounty from "@/lib/swr/use-bounty";import useGroups from "@/lib/swr/use-groups";import useWorkspace from "@/lib/swr/use-workspace";import { BountySubmissionProps } from "@/lib/types";-import { WORKFLOW_ATTRIBUTE_LABELS } from "@/lib/zod/schemas/workflows";import { GroupColorCircle } from "@/ui/partners/groups/group-color-circle";import { PartnerRowItem } from "@/ui/partners/partner-row-item";import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";@@ -77,7 +77,7 @@ export function BountySubmissionsTable() {: "leads";const metricColumnLabel = performanceCondition?.attribute- ? WORKFLOW_ATTRIBUTE_LABELS[performanceCondition.attribute]+ ? PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[performanceCondition.attribute]: "Progress";const sortBy =diff --git a/apps/web/lib/api/bounties/generate-performance-bounty-name.ts b/apps/web/lib/api/bounties/generate-performance-bounty-name.tsindex 254ad45f2d..f334ce8190 100644--- a/apps/web/lib/api/bounties/generate-performance-bounty-name.ts+++ b/apps/web/lib/api/bounties/generate-performance-bounty-name.ts@@ -1,7 +1,7 @@import { WorkflowCondition } from "@/lib/types";-import { WORKFLOW_ATTRIBUTE_LABELS } from "@/lib/zod/schemas/workflows";import { currencyFormatter, nFormatter } from "@dub/utils";import { isCurrencyAttribute } from "../workflows/utils";+import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "./performance-bounty-scope-attributes";export const generatePerformanceBountyName = ({rewardAmount,@@ -11,7 +11,8 @@ export const generatePerformanceBountyName = ({condition: WorkflowCondition;}) => {const isCurrency = isCurrencyAttribute(condition.attribute);- const attributeLabel = WORKFLOW_ATTRIBUTE_LABELS[condition.attribute];+ const attributeLabel =+ PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[condition.attribute];const valueFormatted = isCurrency? `${currencyFormatter(condition.value / 100, { trailingZeroDisplay: "stripIfInteger" })} in`: `${nFormatter(condition.value, { full: true })}`;diff --git a/apps/web/lib/api/bounties/performance-bounty-scope-attributes.ts b/apps/web/lib/api/bounties/performance-bounty-scope-attributes.tsnew file mode 100644index 0000000000..62c146127b--- /dev/null+++ b/apps/web/lib/api/bounties/performance-bounty-scope-attributes.ts@@ -0,0 +1,9 @@+export const PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES: Record<+ "totalLeads" | "totalConversions" | "totalSaleAmount" | "totalCommissions",+ string+> = {+ totalLeads: "Leads",+ totalConversions: "Conversions",+ totalSaleAmount: "Revenue",+ totalCommissions: "Commissions",+} as const;diff --git a/apps/web/lib/api/workflows/execute-send-campaign-workflow.ts b/apps/web/lib/api/workflows/execute-send-campaign-workflow.tsindex 54fb5e42bb..4272a7cf5c 100644--- a/apps/web/lib/api/workflows/execute-send-campaign-workflow.ts+++ b/apps/web/lib/api/workflows/execute-send-campaign-workflow.ts@@ -222,6 +222,8 @@ async function getProgramEnrollments({groupIds: string[];condition: WorkflowCondition;}) {+ const { attribute } = condition;+if (partnerId) {const programEnrollment = await prisma.programEnrollment.findUnique({where: {diff --git a/apps/web/lib/zod/schemas/campaigns.ts b/apps/web/lib/zod/schemas/campaigns.tsindex 16abb08d1f..62d21d35d6 100644--- a/apps/web/lib/zod/schemas/campaigns.ts+++ b/apps/web/lib/zod/schemas/campaigns.ts@@ -2,11 +2,7 @@ import {CampaignWorkflowAttributeConfig,WorkflowAttribute,} from "@/lib/types";-import {- CampaignStatus,- CampaignType,- WorkflowTrigger,-} from "@dub/prisma/client";+import { CampaignStatus, CampaignType } from "@dub/prisma/client";import { z } from "zod";import { GroupSchema } from "./groups";import { getPaginationQuerySchema } from "./misc";@@ -22,28 +18,20 @@ export const CAMPAIGN_WORKFLOW_ATTRIBUTE_CONFIG: Record<WorkflowAttribute,CampaignWorkflowAttributeConfig> = {- totalClicks: {- label: "clicks",- inputType: "number",- },totalLeads: {- label: "leads",+ label: "total leads",inputType: "number",},totalConversions: {- label: "conversions",- inputType: "number",- },- totalSales: {- label: "sales",+ label: "total conversions",inputType: "number",},totalSaleAmount: {- label: "revenue",+ label: "total revenue",inputType: "currency",},totalCommissions: {- label: "commissions",+ label: "total commissions",inputType: "currency",},partnerEnrolledDays: {diff --git a/apps/web/lib/zod/schemas/workflows.ts b/apps/web/lib/zod/schemas/workflows.tsindex 9be06203e4..70c8297118 100644--- a/apps/web/lib/zod/schemas/workflows.ts+++ b/apps/web/lib/zod/schemas/workflows.ts@@ -7,38 +7,22 @@ import { WorkflowTrigger } from "@dub/prisma/client";import { z } from "zod";export const WORKFLOW_ATTRIBUTES = [- "totalClicks",+ // "totalClicks","totalLeads","totalConversions",- "totalSales","totalSaleAmount","totalCommissions","partnerEnrolledDays","partnerJoined",] as const;-export const WORKFLOW_ATTRIBUTE_LABELS: Record<- WorkflowConditionAttribute,- string-> = {- totalClicks: "Clicks",- totalLeads: "Leads",- totalConversions: "Conversions",- totalSales: "Sales",- totalSaleAmount: "Revenue",- totalCommissions: "Commissions",- partnerEnrolledDays: "days since enrollment",- partnerJoined: "joins the program",-} as const;-export const WORKFLOW_ATTRIBUTE_TRIGGER: Record<WorkflowConditionAttribute,WorkflowTrigger> = {- totalClicks: WorkflowTrigger.clickRecorded,+ // totalClicks: WorkflowTrigger.clickRecorded,totalLeads: WorkflowTrigger.leadRecorded,totalConversions: WorkflowTrigger.saleRecorded,- totalSales: WorkflowTrigger.saleRecorded,totalSaleAmount: WorkflowTrigger.saleRecorded,totalCommissions: WorkflowTrigger.commissionEarned,partnerEnrolledDays: WorkflowTrigger.partnerEnrolled,@@ -48,14 +32,12 @@ export const WORKFLOW_ATTRIBUTE_TRIGGER: Record<export const WORKFLOW_COMPARISON_OPERATORS = ["gte"] as const;export const SCHEDULED_WORKFLOW_TRIGGERS: WorkflowTrigger[] = [- "clickRecorded",- "commissionEarned",+ // "clickRecorded","partnerEnrolled",];export const WORKFLOW_SCHEDULES: Partial<Record<WorkflowTrigger, string>> = {- clickRecorded: "*/5 * * * *", // every 5 minutes- commissionEarned: "*/5 * * * *", // every 5 minutes+ // clickRecorded: "*/5 * * * *", // every 5 minutespartnerEnrolled: "0 */12 * * *", // every 12 hours};diff --git a/apps/web/ui/partners/bounties/bounty-logic.tsx b/apps/web/ui/partners/bounties/bounty-logic.tsxindex f4b6d4ea58..ff8b269cfd 100644--- a/apps/web/ui/partners/bounties/bounty-logic.tsx+++ b/apps/web/ui/partners/bounties/bounty-logic.tsx@@ -1,9 +1,7 @@+import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "@/lib/api/bounties/performance-bounty-scope-attributes";import { isCurrencyAttribute } from "@/lib/api/workflows/utils";import { handleMoneyInputChange, handleMoneyKeyDown } from "@/lib/form-utils";-import {- WORKFLOW_ATTRIBUTE_LABELS,- WORKFLOW_ATTRIBUTES,-} from "@/lib/zod/schemas/workflows";+import { WORKFLOW_ATTRIBUTES } from "@/lib/zod/schemas/workflows";import {InlineBadgePopover,InlineBadgePopoverContext,@@ -59,7 +57,9 @@ export function BountyLogic({ className }: { className?: string }) {<InlineBadgePopovertext={field.value- ? WORKFLOW_ATTRIBUTE_LABELS[field.value].toLowerCase()+ ? PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[+ field.value+ ].toLowerCase(): "activity"}invalid={!field.value}@@ -68,15 +68,11 @@ export function BountyLogic({ className }: { className?: string }) {selectedValue={field.value}onSelect={field.onChange}items={WORKFLOW_ATTRIBUTES.filter(- (attr) =>- ![- "totalClicks",- "totalSales",- "partnerEnrolledDays",- "partnerJoined",- ].includes(attr),+ (attr) => PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[attr],).map((attribute) => ({- text: WORKFLOW_ATTRIBUTE_LABELS[attribute].toLowerCase(),+ text: PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[+ attribute+ ].toLowerCase(),value: attribute,}))}/>diff --git a/apps/web/ui/partners/bounties/bounty-performance.tsx b/apps/web/ui/partners/bounties/bounty-performance.tsxindex 1749b96445..8be562d644 100644--- a/apps/web/ui/partners/bounties/bounty-performance.tsx+++ b/apps/web/ui/partners/bounties/bounty-performance.tsx@@ -1,6 +1,6 @@+import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "@/lib/api/bounties/performance-bounty-scope-attributes";import { isCurrencyAttribute } from "@/lib/api/workflows/utils";import { PartnerBountyProps } from "@/lib/types";-import { WORKFLOW_ATTRIBUTE_LABELS } from "@/lib/zod/schemas/workflows";import { currencyFormatter, nFormatter } from "@dub/utils";export function BountyPerformance({ bounty }: { bounty: PartnerBountyProps }) {@@ -26,7 +26,9 @@ export function BountyPerformance({ bounty }: { bounty: PartnerBountyProps }) {: nFormatter(target, { full: true });const metricLabel =- WORKFLOW_ATTRIBUTE_LABELS[performanceCondition.attribute].toLowerCase();+ PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[+ performanceCondition.attribute+ ].toLowerCase();return (<div className="flex flex-col gap-2">diff --git a/packages/prisma/schema/workflow.prisma b/packages/prisma/schema/workflow.prismaindex fd3a05baf1..4f2b39ef9c 100644--- a/packages/prisma/schema/workflow.prisma+++ b/packages/prisma/schema/workflow.prisma@@ -1,7 +1,7 @@enum WorkflowTrigger {partnerEnrolled // scheduledclickRecorded // scheduled- commissionEarned // scheduled+ commissionEarnedleadRecordedsaleRecorded}