@lssm-tech/integration.provider-analytics
Website: https://contractspec.io
Analytics provider implementations for ContractSpec.
Usage
Import the root entrypoint for the domain surface, or import a concrete implementation from the ./impls/* subpaths.
PosthogLssmPorts is the canonical initial adapter for the vendor-neutral analytics, OTel observability, error-reporting, feature-flag, and experiment ports. It defaults to PostHog EU, supports US and explicit self-hosted profiles, uses tenant/workspace groups, disables implicit flag exposure events, and buffers capture behind bounded retries and a circuit breaker. Secret, prompt, body, webhook/MCP payload, and personal fields are removed by default. Tenant, workspace, and organization identifiers are omitted from event properties; configured PostHog group keys remain available only as project-scoped pseudonyms. Unknown-consent non-personal capture requires an explicit property or targeting-attribute allowlist, normalizes sensitive-key aliases with Unicode compatibility folding before redaction, and pseudonymizes feature-flag subject keys before the provider boundary.
Manual errors now use PostHog's canonical $exception_list and
$exception_fingerprint fields without transmitting raw messages or stacks. Experiment allocations emit the canonical $feature_flag_called exposure event with $feature_flag and $feature_flag_response; the adapter no longer uses a legacy custom exposure event. PostHog remains an analysis projection and never satisfies Connect or promotion authority by itself.
Compatibility
This package owns the analytics implementation slice split out of @lssm-tech/integration.providers-impls. The legacy package continues to re-export these subpaths for existing consumers.
Marketing warehouse reports
impls/posthog-marketing-reports implements the library-owned metric report source. Its authority callback validates actor/brand/campaign access, authoritative metric source and freshness policy, then supplies a project-bound PosthogAnalyticsReader query method and a qualified projection name. All request values use HogQL placeholders.
The projection must expose tenant_id, workspace_id, brand_id, campaign_ref,
metric, grain, source, period_start, period_end and observation_json. The last column contains the complete MarketingObservation JSON contract, including attribution, currency, revision, coverage and evidence digest. Map native advertising imports into this versioned projection; preserve one owner per metric grain and source-event identity. Do not combine platform and first-party attribution in the same rows.
The reader rejects foreign scope, malformed rows, schema drift, explicit truncation and results above 10,000 rows. Split large reports into explicit qualified periods. Empty results remain missing in the reporting runtime. Installation-specific warehouse view creation, native-source mappings and live project qualification remain required.
HogQL constant binding follows the official query schema; this adapter reuses the existing query API reader and does not copy warehouse ingestion.
The pure-fetch PostHog client binds requests to its configured origin, rejects credential header overrides and redirects, and bounds response reads to 5 MB with a 30-second timeout. API errors expose status only; malformed success JSON fails instead of being returned as a typed result. HTTPS is required except for explicit loopback development.