Skip to content

docs(setup): name projectToken as the project credential config option - #108

Merged
turnipdabeets merged 2 commits into
mainfrom
posthog/setup-project-token-config-name
Oct 9, 2026
Merged

turnipdabeets merged 2 commits into
mainfrom
posthog/setup-project-token-config-name

Conversation

@posthog

@posthog posthog Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Why

Five SDKs have renamed the configuration option carrying the project credential from apiKey to projectToken, but the setup spec never named the option at all — it said only "project API key/token". The contract therefore does not record which name is canonical, that the old name survives as a deprecated alias, or that the rename stops at the public configuration surface.

Source SDK changes

SDK PR Shipped name
posthog-ios #573 PostHogConfig(projectToken:), deprecated apiKey alias
posthog-flutter #374 projectToken, plus com.posthog.posthog.PROJECT_TOKEN for native auto-init
posthog-dotnet #183 ProjectToken, deprecated ProjectApiKey alias
posthog-kmp #91 projectToken, deprecated apiKey
posthog-android #835 projectToken, deprecated apiKey

What changed

Three requirements added to openspec/specs/setup/spec.md:

  • Project token configuration option name — projectToken is canonical, adapted to platform casing.
  • Deprecated project credential alias — any SDK that still names the option apiKey, including ones not yet renamed, adds projectToken and keeps the old name as a deprecated alias that resolves to the same value. That ships in a minor release; the alias can only be dropped in a later major. A compile-time deprecation counts, and a runtime warning is optional. Where a surface accepts both names at once (options objects, provider props, manifest or Info.plist keys), projectToken wins.
  • Project token rename stops at the public configuration surface — wire fields (api_key, token) and persisted queue/preference paths are unchanged, so stored data survives the upgrade. Positional first-argument constructors were never affected.

Narrative updates record which SDKs trim the configured value (iOS, Android, Flutter, React Native), and that React Native's PostHogProvider apiKey prop and Unity's ApiKey have not adopted the name yet.

Proposed, applied, and archived on this branch under openspec/changes/archive/2026-10-08-rename-api-key-to-project-token/.

Not yet renamed

  • React Native: <PostHogProvider apiKey="…"> is the named surface to rename. posthog-js #5221 changed only the docs and the missing-token error message. The new PostHog(apiKey, options?) constructor and browser init(token, …) take the token positionally, so they are out of scope.
  • Unity: PostHogConfig.ApiKey and PostHogSettings.ApiKey.

Both are non-conforming under this spec until they add projectToken with a deprecated alias. That can ship in a minor release.

Uncertainty

  • Deprecation signal. iOS, .NET, and Flutter's native auto-init keys log a runtime warning. Android, KMP, and Flutter's Dart apiKey getter use @Deprecated only, so the requirement accepts either, and the alias scenario checks the resolved token, not a log line.
  • Both names at once can't happen on iOS, Android, KMP, or Flutter's Dart config (separate constructors), so the precedence scenario is tagged @both_token_names_capable.
  • Trimming is in the narrative, not a requirement, and I did not audit every SDK for it.

Validation

openspec validate --specs --strict passes (64 passed, 0 failed), the same as on main. These are specification checks, not executed SDK conformance tests.


Created with PostHog Desktop

🤖 Generated with Claude Code

Five SDKs renamed the project credential configuration option from apiKey
to projectToken (posthog-ios #573, posthog-flutter #374, posthog-dotnet
#183, posthog-kmp #91, posthog-android #835). The setup spec never named
the option, so it did not record which name is canonical, that the old
name survives as a deprecated alias, or that the rename stops at the
public configuration surface.

Adds three requirements to the setup spec: the canonical option name, the
deprecated alias and its precedence, and the guarantee that wire fields
and persisted storage paths are unchanged. Applies and archives the change
on this branch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 88004f09-5e06-46d4-b82d-ce0799263066
@turnipdabeets turnipdabeets self-assigned this Oct 8, 2026
…hipped deprecation

Require SDKs that still use apiKey (React Native's PostHogProvider prop, Unity)
to add projectToken with a deprecated alias, which needs no major release.
Accept compile-time deprecation, since Android, KMP, and Flutter's Dart getter
do not log. Scope the both-names precedence scenario to surfaces that accept
both, and drop the untestable "before the rename" fixture wording.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@turnipdabeets
turnipdabeets marked this pull request as ready for review October 8, 2026 15:22
@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 8, 2026 15:22
@turnipdabeets
turnipdabeets merged commit c2f09c1 into main Oct 9, 2026
10 checks passed
@turnipdabeets
turnipdabeets deleted the posthog/setup-project-token-config-name branch October 9, 2026 19:56
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.

2 participants