The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Drop em dashes from the partner search comments
Rafi3e0e96cbbe73
diff --git a/apps/web/lib/api/partners/get-partners.ts b/apps/web/lib/api/partners/get-partners.tsindex a71c324892..22a3d9d118 100644--- a/apps/web/lib/api/partners/get-partners.ts+++ b/apps/web/lib/api/partners/get-partners.ts@@ -99,7 +99,7 @@ export async function getPartners(if (relevanceHits) {// Relevance order cannot be expressed in SQL, so the page has to be chosen// in memory. Resolve which candidates survive the filters as bare IDs- // first — hydrating all of them to show one page costs ~330ms at the+ // first, because hydrating all of them to show one page costs ~330ms at the// candidate limit against ~4ms for the page alone.const matches = await prisma.programEnrollment.findMany({where: candidateWhere,diff --git a/apps/web/lib/api/partners/search/providers/resilience.ts b/apps/web/lib/api/partners/search/providers/resilience.tsindex 047f90d4a4..70c6002a7c 100644--- a/apps/web/lib/api/partners/search/providers/resilience.ts+++ b/apps/web/lib/api/partners/search/providers/resilience.ts@@ -4,7 +4,7 @@ function isTransientError(error: unknown): boolean {const message = error instanceof Error ? error.message : String(error);// fetch network failures surface as TypeError ("fetch failed"), but so do- // ordinary programming errors — only the network ones deserve a retry.+ // ordinary programming errors, and only the network ones deserve a retry.if (error instanceof TypeError) {const normalized = message.toLowerCase();return (@@ -51,7 +51,7 @@ export async function withTransientRetry<T>(/*** Rejects if `operation` has not settled within `timeoutMs`. The operation is- * not cancelled — `Promise.race` cannot do that — so only pass work that+ * not cancelled, because `Promise.race` cannot do that, so only pass work that* settles on its own.*/export async function withDeadline<T>(diff --git a/apps/web/lib/api/partners/search/providers/shared.ts b/apps/web/lib/api/partners/search/providers/shared.tsindex 1bf3ed866f..937d7116b2 100644--- a/apps/web/lib/api/partners/search/providers/shared.ts+++ b/apps/web/lib/api/partners/search/providers/shared.ts@@ -4,9 +4,9 @@ const NGRAM_SIZE = 3;/*** Three-character tokens, which is what lets a partial email match without a- * leading-wildcard query. Providers package these differently — Redis Search+ * leading-wildcard query. Providers package these differently. Redis Search* requires each one as a separate `$eq`, Turbopuffer takes them as a single- * query string — so this returns the tokens and leaves the packaging to them.+ * query string, so this returns the tokens and leaves the packaging to them.*/function toNgrams(value: string): string[] {return Array.from(diff --git a/apps/web/lib/api/partners/search/providers/turbopuffer.ts b/apps/web/lib/api/partners/search/providers/turbopuffer.tsindex 50f923fca5..94d2333edf 100644--- a/apps/web/lib/api/partners/search/providers/turbopuffer.ts+++ b/apps/web/lib/api/partners/search/providers/turbopuffer.ts@@ -38,7 +38,7 @@ interface TurbopufferPartnerSearchRow extends Record<string, unknown> {/*** Pinned rather than left to default. Turbopuffer's newer tokenizers keep a URL* as a single token, so `scottdigital` cannot match- * `https://www.scottdigital-42.techcorp.io` — and partner websites, short+ * `https://www.scottdigital-42.techcorp.io`, and partner websites, short* links, and destination URLs are all searchable fields here. word_v2 splits* URLs into their components while handling emails, handles, and hyphenated* keys the same way the newer ones do.@@ -191,8 +191,8 @@ const RRF_RANK_CONSTANT = 60;/*** Fuses the branches by rank (RRF) rather than by score. BM25 scores from- * different clauses are not comparable — the n-gram branch sums over many- * trigram terms and runs numerically hotter than the text branch — but rank+ * different clauses are not comparable, because the n-gram branch sums over many+ * trigram terms and runs numerically hotter than the text branch, but rank* positions are. Each document scores Σ 1/(60 + rank) across the branches it* appears in, so a document found by both branches receives a contribution* from each, and the raw `$dist` values are deliberately unused. Relies on@@ -260,7 +260,7 @@ export function createTurbopufferPartnerSearchProvider({},async waitForIndexing() {- // Turbopuffer writes are read-after-write consistent — a committed write+ // Turbopuffer writes are read-after-write consistent, so a committed write// is immediately queryable, so there is no indexing lag to wait on.},diff --git a/apps/web/lib/api/partners/search/types.ts b/apps/web/lib/api/partners/search/types.tsindex 98ce65ef94..8ea6bff7d6 100644--- a/apps/web/lib/api/partners/search/types.ts+++ b/apps/web/lib/api/partners/search/types.ts@@ -12,11 +12,11 @@ import { PlatformType } from "@prisma/client";* 2. the database applies status/group/country/tag/metric to those 999** A query matching fewer than 999 is unaffected. Beyond that, both the rows and- * the count are a floor, and nothing reports that — neither response has a+ * the count are a floor, and nothing reports that, because neither response has a* field for it that could be added without breaking its shape.** The fix is indexing the filterable fields so the provider filters before it- * ranks, which means keeping them in sync on every write — out of scope here.+ * ranks, which means keeping them in sync on every write. That is out of scope here.*/export const PARTNER_SEARCH_CANDIDATE_LIMIT = 999;diff --git a/apps/web/scripts/dev/benchmark-partner-search.ts b/apps/web/scripts/dev/benchmark-partner-search.tsindex 0ea053318c..89c7b24dc5 100644--- a/apps/web/scripts/dev/benchmark-partner-search.ts+++ b/apps/web/scripts/dev/benchmark-partner-search.ts@@ -2,7 +2,7 @@* Measures p99 latency of the relevance-ranked partner list for a program.** Calls `getPartners` in process, not over HTTP, so the numbers exclude route- * handling, auth, and serialization — treat them as a floor for the endpoint.+ * handling, auth, and serialization, so treat them as a floor for the endpoint.** --searchOnly times the provider's candidate query alone and skips the* database. Use it to compare providers: they are the same remote services@@ -583,7 +583,7 @@ async function main() {.map(({ field }) => field).join(", ",- )}. There is no p99 to compare against the threshold — check that the search index is backfilled for this program.`,+ )}. There is no p99 to compare against the threshold. Check that the search index is backfilled for this program.`,);}diff --git a/apps/web/scripts/dev/debug-partner-search.ts b/apps/web/scripts/dev/debug-partner-search.tsindex a619c8f640..74962eec08 100644--- a/apps/web/scripts/dev/debug-partner-search.ts+++ b/apps/web/scripts/dev/debug-partner-search.ts@@ -111,7 +111,7 @@ const EMAIL_PATTERN = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;** Debug-only: `searchCandidates` asks for no attributes, because the API only* ever needs IDs. This exists so --searchOnly can show what was indexed when the- * rows are not in the local database — a production index against a seeded one.+ * rows are not in the local database, such as a production index against a seeded one.*/async function fetchIndexedText(ids: string[]): Promise<Map<string, string>> {const apiKey = process.env.TURBOPUFFER_API_KEY;@@ -148,8 +148,8 @@ const PLATFORM_TYPES = [/*** `searchText` is every searchable value lowercased and space-joined in a fixed* order: partner ID, name, email, company, description, platform types, handles,- * then links. Three of those boundaries are recoverable — the ID is prefixed,- * the email is address-shaped, and the platform types are a known enum — so the+ * then links. Three of those boundaries are recoverable, since the ID is prefixed,+ * the email is address-shaped, and the platform types are a known enum, so the* blob splits into name / profile / platforms-and-links. Company and description* cannot be told apart once joined, so they stay together as `profile`.*/diff --git a/apps/web/scripts/dev/seed-100k-partners.ts b/apps/web/scripts/dev/seed-100k-partners.tsindex 59d8c40cf4..b0358845da 100644--- a/apps/web/scripts/dev/seed-100k-partners.ts+++ b/apps/web/scripts/dev/seed-100k-partners.ts@@ -2,7 +2,7 @@* Bulk-seeds partners for local development and partner-search benchmarking.** Writes User, Partner, PartnerUser, ProgramEnrollment, PartnerPlatform, and Link- * rows — every field the search index reads — in atomic chunks of CHUNK_SIZE+ * rows (every field the search index reads) in atomic chunks of CHUNK_SIZE* partners, so 100K partners lands ~400K rows in seconds.** Re-running with the same `--seed` collides. `seedFingerprint` is a deterministic@@ -106,7 +106,7 @@ const DOMAINS = [const COUNTRIES = ["US", "CA", "GB", "DE", "FR", "AU", "JP", "IN", "BR", "NL", "ES", "SE", "SG"];// A description's longest word becomes its benchmark query, so the specialty is-// what has to vary — every other word here is shorter than every specialty, and+// what has to vary, since every other word here is shorter than every specialty, and// the specialties differ within their first twelve characters (the query is// truncated there).const DESCRIPTION_TEMPLATES = [@@ -278,7 +278,7 @@ const assertSeedableDatabase = (allowRemoteDatabase: boolean) => {// The host allowlist cannot tell a truly local database from a production// one reached through a local tunnel, so a production environment refuses- // outright — --allowRemoteDatabase does not override this.+ // outright. --allowRemoteDatabase does not override this.if (process.env.NODE_ENV === "production" ||process.env.VERCEL_ENV === "production"@@ -500,7 +500,7 @@ const insertPartnerChunk = async ({// Generation is deterministic given (programId, seed), so index 0's link key is// always the same. Keyed on the link key rather than the email because the key-// is built from the fingerprint and index alone — editing the name or domain+// is built from the fingerprint and index alone, so editing the name or domain// pools changes index 0's email, which would let this miss an applied seed and// surface a raw constraint error partway through instead.const assertSeedNotAlreadyApplied = async (@@ -522,7 +522,7 @@ const assertSeedNotAlreadyApplied = async (if (existing) {throw new Error(- `Seed "${seed}" has already been applied to this program (found ${firstLink.domain}/${firstLink.key}). Re-running would collide on unique emails, usernames, and link keys — pass a different --seed to add another batch.`,+ `Seed "${seed}" has already been applied to this program (found ${firstLink.domain}/${firstLink.key}). Re-running would collide on unique emails, usernames, and link keys. Pass a different --seed to add another batch.`,);}};diff --git a/apps/web/scripts/partners/backfill-partner-search.ts b/apps/web/scripts/partners/backfill-partner-search.tsindex caca3938fd..06be793fbd 100644--- a/apps/web/scripts/partners/backfill-partner-search.ts+++ b/apps/web/scripts/partners/backfill-partner-search.ts@@ -6,7 +6,7 @@* last indexed document, so a partial backfill is never redone from zero.** The backfill only upserts. Documents whose enrollment was deleted are removed- * by rebuilding the index wholesale, not incrementally — delete it and backfill+ * by rebuilding the index wholesale, not incrementally. Delete it and backfill* again.** cd apps/webdiff --git a/apps/web/tests/partners/turbopuffer-partner-search-provider.test.ts b/apps/web/tests/partners/turbopuffer-partner-search-provider.test.tsindex aa363b38c6..b9c7ad8fd5 100644--- a/apps/web/tests/partners/turbopuffer-partner-search-provider.test.ts+++ b/apps/web/tests/partners/turbopuffer-partner-search-provider.test.ts@@ -93,7 +93,7 @@ describe("Turbopuffer partner search provider", () => {expect(row.identityText).not.toContain(value);}// ContainsAllTokens reads the BM25 index, so no text attribute needs a- // filter index — and turbopuffer bills FTS + filterable at 200%.+ // filter index, and turbopuffer bills FTS + filterable at 200%.expect(schema.identityText.filterable).toBeUndefined();expect(schema.emailNgrams.filterable).toBeUndefined();expect(schema.programId).toMatchObject({ filterable: true });@@ -124,7 +124,7 @@ describe("Turbopuffer partner search provider", () => {it("pins a tokenizer that splits URLs into their components", async () => {// The default tokenizer keeps a URL as one token, so "scottdigital" cannot- // match "https://www.scottdigital-42.techcorp.io" — and websites, short+ // match "https://www.scottdigital-42.techcorp.io", and websites, short// links, and destination URLs are all searchable here.await createProvider().upsert([document]);