On this page
- Status: Accepted; D3 and the M3 deferral are SUPERSEDED by ADR 0017 (2026-07-23). Read D3 below as history: per-org column mapping for a sheet binding IS built —
mappingTemplateIdresolves to the org's mapping template and applies the sameapplyTemplatean upload does. The fixed product header maps remain correct for genuine fixed-vendor exports and are still in use; what changed is that they are no longer the ONLY option, so a customer with their own column names is a template, not a code change. Everything else in this ADR stands. - Superseded in part by ADR 0061 D8: the sheet-fed SocialTrend stream is replaced, for an org that holds the shared feed, by the platform connector's shared dataset; sheet bindings stay available for uploads.
- Date: 2026-07-20
- Context owner: Platform
- Related: ADR 0008 (marketing family), ADR 0013 (org credential store), §10/§34/§41 (ICT), §15 (mapping is data), §27 (chunked bulk), §44 (PII verbatim+mask), §46 (rollup consumer), §53 (reconciliation), §57 (three planes), §62 (no vendor names in user copy), §68 (NULLS NOT DISTINCT)
Context#
YouNet Media (org younet-media) feeds three product exports into one Google Sheet
(1mSoBZY68…), shared read-only with the same service account the org's GA4/GSC connectors
use. Live tab schemas were probed 2026-07-20:
| Tab | Rows | Content |
|---|---|---|
SocialTrend by Topic |
~1k | top posts per trending topic |
SocialTrend Ranking Hourly |
~2.4k | hourly trend-ranking snapshots |
SocialHeat ynm |
~7k | social mentions (posts/news, HTML content, sentiment) |
CRM_ |
~1k | website lead-form submissions (PII, UTM, MPL/MQL) |
CRM_ |
~51k | CRM leads + deal/contract VND amounts (dirty: #N/ strings, Excel serial dates, trailing junk cols) |
CRM_ |
~12k | campaign/minigame leads (Vietnamese headers) |
Current state: the google-sheets connector already supports N tab→stream bindings in its
CONFIG (bindings.max(20), 12 canon streams incl. crm_lead), but the UI hard-codes one
binding with two streams and the worker routes everything that is not ad_spend into
budget_plans. SocialTrend has zero backing infrastructure (display-only catalog node);
SocialHeat has a file parser + listening tables; CRM tables + two dashboards exist but YNM
runs on is_sample demo rows.
Decision#
D1 — Connector shape follows the DATA PLANE, transport is shared
Sheet reading (SA auth → tab enumeration → range reads → header-mapped rows) is a shared
transport in @yng/connector-google-sheets/@yng/connectors-core. On top of it:
- CRM stays on the 1st-party marketing plane → the existing
google-sheetsconnector (familymarketing) generalized: the operator adds bindingsCRM_LeadForm → crm_lead_form,CRM_RawLead → crm_raw_lead,CRM_CampaignLead → crm_campaign_lead. - SocialHeat and SocialTrend are their own connector types (
socialheat,socialtrend; familymarket_intel,thirdPartyData: true, dependsOnsocial-intelligence), whose transport is the shared sheet reader and whose credential is the sharedgoogle_service_account(ADR 0013). Rationale: §57 — a marketing-family connector must not emit 3rd-party listening streams; and the connector topology already models them as distinct nodes.
D2 — Worker dispatch is a table, not a fork
syncGoogleSheets's binary if ad_spend / else budget_plan becomes a declarative
STREAM_SINKS: Record<TargetStream, {schema, upsert}> map covering every wired stream with
per-stream accounting (rowsPromoted per stream, misconfigured binding → rejected rows with
reasons, permanent-vs-transient per §56). Unwired stream in a binding = validation error at
create time, not silent budget rows.
D3 — Fixed product-export headers are mapping DATA (§15)
These tabs are product export formats with stable headers (incl. Vietnamese). Each new stream
declares a versioned header map + row transform in the connector package (typed, tested,
tolerant of the observed dirt: #N/A (…) → null, Excel serial dates → ICT dates, trailing
junk columns ignored, numbers-as-phone → verbatim text). No per-org conditionals.
D4 — New tables (all org-scoped, is_sample, §68 keys, §27 chunked)
| Table | Grain / natural key | Notes |
|---|---|---|
social_ |
(org, snapshot_at, topic_external_id) | rank, buzz/likes/shares/comments, sentiment as signed bp int, status, passion_point, ranking ICT day, image URL |
social_ |
(org, post_external_id) | topic FK-by-id, engagement ints, description, platform slug, author, created_at ICT |
social_ |
(org, mention_external_id) | verbatim content/title/link/author (§44), tags/attributes jsonb, sentiment int, counts |
| CRM | reuse crm_ (+ crm_ for RawLead deal/contract VND bigint §2) |
provider sheet, per-tab source; full row in raw_; PII masked at display |
Every sink reaches a rollup consumer (§46): mentions aggregate into the existing
social_listening_* daily tables (additive per ICT day, §52); trend rankings serve their
surface directly (hourly snapshot grain IS the rollup); CRM flows into the existing
marketing-leads metrics.
D5 — Binding UX: enumerate real tabs
Connector create/edit gains a proper multi-binding editor: after credentials + spreadsheet id
are testable, the UI enumerates live tab names (metadata ping) and the operator picks
tab → loại dữ liệu per row. Bindings become editable post-create (today they are frozen).
D6 — YNM wiring replaces demo rows
The wiring script (scripts/ops/wire-connector.ts, parameterized by org; it replaced the
per-customer wire-*-ynm.ts one-offs in 2026-09) creates/repoints the three connectors on the
shared SA credential; the org's is_sample demo rows are cleared, a full historical sync runs
(chunked reads over the 51k-row tab), and materializations are refreshed. Dashboards
(/marketing-performance/leads, /lead-marketing, /social-intelligence/listening, new
trend surface) then render REAL ingested data. §53: each new metric-bearing surface adds a
reconciliation assertion; ground truth = the sheet itself (row counts + spot sums per §55).
D7 — Naming (§62)
User-facing titles are Vietnamese noun phrases (Xu hướng mạng xã hội, Lắng nghe mạng xã hội, Khách hàng tiềm năng); SocialHeat/SocialTrend appear only as small source badges
and on connector-config screens.
Consequences#
- The google-sheets connector becomes the platform's generic "spreadsheet → any wired stream" ingester; new sheet-fed data kinds are a stream declaration + sink registration, not a new connector.
- Hourly-grain trend data introduces the first intraday time series on the social plane —
charts stay §39-compliant (server ISO strings, category axis; hour grain is genuinely
intraday so
type:'time'+useUTCrules apply where used). - The 51k-row tab sets the chunking bar: range-paged reads +
bulkInsertChunked-style upserts; sync must stay idempotent under NULLS NOT DISTINCT keys (§68). - Deferred: mappingTemplateId-driven custom column mapping (M3) stays reserved; per-org header overrides are NOT built until a second org needs a different export shape.