# Contribute a preset

> Write a provider preset for the consent-kit catalogue: source every fact, write the fixture, version it correctly and open the pull request.

Write a provider preset for the consent-kit catalogue: source every fact, write the fixture, version it correctly and open the pull request.

A preset is one file in `packages/presets/src/catalogue/` that exports a `PresetDefinition`, listed in `packages/presets/src/catalogue/index.ts`. `acme-analytics.ts` in that folder is the reference: copy it. The format is in the [presets reference](/docs/manual/reference/presets/#preset-definition).

## The sourcing rule

**Facts about a vendor come from the vendor's own published documentation. Never from memory, a blog post, another consent tool's database or a language model.**

This covers the legal entity, the country, the transfer mechanism, DPA and privacy links, script URLs, cookie names and lifetimes, storage keys and endpoints.

For every fact:

1. Open the vendor's page that states it. Put that URL in `source`. One URL per fact, the most specific page there is: the imprint for the legal entity, the cookie reference for a cookie.
2. If the page says what you are declaring, set `verified: true` and `checkedOn` to today's date. Put the quote, or what exactly the page says, in `note` when it is not obvious.
3. If you could not find the fact stated, or the page says something weaker than what you declare, set `verified: false` and say in `note` what is open.
4. Do not declare what you cannot source at all.

An honest `verified: false` is welcome. An unsourced `verified: true` gets the pull request rejected. A preset that declares less is better than one that guesses: the audit of an adopting site reports whatever is missing, with a ready-to-paste entry.

`verified` on a fact means that a person read it on the cited page on that day. It does not mean anyone watched the tool do it. That is what the fixture and `status` are for.

Things that are not facts and need no source: the default ids, the parameter names, the purpose slot names, the summary.

## 1. Start the file

```ts
import type { PresetDefinition } from '@consent-kit/schema';

/** The day the cited pages were read. */
const CHECKED = '2026-11-27';

export const plausible: PresetDefinition = {
  id: 'plausible',
  version: '1.0.0',
  status: 'draft',
  name: 'Plausible Analytics',
  summary: 'Plausible Analytics on plausible.io: one script and one event endpoint. Documented as setting no cookies and writing no browser storage.',
  docs: 'https://plausible.io/docs',
  // parameters, purposes, processor, artefacts, statements, fixture
};
```

Every new preset ships as `status: 'draft'`. Say in a comment what the preset does not cover: the `plausible` preset names self-hosted installations and the legacy snippet.

## 2. Parameters

A parameter is a value the adopting project supplies. It is used as a `${name}` placeholder in string values.

```ts
parameters: {
  script: {
    description: "File name of your site's personalised script, from the snippet in your Plausible site settings",
    type: 'string',
    pattern: '^[A-Za-z0-9._-]+\\.js$',
    example: 'pa-XXXXX.js',
  },
},
```

`type` is `origin` (scheme, host and optional port, no path), `host` (a bare host name) or `string` (anything matching `pattern`). A parameter without a `default` is required. `example` must be a valid value: it is used for documentation and for expanding the preset in tests.

## 3. Purpose slots

A slot is a role the preset's artefacts play. The adopting project binds each slot to one of its own purposes.

```ts
purposes: {
  analytics: {
    description: 'counting page views and returning visitors',
    expectedBasis: 'consent',
    basisReason: 'the tag stores a visitor id cookie and a localStorage key on the device',
  },
},
```

**A preset never sets a lawful basis.** A slot may declare `expectedBasis` with a `basisReason` when the artefacts in it leave little room, typically `consent` because the tool stores or reads an identifier on the device. A mismatch is a warning to the project, not an error.

When the vendor documents that nothing is stored on the device, leave `expectedBasis` out. Do not encode an opinion about legitimate interest. The `plausible` preset expects no basis for that reason.

## 4. The processor

```ts
processor: {
  declares: {
    id: 'plausible',
    name: 'Plausible Analytics',
    legalEntity: 'Plausible Insights OÜ',
    country: 'EE',
    dpaUrl: 'https://plausible.io/dpa',
    privacyUrl: 'https://plausible.io/privacy',
  },
  facts: {
    legalEntity: { source: IMPRINT, verified: true, checkedOn: CHECKED, note: 'Imprint: "Plausible Insights OÜ", …' },
    country: { source: IMPRINT, verified: true, checkedOn: CHECKED, note: 'Estonia (EU), so no transfer mechanism is declared. …' },
    dpaUrl: { source: 'https://plausible.io/dpa', verified: true, checkedOn: CHECKED },
    privacyUrl: { source: 'https://plausible.io/privacy', verified: true, checkedOn: CHECKED },
  },
},
```

Give one fact for every declared field other than `id` and `name`. Declare `role` only when the vendor's own documents state it; otherwise leave it out, and the registry default (`processor`) applies until a project that knows better overrides it. For a vendor outside the EU/EEA, `transferMechanism` is a fact like any other and needs its source.

## 5. The artefacts

Each artefact is written as it will appear in a registry, with three differences: `id` is the default id, `purposes` lists slots of this preset, and `processor` is left out.

```ts
artefacts: [
  {
    declares: { id: 'plausible_script', kind: 'script', src: 'https://plausible.io/js/${script}', purposes: ['analytics'] },
    source: PROXY_GUIDE,
    verified: true,
    checkedOn: CHECKED,
    note: 'The guide gives "https://plausible.io/js/pa-XXXXX.js" as "the personalized location for your site\'s script". …',
  },
  {
    declares: { id: 'plausible_event', kind: 'endpoint', url: 'https://plausible.io/api/event', purposes: ['analytics'] },
    source: EVENTS_API,
    verified: true,
    checkedOn: CHECKED,
  },
],
```

Give cookies and storage keys a visitor-facing `description` in English and German. A project whose locale the preset lacks gets the warning `preset/missing-locale`.

Claims that are not artefacts go under `statements`, each with its own source:

```ts
statements: [
  {
    text: 'Sets no cookies and writes nothing to localStorage or the browser cache; the script only reads the plausible_ignore localStorage flag.',
    source: DATA_POLICY,
    verified: true,
    checkedOn: CHECKED,
  },
],
```

## 6. The fixture

A fixture says how to load the tool on an otherwise empty page and which artefacts a plain page view must produce. It is a descriptor, not a script.

```ts
fixture: {
  with: { origin: 'http://127.0.0.1:4174' },
  head: '<script src="${origin}/analytics.js"></script>',
  expect: ['acme_script', 'acme_id', 'acme_last_page', 'acme_collect'],
  lastRun: null,
},
```

- `head` is the vendor's own install snippet, as documented, with `${parameter}` placeholders. Cite where it came from in `fixture.note`.
- `with` holds values the run can use. If the tool needs a real account (a site id, a key), put a placeholder there and say so in `note`. The real value is passed at run time and never committed.
- `expect` lists the default ids a plain page view must produce. Artefacts that need an interaction stay out.

Run it before you open the pull request:

```ts
import { plausible } from '@consent-kit/presets';
import { runPresetFixture } from '@consent-kit/audit';

console.log(await runPresetFixture(plausible, { against: 'live', with: { script: 'pa-<your site>.js' } }));
```

`runPresetFixture` serves the page from a throw-away local server, opens it in Chromium with the audit's own recorder, and compares what the browser did with what the preset declares:

| Result field | Meaning |
| --- | --- |
| `missing` | Expected artefacts that were not observed. The declaration may be stale. |
| `undeclared` | Anything else the tool did, each with a ready-to-paste registry entry: a new cookie, storage key or origin. |
| `attributeDrift` | Declared cookies whose attributes differ, such as a longer lifetime. |

Paste the result into the pull request. If you could not run it, say so and say why. The `plausible` fixture has never been run; its `note` says what it still needs.

## 7. Register it

1. Export the definition from `packages/presets/src/catalogue/index.ts` and add it to `catalogue`.
2. Add a row to the catalogue table in `packages/presets/README.md`.
3. Run the tests:

```sh
pnpm vitest run packages/presets
```

## Draft to verified

A preset becomes `verified` when both hold:

1. every fact has `verified: true`;
2. its fixture ran green against the **live vendor**: `runPresetFixture(preset, { against: 'live', with: … })` returned `ok: true`, and `fixture.lastRun` records `{ date, against: 'live', result: 'pass' }`.

A catalogue test enforces this: a preset with `status: 'verified'` and an unverified fact or no live run fails the build. Moving to `verified` is a patch release of the preset, because nothing a registry receives changes.

`synthetic: true` is only for vendors that do not exist, such as the example's Acme Analytics. Their sources are files in the repository and their fixture runs offline in the test suite.

Until a preset is verified, `consent-kit check` flags it on every run of every project that adopts it.

## Versioning

Presets follow semver. `checkPresetBump(previous, next)` decides the smallest allowed step by expanding both versions into registries and diffing them with the same rule that classifies a project's own changes.

| Step | When |
| --- | --- |
| **major** | Any change classified `material` or `needs_review`: a new cookie, storage key, script or endpoint; a longer lifetime; a new origin; another legal entity or country; reworded visitor-facing text. Also anything that stops existing registries from resolving: a new required parameter, a removed parameter, a new or removed purpose slot, a removed or renamed default id. |
| **minor** | Any other change to what a registry ends up containing: a shorter cookie lifetime, a text that changed only in case, spacing or punctuation. |
| **patch** | Nothing a registry receives changes: sources, notes, `verified` flags, `status`, the fixture, the summary. |

The reason for the major rule: a project pins a major (`version: 1`). Whatever it receives within that major must never, by itself, require asking its visitors again.

To release a new version, **add** a new definition and keep the old one in the catalogue. Old versions stay resolvable for projects pinned to an exact version, and the test `checkCatalogueHistory(catalogue)` compares every version with its predecessor and fails when a step is too small.

## Checklist

- [ ] One file in `src/catalogue/`, listed in `src/catalogue/index.ts` and in the README's catalogue table.
- [ ] `status: 'draft'`.
- [ ] Every processor field (except `id`, `name`) and every artefact has a `source` on the vendor's own site.
- [ ] `verified: true` only where you read it there; `checkedOn` set; everything else `verified: false` with a `note`.
- [ ] No lawful basis set; `expectedBasis` only with a `basisReason`.
- [ ] Visitor-facing descriptions in English and German.
- [ ] A fixture, and the output of a local run in the pull request, or a clear statement that it was not run and why.
- [ ] `pnpm vitest run packages/presets` is green.
- [ ] The pull request lists the URLs you opened. A reviewer opens each one.

## What is not built

The scheduled job that would re-run every non-synthetic preset's fixture against the live vendor does not exist. Its core, `runPresetFixture`, does. Still needed: a runner over the catalogue, real vendor accounts supplied as CI secrets, a public page for vendors that reject events from `localhost`, turning a failed result into a pull request, and writing `fixture.lastRun` back on a pass.

Until then, a `verified` preset is true as of the date in `fixture.lastRun`, and nothing re-checks it.

## Related

- [Presets reference](/docs/manual/reference/presets/)
- [Add a vendor with a preset](/docs/manual/guides/add-a-vendor-with-a-preset/)
- [Change classifications](/docs/manual/reference/change-classifications/)
