mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(enrichment): stop PDL billing on no-match via required-field gating (#5184)
PDL bills per matched profile, but each cascade only counts a hit when mapOutput yields a specific field. A confident profile (likelihood >= 6) lacking that field was billed yet recorded as no_match. Pass PDL's required param so it 404s (free) when the extracted field is absent, aligning PDL's billing unit with the cascade's success unit.
This commit is contained in:
@@ -22,7 +22,7 @@ describe('company-domain enrichment cascade', () => {
|
||||
const p = provider('pdl')
|
||||
it('matches by name and normalizes the returned website', () => {
|
||||
expect(p.toolId).toBe('pdl_company_enrich')
|
||||
expect(p.buildParams(nameInput)).toEqual({ name: 'Acme Inc' })
|
||||
expect(p.buildParams(nameInput)).toEqual({ name: 'Acme Inc', required: 'website' })
|
||||
expect(p.buildParams({ companyName: '' })).toBeNull()
|
||||
expect(p.mapOutput({ company: { website: 'https://www.acme.com' } })).toEqual({
|
||||
domain: 'acme.com',
|
||||
|
||||
@@ -21,7 +21,9 @@ export const companyDomainEnrichment: EnrichmentConfig = {
|
||||
buildParams: (inputs) => {
|
||||
const name = str(inputs.companyName)
|
||||
if (!name) return null
|
||||
return { name }
|
||||
// `required` makes PDL 404 (free) when the match has no website,
|
||||
// instead of charging a credit for a match we'd discard as a no-match.
|
||||
return { name, required: 'website' }
|
||||
},
|
||||
mapOutput: (output) => {
|
||||
const company = output.company as Record<string, unknown> | undefined
|
||||
|
||||
@@ -45,7 +45,9 @@ export const companyInfoEnrichment: EnrichmentConfig = {
|
||||
buildParams: (inputs) => {
|
||||
const website = normalizeDomain(inputs.domain)
|
||||
if (!website) return null
|
||||
return { website }
|
||||
// `required` makes PDL 404 (free) when neither field we extract is
|
||||
// present, instead of charging a credit for a match we'd discard.
|
||||
return { website, required: 'employee_count OR summary' }
|
||||
},
|
||||
mapOutput: (output) => {
|
||||
const company = output.company as Record<string, unknown> | undefined
|
||||
|
||||
@@ -31,10 +31,13 @@ export const phoneNumberEnrichment: EnrichmentConfig = {
|
||||
buildParams: (inputs) => {
|
||||
const name = str(inputs.fullName)
|
||||
if (!name) return null
|
||||
// `required` makes PDL 404 (free) when the profile has no phone,
|
||||
// instead of charging a credit for a match we'd discard as a no-match.
|
||||
return filterUndefined({
|
||||
name,
|
||||
company: normalizeDomain(inputs.companyDomain) || undefined,
|
||||
min_likelihood: 6,
|
||||
required: 'phone_numbers OR mobile_phone',
|
||||
})
|
||||
},
|
||||
mapOutput: (output) => {
|
||||
|
||||
@@ -122,10 +122,13 @@ export const workEmailEnrichment: EnrichmentConfig = {
|
||||
buildParams: (inputs) => {
|
||||
const name = str(inputs.fullName)
|
||||
if (!name) return null
|
||||
// `required` makes PDL 404 (free) when the profile has no work email,
|
||||
// instead of charging a credit for a match we'd discard as a no-match.
|
||||
return filterUndefined({
|
||||
name,
|
||||
company: normalizeDomain(inputs.companyDomain) || undefined,
|
||||
min_likelihood: 6,
|
||||
required: 'work_email',
|
||||
})
|
||||
},
|
||||
mapOutput: (output) => {
|
||||
|
||||
Reference in New Issue
Block a user