The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update max batches, bounty edit button
Steven Tey5bee35d3fa6a
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsxindex fafd66e152..b334839fcf 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx@@ -66,15 +66,17 @@ export function BountyInfo() {<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-6"><div className="relative flex h-[100px] w-full items-center justify-center rounded-lg bg-neutral-100 p-4 sm:h-[128px] sm:w-[100px] sm:shrink-0"><BountyThumbnailImage bounty={bounty} />- <div className="absolute right-2 top-2 sm:hidden">- <BountyActionButton bounty={bounty} />- </div></div><div className="flex min-w-0 flex-1 flex-col gap-1.5">- <h3 className="break-words text-base font-semibold leading-6 text-neutral-900 sm:truncate">- {bounty.name}- </h3>+ <div className="flex items-start justify-between gap-3">+ <h3 className="break-words text-base font-semibold leading-6 text-neutral-900 sm:truncate">+ {bounty.name}+ </h3>+ <div className="shrink-0 sm:hidden">+ <BountyActionButton bounty={bounty} />+ </div>+ </div><div className="text-content-subtle font-regular flex items-center gap-2 text-sm"><Calendar6 className="size-4 shrink-0" />@@ -186,7 +188,13 @@ function BountyInfoSkeleton() {<div className="flex flex-col items-center gap-3 sm:flex-row sm:items-start sm:gap-6"><div className="relative flex h-[100px] w-[100px] shrink-0 items-center justify-center rounded-lg bg-neutral-100 p-3 sm:h-[128px]" /><div className="flex min-w-0 flex-1 flex-col gap-1.5">- <div className="h-6 w-48 animate-pulse rounded-md bg-neutral-200" />+ <div className="flex items-start justify-between gap-3">+ <div className="h-6 w-48 animate-pulse rounded-md bg-neutral-200" />+ <div className="flex shrink-0 items-start gap-2 sm:hidden">+ <div className="h-9 w-16 animate-pulse rounded-md bg-neutral-200" />+ <div className="h-9 w-9 animate-pulse rounded-md bg-neutral-200" />+ </div>+ </div><div className="flex items-center space-x-2"><div className="size-4 animate-pulse rounded bg-neutral-200" /><div className="h-5 w-32 animate-pulse rounded bg-neutral-200" />@@ -200,8 +208,9 @@ function BountyInfoSkeleton() {<div className="h-5 w-40 animate-pulse rounded bg-neutral-200" /></div></div>- <div className="flex items-start">- <div className="h-9 w-24 animate-pulse rounded-md bg-neutral-200" />+ <div className="hidden items-start gap-2 sm:flex">+ <div className="h-9 w-16 animate-pulse rounded-md bg-neutral-200" />+ <div className="h-9 w-9 animate-pulse rounded-md bg-neutral-200" /></div></div>);diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-action-button.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-action-button.tsxindex 43f9b23964..a08cbe8c8e 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-action-button.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-action-button.tsx@@ -73,52 +73,51 @@ export function BountyActionButton({{BountySheet}{deleteModal}<div className={className}>- <Popover- openPopover={isOpen}- setOpenPopover={setIsOpen}- content={- <Command tabIndex={0} loop className="focus:outline-none">- <Command.List className="flex w-screen flex-col gap-1 p-1.5 text-sm focus-visible:outline-none sm:w-auto sm:min-w-[200px]">- <MenuItem- as={Command.Item}- icon={PenWriting}- variant="default"- onSelect={() => {- setShowCreateBountySheet(true);- setIsOpen(false);- }}- >- Edit bounty- </MenuItem>-- <MenuItem- as={Command.Item}- icon={Trash}- variant="danger"- onSelect={() => {- setIsOpen(false);- setShowDeleteModal(true);- }}- disabledTooltip={- totalSubmissions > 0- ? "Bounties with submissions cannot be deleted."- : undefined- }- >- Delete bounty- </MenuItem>- </Command.List>- </Command>- }- align="end"- >+ <div className="flex items-center gap-2"><Buttontype="button"- className={buttonClassName || "w-auto px-1.5"}+ text="Edit"variant="secondary"- icon={<ThreeDots className="h-4 w-4 shrink-0" />}+ className="h-9 w-fit rounded-lg"+ icon={<PenWriting className="size-4 shrink-0" />}+ onClick={() => setShowCreateBountySheet(true)}/>- </Popover>++ <Popover+ openPopover={isOpen}+ setOpenPopover={setIsOpen}+ content={+ <Command tabIndex={0} loop className="focus:outline-none">+ <Command.List className="flex w-screen flex-col gap-1 p-1.5 text-sm focus-visible:outline-none sm:w-auto sm:min-w-[200px]">+ <MenuItem+ as={Command.Item}+ icon={Trash}+ variant="danger"+ onSelect={() => {+ setIsOpen(false);+ setShowDeleteModal(true);+ }}+ disabledTooltip={+ totalSubmissions > 0+ ? "Bounties with submissions cannot be deleted."+ : undefined+ }+ >+ Delete bounty+ </MenuItem>+ </Command.List>+ </Command>+ }+ align="end"+ >+ <Button+ type="button"+ className={buttonClassName || "h-9 w-9 shrink-0 rounded-lg p-0"}+ variant="secondary"+ icon={<ThreeDots className="h-4 w-4 shrink-0" />}+ />+ </Popover>+ </div></div></>);diff --git a/apps/web/lib/rewardful/import-affiliate-coupons.ts b/apps/web/lib/rewardful/import-affiliate-coupons.tsindex 73a6910e1a..6ef625d787 100644--- a/apps/web/lib/rewardful/import-affiliate-coupons.ts+++ b/apps/web/lib/rewardful/import-affiliate-coupons.ts@@ -4,7 +4,7 @@ import { bulkCreateLinks } from "../api/links";import { ProcessedLinkProps } from "../types";import { redis } from "../upstash";import { RewardfulApi } from "./api";-import { MAX_BATCHES, rewardfulImporter } from "./importer";+import { REWARDFUL_MAX_BATCHES, rewardfulImporter } from "./importer";import { RewardfulImportPayload } from "./types";export async function importAffiliateCoupons(payload: RewardfulImportPayload) {@@ -31,7 +31,7 @@ export async function importAffiliateCoupons(payload: RewardfulImportPayload) {let hasMore = true;let processedBatches = 0;- while (hasMore && processedBatches < MAX_BATCHES) {+ while (hasMore && processedBatches < REWARDFUL_MAX_BATCHES) {const affiliateCoupons = await rewardfulApi.listAffiliateCoupons({page: currentPage,});diff --git a/apps/web/lib/rewardful/import-commissions.ts b/apps/web/lib/rewardful/import-commissions.tsindex 8b20534e31..a32b06ec13 100644--- a/apps/web/lib/rewardful/import-commissions.ts+++ b/apps/web/lib/rewardful/import-commissions.ts@@ -16,7 +16,7 @@ import { LeadEventTB } from "../types";import { redis } from "../upstash";import { clickEventSchemaTB } from "../zod/schemas/clicks";import { RewardfulApi } from "./api";-import { MAX_BATCHES, rewardfulImporter } from "./importer";+import { REWARDFUL_MAX_BATCHES, rewardfulImporter } from "./importer";import { RewardfulCommission, RewardfulImportPayload } from "./types";const toDubStatus: Record<RewardfulCommission["state"], CommissionStatus> = {@@ -45,7 +45,7 @@ export async function importCommissions(payload: RewardfulImportPayload) {let hasMore = true;let processedBatches = 0;- while (hasMore && processedBatches < MAX_BATCHES) {+ while (hasMore && processedBatches < REWARDFUL_MAX_BATCHES) {const commissions = await rewardfulApi.listCommissions({page: currentPage,});diff --git a/apps/web/lib/rewardful/import-customers.ts b/apps/web/lib/rewardful/import-customers.tsindex e11fb66081..00f37e6ed0 100644--- a/apps/web/lib/rewardful/import-customers.ts+++ b/apps/web/lib/rewardful/import-customers.ts@@ -9,7 +9,7 @@ import { recordClick } from "../tinybird/record-click";import { recordLeadWithTimestamp } from "../tinybird/record-lead";import { clickEventSchemaTB } from "../zod/schemas/clicks";import { RewardfulApi } from "./api";-import { MAX_BATCHES, rewardfulImporter } from "./importer";+import { REWARDFUL_REFERRALS_MAX_BATCHES, rewardfulImporter } from "./importer";import { RewardfulImportPayload, RewardfulReferral } from "./types";export async function importCustomers(payload: RewardfulImportPayload) {@@ -32,7 +32,7 @@ export async function importCustomers(payload: RewardfulImportPayload) {let hasMore = true;let processedBatches = 0;- while (hasMore && processedBatches < MAX_BATCHES) {+ while (hasMore && processedBatches < REWARDFUL_REFERRALS_MAX_BATCHES) {const referrals = await rewardfulApi.listCustomers({page: currentPage,});diff --git a/apps/web/lib/rewardful/import-partners.ts b/apps/web/lib/rewardful/import-partners.tsindex 4e7b558e41..6a62c9bc3e 100644--- a/apps/web/lib/rewardful/import-partners.ts+++ b/apps/web/lib/rewardful/import-partners.ts@@ -6,7 +6,7 @@ import { bulkCreateLinks } from "../api/links";import { logImportError } from "../tinybird/log-import-error";import { redis } from "../upstash";import { RewardfulApi } from "./api";-import { MAX_BATCHES, rewardfulImporter } from "./importer";+import { REWARDFUL_MAX_BATCHES, rewardfulImporter } from "./importer";import { RewardfulAffiliate, RewardfulImportPayload } from "./types";export async function importPartners(payload: RewardfulImportPayload) {@@ -47,7 +47,7 @@ export async function importPartners(payload: RewardfulImportPayload) {entity: "partner",} as const;- while (hasMore && processedBatches < MAX_BATCHES) {+ while (hasMore && processedBatches < REWARDFUL_MAX_BATCHES) {const affiliates = await rewardfulApi.listPartners({page: currentPage,});diff --git a/apps/web/lib/rewardful/importer.ts b/apps/web/lib/rewardful/importer.tsindex 16a1f33dee..c80b87886b 100644--- a/apps/web/lib/rewardful/importer.ts+++ b/apps/web/lib/rewardful/importer.ts@@ -5,7 +5,9 @@ import { RewardfulCredentials, RewardfulImportPayload } from "./types";// Rewardful rate limit is 45 requests per 30 seconds// so we should be able to safely request up to 10 batches at a time-export const MAX_BATCHES = 10;+export const REWARDFUL_MAX_BATCHES = 10;+// smaller batch size for referrals to make sure each batch succeeds+export const REWARDFUL_REFERRALS_MAX_BATCHES = 1;// cache rewardful credentials for 24 hoursexport const CACHE_EXPIRY = 60 * 60 * 24;