The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
State why each sync call site queues
Rafif052531de4d7
diff --git a/apps/web/app/(ee)/api/admin/partners/[partnerId]/platforms/route.ts b/apps/web/app/(ee)/api/admin/partners/[partnerId]/platforms/route.tsindex 3162d43167..0bb6a10803 100644--- a/apps/web/app/(ee)/api/admin/partners/[partnerId]/platforms/route.ts+++ b/apps/web/app/(ee)/api/admin/partners/[partnerId]/platforms/route.ts@@ -129,8 +129,8 @@ export const POST = withAdmin(},});- // The identifier is searchable, so an admin correcting a handle has to- // reach the index too.+ // Queue an index update because an admin corrected the searchable platform+ // identifier.waitUntil(queuePartnerSearchSync({ partnerIds: [partnerId] }));return NextResponse.json({diff --git a/apps/web/app/(ee)/api/admin/partners/[partnerId]/route.ts b/apps/web/app/(ee)/api/admin/partners/[partnerId]/route.tsindex c41853b0fe..15b690251a 100644--- a/apps/web/app/(ee)/api/admin/partners/[partnerId]/route.ts+++ b/apps/web/app/(ee)/api/admin/partners/[partnerId]/route.ts@@ -160,8 +160,8 @@ export const PATCH = withAdmin(async ({ params, req }) => {},});- // Country is a filterable field on the document, so an admin correcting it- // has to reach the index or the partner stays findable under the old one.+ // Queue an index update because an admin corrected the partner country, a+ // filterable field.waitUntil(queuePartnerSearchSync({ partnerIds: [partner.id] }));// if there was an existing veriff session, trigger a country change verificationdiff --git a/apps/web/app/(ee)/api/admin/partners/delete-account/route.ts b/apps/web/app/(ee)/api/admin/partners/delete-account/route.tsindex 6803966dbb..b3d91aeb85 100644--- a/apps/web/app/(ee)/api/admin/partners/delete-account/route.ts+++ b/apps/web/app/(ee)/api/admin/partners/delete-account/route.ts@@ -135,7 +135,7 @@ export const POST = withAdmin(`Deleted ${partner.programs.length} program enrollments for partner ${partner.email} (${partner.id})`,);- // Queue an index update for the deleted enrollments.+ // Queue an index update because the partner's enrollments were deleted.await queuePartnerSearchSync({enrollmentIds: partner.programs.map(({ id }) => id),});diff --git a/apps/web/app/(ee)/api/cron/cleanup/declined-invites/route.ts b/apps/web/app/(ee)/api/cron/cleanup/declined-invites/route.tsindex c57337c149..477dae5b97 100644--- a/apps/web/app/(ee)/api/cron/cleanup/declined-invites/route.ts+++ b/apps/web/app/(ee)/api/cron/cleanup/declined-invites/route.ts@@ -53,7 +53,7 @@ export async function POST(req: Request) {`Deleted ${deletedRes.count} declined programEnrollments that are older than 90 days`,);- // Queue an index update for the deleted enrollments.+ // Queue an index update because the declined enrollments were deleted.await queuePartnerSearchSync({enrollmentIds: declinedProgramEnrollments.map(({ id }) => id),});diff --git a/apps/web/app/(ee)/api/cron/cleanup/rejected-applications/route.ts b/apps/web/app/(ee)/api/cron/cleanup/rejected-applications/route.tsindex 075a774c56..c6be2fa1f4 100644--- a/apps/web/app/(ee)/api/cron/cleanup/rejected-applications/route.ts+++ b/apps/web/app/(ee)/api/cron/cleanup/rejected-applications/route.ts@@ -60,7 +60,7 @@ export async function POST(req: Request) {`Deleted ${deletedProgramEnrollments.count} rejected programEnrollments that are older than 30 days`,);- // Queue an index update for the deleted enrollments.+ // Queue an index update because the rejected enrollments were deleted.await queuePartnerSearchSync({enrollmentIds: rejectedProgramEnrollments.map(({ id }) => id),});diff --git a/apps/web/app/(ee)/api/cron/domains/update/route.ts b/apps/web/app/(ee)/api/cron/domains/update/route.tsindex aede01e279..789761f1d0 100644--- a/apps/web/app/(ee)/api/cron/domains/update/route.ts+++ b/apps/web/app/(ee)/api/cron/domains/update/route.ts@@ -105,8 +105,9 @@ export async function POST(req: Request) {linkCache.expireMany(linksToUpdate),]);- // Queued after the block above rather than inside it, because- // updateShortLinks runs there and the document indexes `shortLink`.+ // Queue an index update because the domain change rewrote each link's+ // shortLink. Queued after updateShortLinks above, which performs the+ // rewrite.await queuePartnerSearchSyncForLinks(updatedLinks, {delay: PARTNER_SEARCH_LINK_SYNC_DELAY_SECONDS,});diff --git a/apps/web/app/(ee)/api/cron/groups/sync-utm/route.ts b/apps/web/app/(ee)/api/cron/groups/sync-utm/route.tsindex 113925ce0d..873c6db890 100644--- a/apps/web/app/(ee)/api/cron/groups/sync-utm/route.ts+++ b/apps/web/app/(ee)/api/cron/groups/sync-utm/route.ts@@ -130,8 +130,8 @@ export async function POST(req: Request) {const redisRes = await linkCache.expireMany(linksToUpdate);console.log(`Updated Redis cache: ${JSON.stringify(redisRes, null, 2)}`);- // A UTM template rewrites each link's destination URL. The enrollments are- // already in hand, so this skips resolving them back from the links.+ // Queue an index update because the UTM template rewrote each link's+ // destination URL.await queuePartnerSearchSync({enrollmentIds: programEnrollments.map(({ id }) => id),delay: PARTNER_SEARCH_LINK_SYNC_DELAY_SECONDS,diff --git a/apps/web/app/(ee)/api/cron/groups/update-default-links/route.ts b/apps/web/app/(ee)/api/cron/groups/update-default-links/route.tsindex 5dc5c2915e..c521d83a6d 100644--- a/apps/web/app/(ee)/api/cron/groups/update-default-links/route.ts+++ b/apps/web/app/(ee)/api/cron/groups/update-default-links/route.ts@@ -202,8 +202,8 @@ export async function POST(req: Request) {),);- // The destination URL is searchable, so the owners of the links that- // actually changed have to be re-indexed.+ // Queue an index update because the default link change rewrote+ // destination URLs.await queuePartnerSearchSyncForLinks(linksToUpdate.map(({ owner }) => owner),{ delay: PARTNER_SEARCH_LINK_SYNC_DELAY_SECONDS },diff --git a/apps/web/app/(ee)/api/cron/partner-platforms/youtube/route.ts b/apps/web/app/(ee)/api/cron/partner-platforms/youtube/route.tsindex e58c7c5419..a8fa3db6e5 100644--- a/apps/web/app/(ee)/api/cron/partner-platforms/youtube/route.ts+++ b/apps/web/app/(ee)/api/cron/partner-platforms/youtube/route.ts@@ -131,7 +131,8 @@ export const POST = withCron(async ({ rawBody }) => {});if (identifierChanged) {- // The identifier is searchable, the stats above are not.+ // Queue an index update because the platform identifier moved. The+ // stats above are not indexed.await queuePartnerSearchSync({partnerIds: [partnerPlatform.partnerId],});diff --git a/apps/web/app/(ee)/api/cron/partners/auto-reject/route.ts b/apps/web/app/(ee)/api/cron/partners/auto-reject/route.tsindex 1a083074df..a0f69ff3e2 100644--- a/apps/web/app/(ee)/api/cron/partners/auto-reject/route.ts+++ b/apps/web/app/(ee)/api/cron/partners/auto-reject/route.ts@@ -144,7 +144,7 @@ export const POST = withCron(async ({ rawBody }) => {partnerIds: [partnerId],}),- // Status moved to rejected.+ // Queue an index update because the enrollment status moved to rejected.queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] }),partner.email &&diff --git a/apps/web/app/(ee)/api/cron/partners/delete/route.ts b/apps/web/app/(ee)/api/cron/partners/delete/route.tsindex 3574dc8679..744ebddc58 100644--- a/apps/web/app/(ee)/api/cron/partners/delete/route.ts+++ b/apps/web/app/(ee)/api/cron/partners/delete/route.ts@@ -158,7 +158,7 @@ export const POST = withCron(async ({ rawBody }) => {}),]);- // Queue an index update for the deleted enrollment.+ // Queue an index update because the enrollment was deleted.await queuePartnerSearchSync({ enrollmentIds: [enrollment.id] });await recordAuditLog({diff --git a/apps/web/app/(ee)/api/cron/partners/merge-accounts/route.ts b/apps/web/app/(ee)/api/cron/partners/merge-accounts/route.tsindex 5e94b1dda9..0bb6b4523c 100644--- a/apps/web/app/(ee)/api/cron/partners/merge-accounts/route.ts+++ b/apps/web/app/(ee)/api/cron/partners/merge-accounts/route.ts@@ -327,9 +327,9 @@ export async function POST(req: Request) {}}- // Both sides: a merge either reassigns a source enrollment to the target- // partner or deletes it in favour of the target's, and passing all of them- // lets the job work out which happened.+ // Queue an index update because the merge either reassigned each source+ // enrollment to the target partner or deleted it. Passing both sides lets+ // the job work out which.await queuePartnerSearchSync({enrollmentIds: [...sourcePartnerEnrollments.map(({ id }) => id),diff --git a/apps/web/app/(ee)/api/stripe/connect/webhook/account-updated.ts b/apps/web/app/(ee)/api/stripe/connect/webhook/account-updated.tsindex 52a7f0e313..665017d75d 100644--- a/apps/web/app/(ee)/api/stripe/connect/webhook/account-updated.ts+++ b/apps/web/app/(ee)/api/stripe/connect/webhook/account-updated.ts@@ -108,7 +108,8 @@ export async function accountUpdated(event: Stripe.AccountUpdatedEvent) {},});- // Country is a filterable field on the document.+ // Queue an index update because the partner country moved, a filterable+ // field.if (countryChanged) {await queuePartnerSearchSync({ partnerIds: [partner.id] });}diff --git a/apps/web/lib/actions/confirm-email-change.ts b/apps/web/lib/actions/confirm-email-change.tsindex 3447c3e208..7ffb7988c5 100644--- a/apps/web/lib/actions/confirm-email-change.ts+++ b/apps/web/lib/actions/confirm-email-change.ts@@ -164,8 +164,8 @@ export const confirmEmailChangeAction = authUserActionClientredis.del(`email-change-request:token:${tokenFound.token}`),- // Email is both a searchable field and the n-gram source, so a stale- // one leaves the partner findable under an address they no longer have.+ // Queue an index update because the partner email changed, which is+ // searchable and the n-gram source....(changedPartnerId? [queuePartnerSearchSync({ partnerIds: [changedPartnerId] })]: []),diff --git a/apps/web/lib/actions/partners/accept-program-invite.ts b/apps/web/lib/actions/partners/accept-program-invite.tsindex 731a84bcc6..e68d92fc06 100644--- a/apps/web/lib/actions/partners/accept-program-invite.ts+++ b/apps/web/lib/actions/partners/accept-program-invite.ts@@ -96,7 +96,8 @@ export const acceptProgramInviteAction = authPartnerActionClientpartnerId: enrolledPartner.id,},}),- // 5. Reflect the accepted status in the partner search index+ // Queue an index update because the enrollment status moved to+ // approved.queuePartnerSearchSync({enrollmentIds: [enrollment.id],}),diff --git a/apps/web/lib/actions/partners/archive-partner.ts b/apps/web/lib/actions/partners/archive-partner.tsindex 498628a292..3be11a44ba 100644--- a/apps/web/lib/actions/partners/archive-partner.ts+++ b/apps/web/lib/actions/partners/archive-partner.ts@@ -64,7 +64,8 @@ export const archivePartnerAction = authActionClient},}),- // Status moved to archived.+ // Queue an index update because the enrollment status moved to+ // archived.queuePartnerSearchSync({ partnerIds: [partnerId], programId }),]),);diff --git a/apps/web/lib/actions/partners/ban-partner.ts b/apps/web/lib/actions/partners/ban-partner.tsindex 3fff2bee90..28a7474128 100644--- a/apps/web/lib/actions/partners/ban-partner.ts+++ b/apps/web/lib/actions/partners/ban-partner.ts@@ -142,7 +142,7 @@ export const banPartner = async ({},}),- // Status moved to banned.+ // Queue an index update because the enrollment status moved to banned.queuePartnerSearchSync({enrollmentIds: [programEnrollmentUpdated.id],}),diff --git a/apps/web/lib/actions/partners/bulk-approve-partners.ts b/apps/web/lib/actions/partners/bulk-approve-partners.tsindex d9b1544943..8f78fe5fa8 100644--- a/apps/web/lib/actions/partners/bulk-approve-partners.ts+++ b/apps/web/lib/actions/partners/bulk-approve-partners.ts@@ -161,7 +161,8 @@ export const bulkApprovePartnersAction = authActionClientpartnerIds: updatedEnrollments.map(({ partnerId }) => partnerId),}),- // Status moved to approved.+ // Queue an index update because the enrollment statuses moved to+ // approved.queuePartnerSearchSync({enrollmentIds: updatedEnrollments.map(({ id }) => id),}),diff --git a/apps/web/lib/actions/partners/bulk-archive-partners.ts b/apps/web/lib/actions/partners/bulk-archive-partners.tsindex 697060c273..1c81b5e185 100644--- a/apps/web/lib/actions/partners/bulk-archive-partners.ts+++ b/apps/web/lib/actions/partners/bulk-archive-partners.ts@@ -84,9 +84,9 @@ export const bulkArchivePartnersAction = authActionClient})),),- // Scoped to the updateMany above, not the findMany: the select is- // narrowed to ACTIVE_ENROLLMENT_STATUSES and the update is not, so it- // also archives statuses the selected rows never carried.+ // Queue an index update because the enrollment statuses moved to+ // archived. Scoped to the updateMany above, not the findMany, which is+ // narrowed to ACTIVE_ENROLLMENT_STATUSES.queuePartnerSearchSync({ partnerIds, programId }),]),);diff --git a/apps/web/lib/actions/partners/bulk-ban-partners.ts b/apps/web/lib/actions/partners/bulk-ban-partners.tsindex e41fc82ea4..76ac1f4d19 100644--- a/apps/web/lib/actions/partners/bulk-ban-partners.ts+++ b/apps/web/lib/actions/partners/bulk-ban-partners.ts@@ -92,7 +92,8 @@ export const bulkBanPartnersAction = authActionClientwaitUntil(Promise.allSettled([- // Status moved to banned.+ // Queue an index update because the enrollment statuses moved to+ // banned.queuePartnerSearchSync({enrollmentIds: programEnrollments.map(({ id }) => id),}),diff --git a/apps/web/lib/actions/partners/bulk-invite-partners.ts b/apps/web/lib/actions/partners/bulk-invite-partners.tsindex 29d15b1509..2d57ab6acb 100644--- a/apps/web/lib/actions/partners/bulk-invite-partners.ts+++ b/apps/web/lib/actions/partners/bulk-invite-partners.ts@@ -200,9 +200,9 @@ export const bulkInvitePartnersAction = authActionClient);}- // createMany returns no IDs, so this passes partners and lets the job- // resolve the enrollments. Queued after the default links exist, so the- // first document already carries them.+ // Queue an index update because the partners were enrolled. createMany+ // returns no IDs, so this passes partners and lets the job resolve+ // them, after the default links exist.await queuePartnerSearchSync({partnerIds: partners.map(({ id }) => id),programId,diff --git a/apps/web/lib/actions/partners/bulk-reject-partner-applications.ts b/apps/web/lib/actions/partners/bulk-reject-partner-applications.tsindex e0410a7b52..c0d2094ae4 100644--- a/apps/web/lib/actions/partners/bulk-reject-partner-applications.ts+++ b/apps/web/lib/actions/partners/bulk-reject-partner-applications.ts@@ -90,7 +90,8 @@ export const bulkRejectPartnerApplicationsAction = authActionClientwaitUntil((async () => {await Promise.allSettled([- // Status moved to rejected.+ // Queue an index update because the enrollment statuses moved to+ // rejected.queuePartnerSearchSync({enrollmentIds: programEnrollments.map(({ id }) => id),}),diff --git a/apps/web/lib/actions/partners/create-program-application.ts b/apps/web/lib/actions/partners/create-program-application.tsindex 002b4652c8..255e439990 100644--- a/apps/web/lib/actions/partners/create-program-application.ts+++ b/apps/web/lib/actions/partners/create-program-application.ts@@ -384,7 +384,7 @@ async function createApplicationAndEnrollment({markApplicationEventSubmitted(programEnrollment),- // A new enrollment, pending approval.+ // Queue an index update because a new pending enrollment was created.queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] }),]);})(),diff --git a/apps/web/lib/actions/partners/decline-program-invite.ts b/apps/web/lib/actions/partners/decline-program-invite.tsindex de75f20d18..cdef6fe1e4 100644--- a/apps/web/lib/actions/partners/decline-program-invite.ts+++ b/apps/web/lib/actions/partners/decline-program-invite.ts@@ -29,6 +29,6 @@ export const declineProgramInviteAction = authPartnerActionClient},});- // Status moved to declined.+ // Queue an index update because the enrollment status moved to declined.waitUntil(queuePartnerSearchSync({ enrollmentIds: [enrollment.id] }));});diff --git a/apps/web/lib/actions/partners/delete-program-invite.ts b/apps/web/lib/actions/partners/delete-program-invite.tsindex ebc1545f7f..c73058c1c9 100644--- a/apps/web/lib/actions/partners/delete-program-invite.ts+++ b/apps/web/lib/actions/partners/delete-program-invite.ts@@ -117,7 +117,7 @@ export const deleteProgramInviteAction = authActionClient],}),- // Queue an index update for the deleted enrollment.+ // Queue an index update because the invited enrollment was deleted.queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] }),]),);diff --git a/apps/web/lib/actions/partners/onboard-partner.ts b/apps/web/lib/actions/partners/onboard-partner.tsindex 1a23dfa9f1..24f675936b 100644--- a/apps/web/lib/actions/partners/onboard-partner.ts+++ b/apps/web/lib/actions/partners/onboard-partner.ts@@ -126,8 +126,8 @@ export const onboardPartnerAction = authUserActionClient// Mark the application event as submitted for the `network` programmarkApplicationEventSubmittedNetwork(updatedPartner),- // Onboarding sets name, country and description. Overlaps with the- // sync completeProgramApplications queues above, which is harmless.+ // Queue an index update because onboarding set the partner name,+ // country and description.queuePartnerSearchSync({ partnerIds: [updatedPartner.id] }),]),);diff --git a/apps/web/lib/actions/partners/reactivate-partner.ts b/apps/web/lib/actions/partners/reactivate-partner.tsindex e312f273a0..3d81a465bb 100644--- a/apps/web/lib/actions/partners/reactivate-partner.ts+++ b/apps/web/lib/actions/partners/reactivate-partner.ts@@ -87,7 +87,8 @@ export const reactivatePartnerAction = authActionClient// TODO send email to partnerlinkCache.expireMany(links),- // Status moved back to approved.+ // Queue an index update because the enrollment status moved back to+ // approved.queuePartnerSearchSync({ partnerIds: [partnerId], programId }),trackActivityLog({diff --git a/apps/web/lib/actions/partners/start-partner-platform-verification.ts b/apps/web/lib/actions/partners/start-partner-platform-verification.tsindex 86233a9125..2535973c6e 100644--- a/apps/web/lib/actions/partners/start-partner-platform-verification.ts+++ b/apps/web/lib/actions/partners/start-partner-platform-verification.ts@@ -97,8 +97,9 @@ export const startPartnerPlatformVerificationAction = authPartnerActionClientconst result = await startVerification();- // All three paths upsert the searchable identifier. Queued once here rather- // than at each of the four upserts.+ // Queue an index update because verification upserts the searchable+ // platform identifier. Queued once here rather than at each of the four+ // upserts.waitUntil(queuePartnerSearchSync({ partnerIds: [partner.id] }));return result;diff --git a/apps/web/lib/actions/partners/tags/update-program-partner-tags.ts b/apps/web/lib/actions/partners/tags/update-program-partner-tags.tsindex 8efe4a242b..5e854cc448 100644--- a/apps/web/lib/actions/partners/tags/update-program-partner-tags.ts+++ b/apps/web/lib/actions/partners/tags/update-program-partner-tags.ts@@ -96,7 +96,8 @@ export const updateProgramPartnerTagsAction = authActionClient]);});- // Queue an index update for the changed tags.+ // Queue an index update because the partner's tags for this program+ // changed.waitUntil(queuePartnerSearchSync({ partnerIds, programId }));waitUntil(diff --git a/apps/web/lib/actions/partners/unban-partner.ts b/apps/web/lib/actions/partners/unban-partner.tsindex 9907d1c96a..110443eba8 100644--- a/apps/web/lib/actions/partners/unban-partner.ts+++ b/apps/web/lib/actions/partners/unban-partner.ts@@ -107,7 +107,8 @@ export const unbanPartnerAction = authActionClient},}),- // Status moved back to approved.+ // Queue an index update because the enrollment status moved back to+ // approved.queuePartnerSearchSync({ partnerIds: [partnerId], programId }),]),);diff --git a/apps/web/lib/actions/partners/update-partner-platforms.ts b/apps/web/lib/actions/partners/update-partner-platforms.tsindex 20c59405a3..786e8c0667 100644--- a/apps/web/lib/actions/partners/update-partner-platforms.ts+++ b/apps/web/lib/actions/partners/update-partner-platforms.ts@@ -192,7 +192,7 @@ export const updatePartnerPlatformsAction = authPartnerActionClientawait Promise.all(operations);- // One queue for the action rather than one per platform, and deliberately- // not scoped by program.+ // Queue an index update because the platform identifiers changed. Not+ // scoped by program, since platforms are shared across them.waitUntil(queuePartnerSearchSync({ partnerIds: [partner.id] }));});diff --git a/apps/web/lib/actions/partners/update-partner-profile.ts b/apps/web/lib/actions/partners/update-partner-profile.tsindex 158b646412..0d6c2a00fd 100644--- a/apps/web/lib/actions/partners/update-partner-profile.ts+++ b/apps/web/lib/actions/partners/update-partner-profile.ts@@ -256,8 +256,8 @@ export const updatePartnerProfileAction = authPartnerActionClientwaitUntil(Promise.allSettled([- // A profile is shared across programs, so this is deliberately not- // scoped to one.+ // Queue an index update because the partner profile changed. Not+ // scoped by program, since a profile is shared across them.queuePartnerSearchSync({ partnerIds: [partner.id] }),(async () => {diff --git a/apps/web/lib/actions/partners/withdraw-partner-application.ts b/apps/web/lib/actions/partners/withdraw-partner-application.tsindex b9da2f13f0..e18fe4c191 100644--- a/apps/web/lib/actions/partners/withdraw-partner-application.ts+++ b/apps/web/lib/actions/partners/withdraw-partner-application.ts@@ -49,7 +49,7 @@ export const withdrawPartnerApplicationAction = authPartnerActionClientreturn deletedProgramEnrollment;});- // Queue an index update for the deleted enrollment.+ // Queue an index update because the enrollment was deleted.waitUntil(queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] }),);diff --git a/apps/web/lib/api/groups/move-partners-to-group.ts b/apps/web/lib/api/groups/move-partners-to-group.tsindex b52a2699e8..9208f8e724 100644--- a/apps/web/lib/api/groups/move-partners-to-group.ts+++ b/apps/web/lib/api/groups/move-partners-to-group.ts@@ -190,7 +190,8 @@ export async function movePartnersToGroup({recordLink(partnerLinks),- // The group is a filterable field on the document.+ // Queue an index update because the enrollments moved group, which is+ // filterable.queuePartnerSearchSync({enrollmentIds: updatedProgramEnrollments.map(({ id }) => id),}),diff --git a/apps/web/lib/api/links/bulk-create-links.ts b/apps/web/lib/api/links/bulk-create-links.tsindex 4cd465065a..aa96386be7 100644--- a/apps/web/lib/api/links/bulk-create-links.ts+++ b/apps/web/lib/api/links/bulk-create-links.ts@@ -236,8 +236,9 @@ export async function bulkCreateLinks({linksCount: links.length,timestamp: new Date().toISOString(),}),- // Default delay rather than the link delay: a new short link is how- // people go looking for that partner, so it is worth indexing promptly.+ // Queue an index update because the new links carry searchable+ // shortLinks. Default delay, since a new short link is how people find+ // that partner.queuePartnerSearchSyncForLinks(createdLinksData),]),);diff --git a/apps/web/lib/api/links/bulk-delete-links.ts b/apps/web/lib/api/links/bulk-delete-links.tsindex 357cffd470..0ebc00bd6d 100644--- a/apps/web/lib/api/links/bulk-delete-links.ts+++ b/apps/web/lib/api/links/bulk-delete-links.ts@@ -65,8 +65,8 @@ export async function bulkDeleteLinks(storage.delete({ key: link.image!.replace(`${R2_URL}/`, "") }),),- // The enrollment outlives its links, so this re-serializes the document- // without them rather than removing it.+ // Queue an index update because the links were deleted. The enrollment+ // outlives them, so the document is re-serialized without them.queuePartnerSearchSyncForLinks(links, {delay: PARTNER_SEARCH_LINK_SYNC_DELAY_SECONDS,}),diff --git a/apps/web/lib/api/links/bulk-update-links.ts b/apps/web/lib/api/links/bulk-update-links.tsindex 3048dc02b7..856c03b7a8 100644--- a/apps/web/lib/api/links/bulk-update-links.ts+++ b/apps/web/lib/api/links/bulk-update-links.ts@@ -130,7 +130,8 @@ export async function bulkUpdateLinks(propagateBulkLinkChanges({links: updatedLinks,}),- // A bulk edit can change the destination URL or the link owner.+ // Queue an index update because a bulk edit can change the destination+ // URL or the link owner.queuePartnerSearchSyncForLinks([...previousOwners, ...updatedLinks], {delay: PARTNER_SEARCH_LINK_SYNC_DELAY_SECONDS,}),diff --git a/apps/web/lib/api/links/complete-ab-tests.ts b/apps/web/lib/api/links/complete-ab-tests.tsindex 7e3bb6be7d..bfb5f76cdd 100644--- a/apps/web/lib/api/links/complete-ab-tests.ts+++ b/apps/web/lib/api/links/complete-ab-tests.ts@@ -82,7 +82,8 @@ export async function completeABTests(link: Link) {linkCache.set(response),// record the linkrecordLink(response),- // The winning variant replaces the destination URL, which is searchable.+ // Queue an index update because the winning variant replaced the+ // destination URL.queuePartnerSearchSyncForLinks([response], {delay: PARTNER_SEARCH_LINK_SYNC_DELAY_SECONDS,}),diff --git a/apps/web/lib/api/links/create-link.ts b/apps/web/lib/api/links/create-link.tsindex def7ff56b5..bd518e74af 100644--- a/apps/web/lib/api/links/create-link.ts+++ b/apps/web/lib/api/links/create-link.ts@@ -154,8 +154,8 @@ export async function createLink(link: ProcessedLinkProps) {...(discount && { discount }),}),- // A new partner link is how people search for that partner, so this- // takes the default delay rather than the longer link one.+ // Queue an index update because the new link adds a searchable+ // shortLink. Default delay rather than the longer link one.response.programId &&response.partnerId &&queuePartnerSearchSync({diff --git a/apps/web/lib/api/links/delete-link.ts b/apps/web/lib/api/links/delete-link.tsindex e938e3a661..fe22434032 100644--- a/apps/web/lib/api/links/delete-link.ts+++ b/apps/web/lib/api/links/delete-link.ts@@ -79,8 +79,8 @@ export async function deleteLink(linkId: string) {link.discountCode && enqueueDeleteDiscountCode([link.discountCode]),- // The enrollment outlives the link, so this re-serializes the document- // without it rather than removing the document.+ // Queue an index update because the link was deleted. The enrollment+ // outlives it, so the document is re-serialized without it.link.programId &&link.partnerId &&queuePartnerSearchSync({diff --git a/apps/web/lib/api/links/update-link.ts b/apps/web/lib/api/links/update-link.tsindex 8557aa2bbf..64ef380906 100644--- a/apps/web/lib/api/links/update-link.ts+++ b/apps/web/lib/api/links/update-link.ts@@ -211,8 +211,9 @@ export async function updateLink({// If key is changed: delete the old key in Redis(changedDomain || changedKey) && linkCache.delete(oldLink),- // Both owners, because the spread above can rewrite `partnerId`: when a- // link moves, the former owner has to be re-serialized without it.+ // Queue an index update because the edit can change the destination URL+ // or move the link. Both owners, so a former one is re-serialized+ // without it.queuePartnerSearchSyncForLinks([oldLink, response], {delay: PARTNER_SEARCH_LINK_SYNC_DELAY_SECONDS,}),diff --git a/apps/web/lib/api/partners/applications/approve-partner.ts b/apps/web/lib/api/partners/applications/approve-partner.tsindex b0bdd164a3..32018376b1 100644--- a/apps/web/lib/api/partners/applications/approve-partner.ts+++ b/apps/web/lib/api/partners/applications/approve-partner.ts@@ -132,7 +132,7 @@ export async function approvePartner({waitUntil(Promise.allSettled([- // Status moved to approved.+ // Queue an index update because the enrollment status moved to approved.queuePartnerSearchSync({ partnerIds: [partnerId], programId }),trackActivityLog({diff --git a/apps/web/lib/api/partners/applications/reject-partner.ts b/apps/web/lib/api/partners/applications/reject-partner.tsindex 8d4417b508..96bdbf151d 100644--- a/apps/web/lib/api/partners/applications/reject-partner.ts+++ b/apps/web/lib/api/partners/applications/reject-partner.ts@@ -147,9 +147,9 @@ export async function rejectPartner({waitUntil(Promise.allSettled([- // Covers both outcomes above: an instant reapplication timeframe deletes- // the enrollment, anything else rejects it. The job reads the ID back, so- // this does not need to know which ran.+ // Queue an index update because the enrollment was either rejected or+ // deleted. The job reads the ID back, so this does not need to know+ // which.queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] }),trackActivityLog({diff --git a/apps/web/lib/api/partners/bulk-delete-partners.ts b/apps/web/lib/api/partners/bulk-delete-partners.tsindex 4d7f1ca558..ed99edf201 100644--- a/apps/web/lib/api/partners/bulk-delete-partners.ts+++ b/apps/web/lib/api/partners/bulk-delete-partners.ts@@ -161,7 +161,7 @@ export async function bulkDeletePartners({`Deleted ${deletedProgramEnrollments.count} program enrollments`,);- // Queue an index update for the deleted enrollments.+ // Queue an index update because the ACME enrollments were deleted.await queuePartnerSearchSync({ enrollmentIds: programEnrollmentIds });if (deletedProgramEnrollments.count > 0) {@@ -202,7 +202,8 @@ export async function bulkDeletePartners({console.log(`Deleted ${partnerIds.length} partners`);- // Queue an index update for the cascade-deleted enrollments.+ // Queue an index update because deleting the partners cascades to their+ // remaining enrollments in other programs.await queuePartnerSearchSync({enrollmentIds: cascadedEnrollments.map(({ id }) => id),});diff --git a/apps/web/lib/api/partners/bulk-reactivate-partners.ts b/apps/web/lib/api/partners/bulk-reactivate-partners.tsindex 880d9553c0..daa56eaa69 100644--- a/apps/web/lib/api/partners/bulk-reactivate-partners.ts+++ b/apps/web/lib/api/partners/bulk-reactivate-partners.ts@@ -155,7 +155,8 @@ export async function bulkReactivatePartners({})),),- // Status moved back to approved.+ // Queue an index update because the enrollment statuses moved back to+ // approved.queuePartnerSearchSync({enrollmentIds: programEnrollments.map(({ id }) => id),}),diff --git a/apps/web/lib/api/partners/create-and-enroll-partner.ts b/apps/web/lib/api/partners/create-and-enroll-partner.tsindex ed817a69f0..ab1625e5aa 100644--- a/apps/web/lib/api/partners/create-and-enroll-partner.ts+++ b/apps/web/lib/api/partners/create-and-enroll-partner.ts@@ -254,8 +254,8 @@ export const createAndEnrollPartner = async ({data: enrolledPartner,}),- // Queued after the default links exist, so the first document already- // carries them and the partner is findable by short link right away.+ // Queue an index update because a new enrollment was created. Queued+ // after the default links exist, so the first document carries them.queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] }),]),);diff --git a/apps/web/lib/api/partners/process-partner-deactivation.ts b/apps/web/lib/api/partners/process-partner-deactivation.tsindex acc19c4c0c..d118277d0b 100644--- a/apps/web/lib/api/partners/process-partner-deactivation.ts+++ b/apps/web/lib/api/partners/process-partner-deactivation.ts@@ -91,8 +91,9 @@ export async function processPartnerDeactivation({},);- // Queued outside the `user` branch below, which only runs for operator-driven- // deactivations. The index has to follow the status either way.+ // Queue an index update because the enrollment statuses moved to deactivated.+ // Outside the user branch below, which only runs for operator-driven+ // deactivations.await queuePartnerSearchSync({ partnerIds, programId });if (user) {diff --git a/apps/web/lib/firstpromoter/import-partners.ts b/apps/web/lib/firstpromoter/import-partners.tsindex 8d7f19c8ce..dfdabdce90 100644--- a/apps/web/lib/firstpromoter/import-partners.ts+++ b/apps/web/lib/firstpromoter/import-partners.ts@@ -91,8 +91,8 @@ export async function importPartners(payload: FirstPromoterImportPayload) {}});- // Queued per page rather than per partner, so a large import produces a- // handful of chunked payloads instead of one message each.+ // Queue an index update because the imported partners were enrolled.+ // Queued per page rather than per partner.await queuePartnerSearchSync({enrollmentIds: results.flatMap((result) =>result.status === "fulfilled" && result.value ? [result.value] : [],diff --git a/apps/web/lib/jobs/handlers/partner-tag-deleted-job.ts b/apps/web/lib/jobs/handlers/partner-tag-deleted-job.tsindex f6aba9d159..0a4081106f 100644--- a/apps/web/lib/jobs/handlers/partner-tag-deleted-job.ts+++ b/apps/web/lib/jobs/handlers/partner-tag-deleted-job.ts@@ -70,7 +70,8 @@ export const partnerTagDeletedJob = defineJob({`[partnerTagDeletedJob] Deleted ${count} program–partner tag associations.`,);- // Queue an index update for the affected enrollments.+ // Queue an index update because the tag was removed from these+ // enrollments.await queuePartnerSearchSync({enrollmentIds: programPartnerTags.map(({ programEnrollment }) => programEnrollment.id,diff --git a/apps/web/lib/partners/complete-program-applications.ts b/apps/web/lib/partners/complete-program-applications.tsindex b98552bc06..c8e30fbdef 100644--- a/apps/web/lib/partners/complete-program-applications.ts+++ b/apps/web/lib/partners/complete-program-applications.ts@@ -274,8 +274,9 @@ export async function completeProgramApplications(userEmail: string) {),);- // One queue covers both the new enrollments and the platforms backfilled- // above, since the job re-reads the whole document.+ // Queue an index update because the applications completed into+ // enrollments. One queue also covers the platforms backfilled above, since+ // the job re-reads the document.await queuePartnerSearchSync({enrollmentIds: programEnrollments.map(({ id }) => id),});diff --git a/apps/web/lib/partners/sync-partner-identity.ts b/apps/web/lib/partners/sync-partner-identity.tsindex ee8782e4c1..a96d8f7353 100644--- a/apps/web/lib/partners/sync-partner-identity.ts+++ b/apps/web/lib/partners/sync-partner-identity.ts@@ -103,8 +103,8 @@ export async function syncNameAndImageToPartner({},});- // Only the name reaches the document, so an image-only sync changes nothing the- // index holds, so it is not worth a queue.+ // Queue an index update because the partner name changed. An image-only sync+ // is skipped, since the image is not indexed.if (hasNameUpdate && name) {await queuePartnerSearchSync({ partnerIds: [partnerId] });}diff --git a/apps/web/lib/partnerstack/import-partners.ts b/apps/web/lib/partnerstack/import-partners.tsindex c07b2b864c..5b617b6dd6 100644--- a/apps/web/lib/partnerstack/import-partners.ts+++ b/apps/web/lib/partnerstack/import-partners.ts@@ -68,8 +68,8 @@ export async function importPartners(payload: PartnerStackImportPayload) {),);- // Queued per page rather than per partner, so a large import produces a- // handful of chunked payloads instead of one message each.+ // Queue an index update because the imported partners were enrolled. Queued+ // per page rather than per partner.await queuePartnerSearchSync({partnerIds: results.flatMap((result) =>result.status === "fulfilled" && result.value ? [result.value] : [],diff --git a/apps/web/lib/rewardful/import-partners.ts b/apps/web/lib/rewardful/import-partners.tsindex 69d9ea1fc7..adaf6ccd3d 100644--- a/apps/web/lib/rewardful/import-partners.ts+++ b/apps/web/lib/rewardful/import-partners.ts@@ -126,8 +126,8 @@ export async function importPartners(payload: RewardfulImportPayload) {),);- // Queued per page rather than per partner, so a large import produces a- // handful of chunked payloads instead of one message each.+ // Queue an index update because the imported partners were enrolled.+ // Queued per page rather than per partner.await queuePartnerSearchSync({partnerIds: filteredPartners.map((p) => p.dubPartnerId),programId: program.id,diff --git a/apps/web/lib/tapfiliate/cleanup-partners.ts b/apps/web/lib/tapfiliate/cleanup-partners.tsindex d8139611f6..bf6b002c9e 100644--- a/apps/web/lib/tapfiliate/cleanup-partners.ts+++ b/apps/web/lib/tapfiliate/cleanup-partners.ts@@ -81,7 +81,7 @@ export async function cleanupPartners(payload: TapfiliateImportPayload) {},});- // The enrollments were just deleted.+ // Queue an index update because the enrollments were deleted.await queuePartnerSearchSync({enrollmentIds: removedEnrollments.map(({ id }) => id),});diff --git a/apps/web/lib/tapfiliate/import-partners.ts b/apps/web/lib/tapfiliate/import-partners.tsindex b0880ac803..5a149bca50 100644--- a/apps/web/lib/tapfiliate/import-partners.ts+++ b/apps/web/lib/tapfiliate/import-partners.ts@@ -112,8 +112,8 @@ export async function importPartners(payload: TapfiliateImportPayload) {.map((p) => p.value);if (partnerIds.length > 0) {- // Queued per page rather than per partner, so a large import produces a- // handful of chunked payloads instead of one message each.+ // Queue an index update because the imported partners were enrolled.+ // Queued per page rather than per partner.await queuePartnerSearchSync({ partnerIds, programId });await tapfiliateImporter.trackImportedPartnerIds({diff --git a/apps/web/lib/tolt/cleanup-partners.ts b/apps/web/lib/tolt/cleanup-partners.tsindex 6136009612..361d1d1d7e 100644--- a/apps/web/lib/tolt/cleanup-partners.ts+++ b/apps/web/lib/tolt/cleanup-partners.ts@@ -75,7 +75,7 @@ export async function cleanupPartners({ programId }: { programId: string }) {},});- // The enrollments were just deleted.+ // Queue an index update because the enrollments were deleted.await queuePartnerSearchSync({enrollmentIds: removedEnrollments.map(({ id }) => id),});diff --git a/apps/web/lib/tolt/import-partners.ts b/apps/web/lib/tolt/import-partners.tsindex 0c0e30007b..0aedd939a0 100644--- a/apps/web/lib/tolt/import-partners.ts+++ b/apps/web/lib/tolt/import-partners.ts@@ -85,8 +85,8 @@ export async function importPartners(payload: ToltImportPayload) {.map((p) => p.value);if (partners.length > 0) {- // Queued per page rather than per partner, so a large import produces a- // handful of chunked payloads instead of one message each.+ // Queue an index update because the imported partners were enrolled.+ // Queued per page rather than per partner.await queuePartnerSearchSync({partnerIds: partners.map((p) => p.id),programId,diff --git a/apps/web/scripts/customers/buffer/migrate-to-case-sensitive.ts b/apps/web/scripts/customers/buffer/migrate-to-case-sensitive.tsindex e285170182..998a788837 100644--- a/apps/web/scripts/customers/buffer/migrate-to-case-sensitive.ts+++ b/apps/web/scripts/customers/buffer/migrate-to-case-sensitive.ts@@ -94,7 +94,8 @@ async function main() {});}- // Queued before the cache expiry below.+ // Queue an index update because the link keys and shortLinks changed. Queued+ // before the cache expiry below.await queuePartnerSearchSyncForLinks(links);// expire the Redis cache for the links so it fetches the latest version from the databasediff --git a/apps/web/scripts/fix-broken-applications.ts b/apps/web/scripts/fix-broken-applications.tsindex d0878b7509..18656cb095 100644--- a/apps/web/scripts/fix-broken-applications.ts+++ b/apps/web/scripts/fix-broken-applications.ts@@ -77,7 +77,7 @@ async function main() {console.log("Deleted program enrollments", res);- // Queue an index update for the deleted enrollments.+ // Queue an index update because the broken enrollments were deleted.await queuePartnerSearchSync({ enrollmentIds });}diff --git a/apps/web/scripts/misc/restore-program-enrollments.ts b/apps/web/scripts/misc/restore-program-enrollments.tsindex aedf8133af..937e24579b 100644--- a/apps/web/scripts/misc/restore-program-enrollments.ts+++ b/apps/web/scripts/misc/restore-program-enrollments.ts@@ -47,7 +47,8 @@ async function main() {});console.log(`Restored ${res.count} program enrollments`);- // Queued before the Tinybird and Stripe work below.+ // Queue an index update because the enrollments and their links were+ // restored. Queued before the Tinybird and Stripe work below.const queueSearchSync = () =>queuePartnerSearchSync({enrollmentIds: programEnrollmentsToRestore.map(({ id }) => id),diff --git a/apps/web/scripts/partners/delete-partner-profile.ts b/apps/web/scripts/partners/delete-partner-profile.tsindex 1e10197e72..39aa9e0e39 100644--- a/apps/web/scripts/partners/delete-partner-profile.ts+++ b/apps/web/scripts/partners/delete-partner-profile.ts@@ -97,7 +97,7 @@ async function main() {});console.log(`Deleted ${deletedProgramEnrollments.count} program enrollments`);- // Queue an index update for the deleted enrollments.+ // Queue an index update because the partner's enrollments were deleted.await queuePartnerSearchSync({enrollmentIds: partner.programs.map(({ id }) => id),});diff --git a/apps/web/scripts/partners/delete-partners-for-program.ts b/apps/web/scripts/partners/delete-partners-for-program.tsindex 65b8f3b1b3..1d01180bc9 100644--- a/apps/web/scripts/partners/delete-partners-for-program.ts+++ b/apps/web/scripts/partners/delete-partners-for-program.ts@@ -57,7 +57,8 @@ async function main() {console.log("deletePartners", deletePartners);- // Queue an index update for the cascade-deleted enrollments.+ // Queue an index update because deleting the partners cascades to their+ // enrollments.await queuePartnerSearchSync({ enrollmentIds });}diff --git a/apps/web/scripts/partners/delete-program-application.ts b/apps/web/scripts/partners/delete-program-application.tsindex 6167e504e6..d0b7adb132 100644--- a/apps/web/scripts/partners/delete-program-application.ts+++ b/apps/web/scripts/partners/delete-program-application.ts@@ -27,7 +27,7 @@ async function main() {console.log("Deleted program enrollment", deleteProgramEnrollment);- // Queue an index update for the deleted enrollment.+ // Queue an index update because the enrollment was deleted.await queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] });if (programEnrollment.applicationId) {diff --git a/apps/web/scripts/partners/delete-program-enrollment.ts b/apps/web/scripts/partners/delete-program-enrollment.tsindex 5d0cdd33ea..f637fa2aa7 100644--- a/apps/web/scripts/partners/delete-program-enrollment.ts+++ b/apps/web/scripts/partners/delete-program-enrollment.ts@@ -53,7 +53,7 @@ async function main() {console.log("deleteProgramEnrollment", deleteProgramEnrollment);- // Queue an index update for the deleted enrollment.+ // Queue an index update because the enrollment was deleted.await queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] });}diff --git a/apps/web/scripts/partners/delete-program.ts b/apps/web/scripts/partners/delete-program.tsindex 866d7efd8e..f8df93247d 100644--- a/apps/web/scripts/partners/delete-program.ts+++ b/apps/web/scripts/partners/delete-program.ts@@ -104,7 +104,8 @@ async function main() {},);- // Queue an index update for the deleted enrollments.+ // Queue an index update because deleting the program deleted every enrollment+ // in it.await queuePartnerSearchSync({enrollmentIds: enrollments.map(({ id }) => id),});diff --git a/apps/web/scripts/partners/fix-partner-groups.ts b/apps/web/scripts/partners/fix-partner-groups.tsindex fd7979374f..2ed9e1a0e6 100644--- a/apps/web/scripts/partners/fix-partner-groups.ts+++ b/apps/web/scripts/partners/fix-partner-groups.ts@@ -56,7 +56,8 @@ async function main() {console.log(`Updated ${updateMany.count} partners`);- // Queue an index update for the changed groups.+ // Queue an index update because the enrollments gained a group, which is+ // filterable.await queuePartnerSearchSync({enrollmentIds: partnersMissingGroup.map((partner) => partner.id),});diff --git a/apps/web/scripts/partners/merge-partner-profile.ts b/apps/web/scripts/partners/merge-partner-profile.tsindex 5836d0c664..3be17acf2a 100644--- a/apps/web/scripts/partners/merge-partner-profile.ts+++ b/apps/web/scripts/partners/merge-partner-profile.ts@@ -61,6 +61,7 @@ async function main() {},});+ // Queue an index update because the enrollment moved to the new partner.// Queued before the Tinybird write below.await queuePartnerSearchSync({ enrollmentIds: [programEnrollment.id] });diff --git a/apps/web/scripts/partners/update-links.ts b/apps/web/scripts/partners/update-links.tsindex e223e40fc7..b7ed4ffd39 100644--- a/apps/web/scripts/partners/update-links.ts+++ b/apps/web/scripts/partners/update-links.ts@@ -47,8 +47,8 @@ async function main() {}),);- // Queued before the cache and Tinybird work below. The helper reads only- // programId and partnerId, which the move does not touch.+ // Queue an index update because the links changed domain. Queued before the+ // cache and Tinybird work below.await queuePartnerSearchSyncForLinks(links);const res = await Promise.all([diff --git a/apps/web/scripts/partners/update-partner-country.ts b/apps/web/scripts/partners/update-partner-country.tsindex 80972fec34..6f55c2c8c1 100644--- a/apps/web/scripts/partners/update-partner-country.ts+++ b/apps/web/scripts/partners/update-partner-country.ts@@ -17,7 +17,7 @@ async function main() {},});- // Queue an index update for the changed country.+ // Queue an index update because the partner country changed.await queuePartnerSearchSync({ partnerIds: [partner.id] });if (partner.stripeConnectId) {diff --git a/apps/web/scripts/programs/delete-network-invites.ts b/apps/web/scripts/programs/delete-network-invites.tsindex cd25eec068..0be17bb2e3 100644--- a/apps/web/scripts/programs/delete-network-invites.ts+++ b/apps/web/scripts/programs/delete-network-invites.ts@@ -68,7 +68,7 @@ async function main() {console.log("res2", res2);- // Queue an index update for the deleted enrollments.+ // Queue an index update because the invited enrollments were deleted.await queuePartnerSearchSync({ enrollmentIds });}diff --git a/apps/web/scripts/programs/delete-program-enrollments.ts b/apps/web/scripts/programs/delete-program-enrollments.tsindex c8483f9e5b..33e0dd4bb3 100644--- a/apps/web/scripts/programs/delete-program-enrollments.ts+++ b/apps/web/scripts/programs/delete-program-enrollments.ts@@ -51,7 +51,7 @@ async function main() {console.log("deleteProgramEnrollment", deleteProgramEnrollment);- // Queue an index update for the deleted enrollments.+ // Queue an index update because the enrollments were deleted.await queuePartnerSearchSync({ enrollmentIds });}}