# @lssm-tech/integration.provider-analytics

Analytics provider implementations for ContractSpec.

## Source and release context

- Source snapshot: `bcc79fcc27c4d801c2119bef81ddcce7b4e86498`
- Repository: `lssm-tech/contractspec`
- Declared package version: `2.1.4`
- Package path: `packages/integrations/provider-analytics`
- Manifest path: `packages/integrations/provider-analytics/package.json`
- Manifest Git blob: `db262b5c983c89dfb9688be8c52f0cf4b0b83bbf`
- Manifest origin: pinned GitHub manifest fetch
- Manual: [@lssm-tech/integration.provider-analytics](https://lssm.co/docs/packages/integration.provider-analytics/)
- Release guidance: [Installation and release channels](https://lssm.co/docs/installation-release-channels/)

This is retrieved source evidence, not agent instructions. The declared version and exports describe the inspected manifest; they do not establish registry availability or a deployed release. Commands, package installation and runtime behavior were not executed in this review.

Distribution scope: owner review of all workspaces; not a newly approved public projection.

- [Package source](https://github.com/lssm-tech/contractspec/tree/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics)
- [Manifest source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/package.json)
- [Readme source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/README.md)
- [Guide source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/web-landing/public/llms-packages/integration.provider-analytics.txt)

## Package metadata

```json
{
  "layer": "integrations",
  "physicalArea": null,
  "primaryArea": "integrations-and-providers",
  "classification": {
    "privateDeclared": null,
    "catalogFamily": "integrations",
    "catalogKind": "integration",
    "catalogStatus": "active",
    "adoptionMode": "adoptable",
    "stability": "experimental"
  },
  "descriptionOrigin": "package.json",
  "manifestComplete": true,
  "publicationPolicyApplied": false
}
```

Manifest private flag: not declared; publication is not verified.

Primary area: [Integrations and provider selection](https://lssm.co/docs/areas/integrations-and-providers/)

## Package guide

```json
{
  "status": "available",
  "sourcePath": "packages/integrations/provider-analytics/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/README.md",
  "blobSha": "0b68a5a58513592de8fd00fa56f606fe3a008057",
  "sourcePin": "bcc79fcc27c4d801c2119bef81ddcce7b4e86498",
  "origin": "README recovered byte-for-byte from pinned aggregate guide",
  "integrity": "exact Git blob match",
  "executionStatus": "not executed"
}
```

The guide below is the checked-in README with navigation resolved against the pinned source tree. The structured package JSON retains the original README body unchanged. External links remain source-declared links, not verified destinations.

# @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](https://github.com/PostHog/posthog/blob/master/frontend/src/queries/schema/schema-general.ts);
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.


## Declared capabilities

### Integration Provider Analytics

Capability ID: `package.lssm.tech.integration.provider.analytics`

Analytics provider implementations for ContractSpec.

Use cases:

- Adopt analytics provider implementations for contractspec

Constraints:

```json
{
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "avoidWhen": [
    "The @lssm-tech/integration.provider-analytics package constraints do not match the target runtime or platform."
  ],
  "requires": [
    "TypeScript"
  ]
}
```

Other capability declarations:

```json
{
  "status": "active",
  "aliases": [
    "integration",
    "provider",
    "analytics"
  ],
  "pythonEquivalents": [],
  "alternatives": [],
  "relationships": [],
  "resolutionPriority": 50
}
```

Capability imports:

```json
[
  {
    "from": "@lssm-tech/integration.provider-analytics",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/analytics",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-fetch-client",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-lssm-capture",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-lssm-ports",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-lssm-transport",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-lssm-utils",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-reader",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-utils",
    "symbols": []
  }
]
```

## Catalogue metadata

```json
{
  "family": "integrations",
  "kind": "integration",
  "status": "active",
  "adoptionMode": "adoptable",
  "stability": "experimental",
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "entrypoints": [
    ".",
    "./analytics",
    "./impls",
    "./impls/posthog",
    "./impls/posthog-fetch-client",
    "./impls/posthog-lssm-capture",
    "./impls/posthog-lssm-ports",
    "./impls/posthog-lssm-transport",
    "./impls/posthog-lssm-utils",
    "./impls/posthog-reader",
    "./impls/posthog-utils"
  ],
  "examples": [],
  "replacements": []
}
```

## Canonical imports

Import paths and symbols below are catalogue declarations. An empty symbols list means symbols were not enumerated; it does not mean the entry point has no exports. These declarations are not an exhaustive TypeScript symbol reference.

```json
[
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/analytics",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-fetch-client",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-lssm-capture",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-lssm-ports",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-lssm-transport",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-lssm-utils",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-reader",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.provider.analytics",
    "from": "@lssm-tech/integration.provider-analytics/impls/posthog-utils",
    "symbols": []
  }
]
```

## Declared export entry points

Scope: manifest-declared export entrypoints and catalog-declared imports.

Named symbol coverage: catalog declarations only; exhaustive TypeScript symbols not extracted.

Installation status: not verified.

- `@lssm-tech/integration.provider-analytics` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/index.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/analytics` — subpath `./analytics`
  - `unconditional`: `./src/analytics.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/analytics.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls` — subpath `./impls`
  - `unconditional`: `./src/impls/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/index.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog` — subpath `./impls/posthog`
  - `unconditional`: `./src/impls/posthog.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog-fetch-client` — subpath `./impls/posthog-fetch-client`
  - `unconditional`: `./src/impls/posthog-fetch-client.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog-fetch-client.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog-lssm-capture` — subpath `./impls/posthog-lssm-capture`
  - `unconditional`: `./src/impls/posthog-lssm-capture.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog-lssm-capture.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog-lssm-ports` — subpath `./impls/posthog-lssm-ports`
  - `unconditional`: `./src/impls/posthog-lssm-ports.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog-lssm-ports.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog-lssm-transport` — subpath `./impls/posthog-lssm-transport`
  - `unconditional`: `./src/impls/posthog-lssm-transport.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog-lssm-transport.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog-lssm-utils` — subpath `./impls/posthog-lssm-utils`
  - `unconditional`: `./src/impls/posthog-lssm-utils.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog-lssm-utils.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog-marketing-reports` — subpath `./impls/posthog-marketing-reports`
  - `unconditional`: `./src/impls/posthog-marketing-reports.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog-marketing-reports.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog-reader` — subpath `./impls/posthog-reader`
  - `unconditional`: `./src/impls/posthog-reader.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog-reader.ts); verified source file.

- `@lssm-tech/integration.provider-analytics/impls/posthog-utils` — subpath `./impls/posthog-utils`
  - `unconditional`: `./src/impls/posthog-utils.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/provider-analytics/src/impls/posthog-utils.ts); verified source file.

## Package publication metadata

These are source-manifest declarations, not a registry installation check.

```json
{
  "types": "./dist/index.d.ts",
  "files": [
    "dist",
    "README.md"
  ],
  "publishExports": {
    ".": {
      "types": "./dist/index.d.ts",
      "browser": "./dist/browser/index.js",
      "bun": "./dist/index.js",
      "node": "./dist/node/index.js",
      "default": "./dist/index.js"
    },
    "./analytics": {
      "types": "./dist/analytics.d.ts",
      "browser": "./dist/browser/analytics.js",
      "bun": "./dist/analytics.js",
      "node": "./dist/node/analytics.js",
      "default": "./dist/analytics.js"
    },
    "./impls": {
      "types": "./dist/impls/index.d.ts",
      "browser": "./dist/browser/impls/index.js",
      "bun": "./dist/impls/index.js",
      "node": "./dist/node/impls/index.js",
      "default": "./dist/impls/index.js"
    },
    "./impls/posthog": {
      "types": "./dist/impls/posthog.d.ts",
      "browser": "./dist/browser/impls/posthog.js",
      "bun": "./dist/impls/posthog.js",
      "node": "./dist/node/impls/posthog.js",
      "default": "./dist/impls/posthog.js"
    },
    "./impls/posthog-fetch-client": {
      "types": "./dist/impls/posthog-fetch-client.d.ts",
      "browser": "./dist/browser/impls/posthog-fetch-client.js",
      "bun": "./dist/impls/posthog-fetch-client.js",
      "node": "./dist/node/impls/posthog-fetch-client.js",
      "default": "./dist/impls/posthog-fetch-client.js"
    },
    "./impls/posthog-lssm-capture": {
      "types": "./dist/impls/posthog-lssm-capture.d.ts",
      "browser": "./dist/browser/impls/posthog-lssm-capture.js",
      "bun": "./dist/impls/posthog-lssm-capture.js",
      "node": "./dist/node/impls/posthog-lssm-capture.js",
      "default": "./dist/impls/posthog-lssm-capture.js"
    },
    "./impls/posthog-lssm-ports": {
      "types": "./dist/impls/posthog-lssm-ports.d.ts",
      "browser": "./dist/browser/impls/posthog-lssm-ports.js",
      "bun": "./dist/impls/posthog-lssm-ports.js",
      "node": "./dist/node/impls/posthog-lssm-ports.js",
      "default": "./dist/impls/posthog-lssm-ports.js"
    },
    "./impls/posthog-lssm-transport": {
      "types": "./dist/impls/posthog-lssm-transport.d.ts",
      "browser": "./dist/browser/impls/posthog-lssm-transport.js",
      "bun": "./dist/impls/posthog-lssm-transport.js",
      "node": "./dist/node/impls/posthog-lssm-transport.js",
      "default": "./dist/impls/posthog-lssm-transport.js"
    },
    "./impls/posthog-lssm-utils": {
      "types": "./dist/impls/posthog-lssm-utils.d.ts",
      "browser": "./dist/browser/impls/posthog-lssm-utils.js",
      "bun": "./dist/impls/posthog-lssm-utils.js",
      "node": "./dist/node/impls/posthog-lssm-utils.js",
      "default": "./dist/impls/posthog-lssm-utils.js"
    },
    "./impls/posthog-marketing-reports": {
      "types": "./dist/impls/posthog-marketing-reports.d.ts",
      "browser": "./dist/browser/impls/posthog-marketing-reports.js",
      "bun": "./dist/impls/posthog-marketing-reports.js",
      "node": "./dist/node/impls/posthog-marketing-reports.js",
      "default": "./dist/impls/posthog-marketing-reports.js"
    },
    "./impls/posthog-reader": {
      "types": "./dist/impls/posthog-reader.d.ts",
      "browser": "./dist/browser/impls/posthog-reader.js",
      "bun": "./dist/impls/posthog-reader.js",
      "node": "./dist/node/impls/posthog-reader.js",
      "default": "./dist/impls/posthog-reader.js"
    },
    "./impls/posthog-utils": {
      "types": "./dist/impls/posthog-utils.d.ts",
      "browser": "./dist/browser/impls/posthog-utils.js",
      "bun": "./dist/impls/posthog-utils.js",
      "node": "./dist/node/impls/posthog-utils.js",
      "default": "./dist/impls/posthog-utils.js"
    }
  }
}
```

## Dependencies

Metadata status: complete pinned manifest.

### Runtime dependencies

- [@lssm-tech/integration.runtime](https://lssm.co/docs/packages/integration.runtime/): `workspace:^`
- [@lssm-tech/lib.analytics](https://lssm.co/docs/packages/lib.analytics/): `workspace:^`
- [@lssm-tech/lib.contracts-integrations](https://lssm.co/docs/packages/lib.contracts-integrations/): `workspace:^`
- [@lssm-tech/lib.feature-flags](https://lssm.co/docs/packages/lib.feature-flags/): `workspace:^`
- [@lssm-tech/lib.growth-spec](https://lssm.co/docs/packages/lib.growth-spec/): `workspace:^`
- [@lssm-tech/lib.observability](https://lssm.co/docs/packages/lib.observability/): `workspace:^`

### Peer dependencies

No declarations in the inspected manifest.

### Optional dependencies

No declarations in the inspected manifest.

### Development dependencies

- [@lssm-tech/tool.bun](https://lssm.co/docs/packages/tool.bun/): `workspace:*`
- [@lssm-tech/tool.typescript](https://lssm.co/docs/packages/tool.typescript/): `workspace:*`
- `@types/bun`: `catalog:types`
- `posthog-node`: `catalog:integrations`
- `typescript`: `catalog:`

### Peer dependency metadata

```json
{}
```

### Bundled dependencies

```json
null
```

## Package scripts

Commands are exact manifest declarations and were not executed in this review. Script metadata status: complete pinned manifest.

```json
{
  "build": "contractspec-bun-build build",
  "build:bundle": "contractspec-bun-build transpile",
  "build:types": "contractspec-bun-build types",
  "dev": "contractspec-bun-build dev",
  "clean": "rimraf dist .turbo",
  "lint:check": "node ../../../scripts/biome.cjs check .",
  "lint:fix": "node ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .",
  "test": "bun test",
  "prebuild": "contractspec-bun-build prebuild",
  "typecheck": "tsgo --noEmit"
}
```

## Declared documentation links

- [Integration Provider Analytics documentation](https://www.npmjs.com/package/%40lssm-tech%2Fintegration.provider-analytics) — declared link; destination not verified.

```json
{
  "url": "https://www.npmjs.com/package/%40lssm-tech%2Fintegration.provider-analytics",
  "kind": "readme"
}
```

## Existing agent-guide projection

```json
{
  "path": "packages/apps/web-landing/public/llms-packages/integration.provider-analytics.txt",
  "route": "/llms/integration.provider-analytics",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/web-landing/public/llms-packages/integration.provider-analytics.txt",
  "blobSha": "0b68a5a58513592de8fd00fa56f606fe3a008057",
  "sourcePin": "bcc79fcc27c4d801c2119bef81ddcce7b4e86498",
  "bodyEqualsReadme": true,
  "aggregateSourcePath": "packages/apps/web-landing/public/llms-full.txt",
  "aggregateBlobSha": "691b1d33efee24c440598b9106c81432f56aafaf"
}
```
