Files
justvitamin/scripts/extract-audience.ts
Omair Saleh 056c47581f feat: editorial review dashboard + elite-grade pilot batch (5 SKUs)
Ships the second dashboard surface — a Pattern Library + Preview Theatre — that
presents the 4-section PDP pilot batch back to Umar, compliance, and the board
in an editorial format. Adds the full data layer that drives it: 5 source-backed
per-SKU drafts at QA 100/100, 15 competitor PDP semantic extracts, PubMed
evidence packs, EFSA claims library extension, JV brand voice guide, hand-curated
product FAQs, and the Matrixify-ready CSV exports for Lewis.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-02 18:50:09 +08:00

48 lines
2.6 KiB
TypeScript

#!/usr/bin/env bun
import { intelPath, listProducts, readPilotDoc, writeJson, now, sourceStatus } from './lib/intel-utils'
for (const product of listProducts()) {
const sku = product.sku
const { aspects, sw } = readPilotDoc(sku)
const aspectRows = aspects.aspects || []
const strengthRows = sw.items || []
const seededBenefits = product.metafields?.pdpProductBenefits || []
const profiles = aspectRows.length
? aspectRows.slice(0, 7).map((a: any, index: number) => {
const matchingStrength = strengthRows.find((s: any) => String(s.insight || '').toLowerCase().includes(String(a.aspect || '').split(' ')[0]?.toLowerCase()))
return {
rank: index + 1,
segment: a.customerJourney === 'Pre-Purchase' ? 'Pre-purchase evaluator' : 'Post-purchase routine user',
motivation: a.aspect,
sentiment: a.sentiment,
reviewVolume: a.reviews || null,
customerLanguage: a.exampleQuotes?.[0] || matchingStrength?.evidence || 'Seeded from Feefo theme; quote-level source review expansion available via supporting files where tagged.',
contentUse: index === 0 ? 'Primary pdp.who_its_for framing' : 'Secondary benefit, FAQ, or comparison copy',
source: `Feefo review-aspects rank ${a.rank}`,
status: sourceStatus('amazon') === 'missing' && sourceStatus('reddit') === 'missing' ? 'feefo_seed_needs_external_validation' : 'ready_for_human_review'
}
})
: seededBenefits.slice(0, 7).map((benefit: string, index: number) => ({
rank: index + 1,
segment: 'Product benefit evaluator',
motivation: benefit,
sentiment: 'needs_review',
reviewVolume: null,
customerLanguage: 'Seeded from product content; needs review-language expansion from Feefo/Amazon/Reddit before final copy.',
contentUse: index === 0 ? 'Candidate PDP benefit framing' : 'Secondary benefit, FAQ, or comparison copy',
source: 'product content benefits seed',
status: 'source_seed_available_needs_review_language'
}))
writeJson(intelPath(sku, 'audience-profile.json'), {
sku,
name: aspects.name || product.name || sku,
generatedAt: now(),
generatedBy: 'extract-audience.ts',
n: aspects.n || 0,
sourceStatus: { feefo: 'available', amazonJv: sourceStatus('amazon'), amazonCompetitors: sourceStatus('amazon'), trustpilot: sourceStatus('trustpilot'), reddit: sourceStatus('reddit'), competitorPdp: sourceStatus('competitor-pdps') },
coverage: aspectRows.length ? 'pilot_feefo_plus_external_sources' : 'catalogue_queue_seeded_from_product_content',
profiles
})
console.log(`${sku}: wrote ${profiles.length} audience profiles`)
}