The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Lower PDL enrichment prices (#28516)
Raphaël Bosi0e886f7e7953
diff --git a/packages/twenty-apps/public/people-data-labs/CHANGELOG.md b/packages/twenty-apps/public/people-data-labs/CHANGELOG.mdindex f6536865199..69dc711daad 100644--- a/packages/twenty-apps/public/people-data-labs/CHANGELOG.md+++ b/packages/twenty-apps/public/people-data-labs/CHANGELOG.md@@ -2,6 +2,10 @@All notable changes to this application are documented in this file.+## 1.3.0++- Lower enrichment prices to $0.15 per person match and $0.075 per company match.+## 1.2.0- Move the minimum match likelihoods for people and companies from serverdiff --git a/packages/twenty-apps/public/people-data-labs/README.md b/packages/twenty-apps/public/people-data-labs/README.mdindex 6babfc362c3..40e73411885 100644--- a/packages/twenty-apps/public/people-data-labs/README.md+++ b/packages/twenty-apps/public/people-data-labs/README.md@@ -12,5 +12,5 @@Pay only for matches, in Twenty credits — **not found and skipped records are free.**-- **Person match:** $0.336-- **Company match:** $0.12+- **Person match:** $0.15+- **Company match:** $0.075diff --git a/packages/twenty-apps/public/people-data-labs/package.json b/packages/twenty-apps/public/people-data-labs/package.jsonindex 6289bb71ae6..f66f6ef57df 100644--- a/packages/twenty-apps/public/people-data-labs/package.json+++ b/packages/twenty-apps/public/people-data-labs/package.json@@ -1,6 +1,6 @@{"name": "@twentyhq/people-data-labs",- "version": "1.2.0",+ "version": "1.3.0","description": "People Data Labs enrichment app for Twenty","license": "MIT","engines": {diff --git a/packages/twenty-apps/public/people-data-labs/src/application-config.ts b/packages/twenty-apps/public/people-data-labs/src/application-config.tsindex 8bdfd5107f3..1f2aa34552c 100644--- a/packages/twenty-apps/public/people-data-labs/src/application-config.ts+++ b/packages/twenty-apps/public/people-data-labs/src/application-config.ts@@ -21,7 +21,7 @@ export default defineApplication({galleryImages: ['public/gallery/cover.png'],billing: {description:- '$0.336 per person match and $0.12 per company match. Not found and skipped records are free. Billed to your Twenty credits.',+ '$0.15 per person match and $0.075 per company match. Not found and skipped records are free. Billed to your Twenty credits.',},applicationVariables: {[PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME]: {diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/billing-margin-multiplier.ts b/packages/twenty-apps/public/people-data-labs/src/constants/billing-margin-multiplier.tsdeleted file mode 100644index 2a54c45b84d..00000000000--- a/packages/twenty-apps/public/people-data-labs/src/constants/billing-margin-multiplier.ts+++ /dev/null@@ -1 +0,0 @@-export const BILLING_MARGIN_MULTIPLIER = 1.2;diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/company-match-cost-dollars.ts b/packages/twenty-apps/public/people-data-labs/src/constants/company-match-cost-dollars.tsdeleted file mode 100644index 1ef85bd35d3..00000000000--- a/packages/twenty-apps/public/people-data-labs/src/constants/company-match-cost-dollars.ts+++ /dev/null@@ -1 +0,0 @@-export const COMPANY_MATCH_COST_DOLLARS = 0.1;diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/company-match-price-dollars.ts b/packages/twenty-apps/public/people-data-labs/src/constants/company-match-price-dollars.tsnew file mode 100644index 00000000000..d3cab94667d--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/company-match-price-dollars.ts@@ -0,0 +1 @@+export const COMPANY_MATCH_PRICE_DOLLARS = 0.075;diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/person-match-cost-dollars.ts b/packages/twenty-apps/public/people-data-labs/src/constants/person-match-cost-dollars.tsdeleted file mode 100644index 8c612e15f46..00000000000--- a/packages/twenty-apps/public/people-data-labs/src/constants/person-match-cost-dollars.ts+++ /dev/null@@ -1 +0,0 @@-export const PERSON_MATCH_COST_DOLLARS = 0.28;diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/person-match-price-dollars.ts b/packages/twenty-apps/public/people-data-labs/src/constants/person-match-price-dollars.tsnew file mode 100644index 00000000000..5254802c959--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/person-match-price-dollars.ts@@ -0,0 +1 @@+export const PERSON_MATCH_PRICE_DOLLARS = 0.15;diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/company-enrichment-adapter.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/company-enrichment-adapter.tsindex 44f2c5bd8b3..d22db67d6bf 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/company-enrichment-adapter.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/company-enrichment-adapter.ts@@ -1,4 +1,4 @@-import { COMPANY_MATCH_COST_DOLLARS } from 'src/constants/company-match-cost-dollars';+import { COMPANY_MATCH_PRICE_DOLLARS } from 'src/constants/company-match-price-dollars';import { PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-min-likelihood-env-var-name';import { PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name';import { buildCompanyMatchedData } from 'src/logic-functions/utils/build-company-matched-data';@@ -20,7 +20,7 @@ export const companyEnrichmentAdapter: BatchEnrichmentAdapter<objectNameSingular: 'Company',noIdentifierMessage:'No usable identifier (domain, LinkedIn, or name) to match against PDL.',- costPerMatchDollars: COMPANY_MATCH_COST_DOLLARS,+ pricePerMatchDollars: COMPANY_MATCH_PRICE_DOLLARS,minLikelihoodEnvVarName: PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME,weakIdentifierMinLikelihoodEnvVarName:PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/person-enrichment-adapter.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/person-enrichment-adapter.tsindex b820782deb3..73037a38446 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/person-enrichment-adapter.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/person-enrichment-adapter.ts@@ -1,6 +1,6 @@import { PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-person-min-likelihood-env-var-name';import { PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-person-weak-identifier-min-likelihood-env-var-name';-import { PERSON_MATCH_COST_DOLLARS } from 'src/constants/person-match-cost-dollars';+import { PERSON_MATCH_PRICE_DOLLARS } from 'src/constants/person-match-price-dollars';import { buildPersonMatchedData } from 'src/logic-functions/utils/build-person-matched-data';import { enrichPeople } from 'src/logic-functions/utils/enrich-people';import { extractPersonMatchParams } from 'src/logic-functions/utils/extract-person-match-params';@@ -20,7 +20,7 @@ export const personEnrichmentAdapter: BatchEnrichmentAdapter<objectNameSingular: 'Person',noIdentifierMessage:'No usable identifier (email, LinkedIn, PDL id, or name paired with a company) to match against PDL.',- costPerMatchDollars: PERSON_MATCH_COST_DOLLARS,+ pricePerMatchDollars: PERSON_MATCH_PRICE_DOLLARS,minLikelihoodEnvVarName: PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME,weakIdentifierMinLikelihoodEnvVarName:PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/charge-matched-enrichments.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/charge-matched-enrichments.test.tsindex e10d798b3f3..73af843de41 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/charge-matched-enrichments.test.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/charge-matched-enrichments.test.ts@@ -1,8 +1,8 @@import { beforeEach, describe, expect, it, vi } from 'vitest';import { chargeCredits } from 'twenty-sdk/billing';-import { COMPANY_MATCH_COST_DOLLARS } from 'src/constants/company-match-cost-dollars';-import { PERSON_MATCH_COST_DOLLARS } from 'src/constants/person-match-cost-dollars';+import { COMPANY_MATCH_PRICE_DOLLARS } from 'src/constants/company-match-price-dollars';+import { PERSON_MATCH_PRICE_DOLLARS } from 'src/constants/person-match-price-dollars';import { chargeMatchedEnrichments } from 'src/logic-functions/utils/charge-matched-enrichments';vi.mock('twenty-sdk/billing', () => ({@@ -14,30 +14,30 @@ describe('chargeMatchedEnrichments', () => {vi.clearAllMocks();});- it('charges person matches at PDL list price plus margin', async () => {+ it('charges 15 cents per person match', async () => {await chargeMatchedEnrichments({matchedCount: 3,- costPerMatchDollars: PERSON_MATCH_COST_DOLLARS,+ pricePerMatchDollars: PERSON_MATCH_PRICE_DOLLARS,resourceContext: 'pdl/person',});expect(chargeCredits).toHaveBeenCalledExactlyOnceWith({- creditsUsedMicro: 3 * 336_000,+ creditsUsedMicro: 450_000,operationType: 'CODE_EXECUTION',quantity: 3,resourceContext: 'pdl/person',});});- it('charges company matches at PDL list price plus margin', async () => {+ it('charges 7.5 cents per company match', async () => {await chargeMatchedEnrichments({matchedCount: 2,- costPerMatchDollars: COMPANY_MATCH_COST_DOLLARS,+ pricePerMatchDollars: COMPANY_MATCH_PRICE_DOLLARS,resourceContext: 'pdl/company',});expect(chargeCredits).toHaveBeenCalledExactlyOnceWith({- creditsUsedMicro: 2 * 120_000,+ creditsUsedMicro: 150_000,operationType: 'CODE_EXECUTION',quantity: 2,resourceContext: 'pdl/company',@@ -47,7 +47,7 @@ describe('chargeMatchedEnrichments', () => {it('does not charge when nothing matched', async () => {await chargeMatchedEnrichments({matchedCount: 0,- costPerMatchDollars: PERSON_MATCH_COST_DOLLARS,+ pricePerMatchDollars: PERSON_MATCH_PRICE_DOLLARS,resourceContext: 'pdl/person',});diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-batch-enrichment.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-batch-enrichment.test.tsindex 723af4735d0..7ace08d6423 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-batch-enrichment.test.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-batch-enrichment.test.ts@@ -16,8 +16,8 @@ vi.mock('twenty-sdk/billing', () => ({chargeCredits: vi.fn(async () => undefined),}));-const FAKE_COST_PER_MATCH_DOLLARS = 0.1;-const FAKE_CREDITS_PER_MATCH_MICRO = 120_000;+const FAKE_PRICE_PER_MATCH_DOLLARS = 0.075;+const FAKE_CREDITS_PER_MATCH_MICRO = 75_000;type FakeNode = {id: string;@@ -114,7 +114,7 @@ const buildHarness = (configs: RecordConfig[]) => {const adapter: BatchEnrichmentAdapter<FakeNode, FakeData, FakeParams> = {objectNameSingular: 'Test',noIdentifierMessage: 'no identifier',- costPerMatchDollars: FAKE_COST_PER_MATCH_DOLLARS,+ pricePerMatchDollars: FAKE_PRICE_PER_MATCH_DOLLARS,minLikelihoodEnvVarName: PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME,weakIdentifierMinLikelihoodEnvVarName:PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/charge-matched-enrichments.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/charge-matched-enrichments.tsindex 8d603ecaeb0..115499dc0e1 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/charge-matched-enrichments.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/charge-matched-enrichments.ts@@ -1,15 +1,14 @@import { chargeCredits } from 'twenty-sdk/billing';-import { BILLING_MARGIN_MULTIPLIER } from 'src/constants/billing-margin-multiplier';import { MICRO_CREDITS_PER_DOLLAR } from 'src/constants/micro-credits-per-dollar';export const chargeMatchedEnrichments = async ({matchedCount,- costPerMatchDollars,+ pricePerMatchDollars,resourceContext,}: {matchedCount: number;- costPerMatchDollars: number;+ pricePerMatchDollars: number;resourceContext: string;}): Promise<void> => {if (matchedCount === 0) {@@ -17,7 +16,7 @@ export const chargeMatchedEnrichments = async ({}const creditsPerMatchMicro = Math.round(- costPerMatchDollars * BILLING_MARGIN_MULTIPLIER * MICRO_CREDITS_PER_DOLLAR,+ pricePerMatchDollars * MICRO_CREDITS_PER_DOLLAR,);await chargeCredits({diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/enrich-chunk.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/enrich-chunk.tsindex 0fbc76a63b5..4c917a022d5 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/enrich-chunk.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/enrich-chunk.ts@@ -296,7 +296,7 @@ export const enrichChunk = async <TNode, TData, TParams>({matchedCount: pdlEnrichmentOutcomes.filter((enrichmentOutcome) => enrichmentOutcome?.outcome === 'matched',).length,- costPerMatchDollars: adapter.costPerMatchDollars,+ pricePerMatchDollars: adapter.pricePerMatchDollars,resourceContext: `pdl/${adapter.objectNameSingular.toLowerCase()}`,});diff --git a/packages/twenty-apps/public/people-data-labs/src/types/batch-enrichment-adapter.ts b/packages/twenty-apps/public/people-data-labs/src/types/batch-enrichment-adapter.tsindex cd74513f68b..61309dbce88 100644--- a/packages/twenty-apps/public/people-data-labs/src/types/batch-enrichment-adapter.ts+++ b/packages/twenty-apps/public/people-data-labs/src/types/batch-enrichment-adapter.ts@@ -7,7 +7,7 @@ import { type PdlEnrichResult } from 'src/types/pdl-enrich-result';export type BatchEnrichmentAdapter<TNode, TData, TParams> = {objectNameSingular: string;noIdentifierMessage: string;- costPerMatchDollars: number;+ pricePerMatchDollars: number;minLikelihoodEnvVarName: string;weakIdentifierMinLikelihoodEnvVarName: string;readRecords: (args: {