Skip to content

feat: add audience collection mode - #15

Merged
francoischalifour merged 5 commits into
mainfrom
feat/audience-collection-pr
Nov 9, 2026
Merged

francoischalifour merged 5 commits into
mainfrom
feat/audience-collection-pr

Conversation

@francoischalifour

@francoischalifour francoischalifour commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What

Add immutable mode="audience" for single events and raw batches. Audience events send only mode, event, timestamp, and properties; the client's mode cannot be overridden by per-event options or batch entries, and caller dictionaries are not mutated. identify() and alias() return None silently without sending a request, and distinct_id is not required. Caller properties pass through unchanged. Product mode remains the default and drops any top-level mode field from batch entries. An invalid mode raises ValueError.

TrackingMode is exported, and the client exposes a read-only mode property.

Why

Server callers need restricted event collection without product identifiers. Custom properties remain the application's responsibility, and server HTTP context does not represent individual visitors.

Checklist

  • Public scalar and batch tests cover the audience wire shape, input ownership, identity suppression, and retained product behavior.
  • Public types, README setup guidance, and changelog updated.

Server SDKs do not rewrite $url, $referer, or $viewport and need no audience-specific transport, cookie, redirect, or credential isolation. Drop that code, its tests, the unrelated py.typed marker and formatting churn, and shorten the docs.
@francoischalifour

Copy link
Copy Markdown
Member Author

Scope change following the spec update: server-tier audience mode is now only the wire shape (mode, event, timestamp, properties) plus no-op identify/alias. URL sanitization and the audience cookie/redirect session are removed; caller properties pass through unchanged.

@francoischalifour
francoischalifour merged commit 9e507b8 into main Nov 9, 2026
10 checks passed
@francoischalifour
francoischalifour deleted the feat/audience-collection-pr branch November 9, 2026 14:43
francoischalifour added a commit that referenced this pull request Nov 9, 2026
## What

Ignore the `environment` constructor argument. It is now `Optional[str]`
and still accepted positionally or by name so existing calls keep
working, but it is ignored, not stored on the client, and emits no
warning. A single helper strips top-level `environment` from track,
identify, and alias requests, including raw batches, without mutating
caller dictionaries or removing nested business properties. README gains
a short note on the deprecation.

## Why

An environment-bound Product Analytics API key now selects the
destination. Callers using unbound legacy keys must replace them before
upgrading.

Stacked on #15 (audience collection); this PR contains only the
environment slice.

## Checklist

- [x] Public client tests cover that the argument is accepted silently,
omission of `environment` from track/identify/alias and batch requests,
preserved nested properties, and caller input ownership.
- [x] Changelog and README updated; the compatibility impact (unbound
keys require migration) is documented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants