feat: add secretKey config, deprecate personalAPIKey#199
Open
turnipdabeets wants to merge 2 commits into
Open
Conversation
Add a canonical `secretKey` argument to `PostHog::init()` and `Client::__construct()` for local feature flag evaluation and remote config. It accepts either a Personal API Key (phx_...) or a Project Secret API Key (phs_...). `personalAPIKey` is kept as a deprecated, backwards-compatible alias; when both are provided, `secretKey` wins. The resolved value mirrors onto the existing `personalAPIKey` field so all internal reads keep working. Non-breaking.
|
Reviews (1): Last reviewed commit: "feat: add secretKey config, deprecate pe..." | Re-trigger Greptile |
Contributor
posthog-php Compliance ReportDate: 2026-07-02 16:14:44 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
|
Reviews (2): Last reviewed commit: "test: collapse secret key credential tes..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The credential used for local feature flag evaluation and remote config accepts either a Personal API Key (
phx_...) or a Project Secret API Key (phs_...), but the config field is namedpersonalAPIKey. That name is misleading — it implies only a personal API key is valid.Change
Add a new canonical
secretKeyargument toPostHog::init()andClient::__construct(), and keeppersonalAPIKeyas a deprecated, backwards-compatible alias. This is non-breaking:secretKey ?? personalAPIKey. When both are provided,secretKeywins.secretKeyfield and mirrored onto the existingpersonalAPIKeyfield so all internal reads (and any reflection-based access) keep working.personalAPIKeyis marked deprecated in phpdoc, pointing users tosecretKey.secretKeyparam/field carries a tooltip-friendly doc comment (accepts a Personal API Key or Project Secret API Key, defaults to null, used for local flag evaluation and remote config).api/public-api.json) updated for the new trailing optional param on both entry points.Tests cover:
secretKeysets the credential,personalAPIKeystill works as an alias, andsecretKeywins when both are set.Context
From Slack + PostHog/posthog-js#4046, this is the rename item only, part of a coordinated rename across backend SDKs. Mirrors the change already merged as draft in posthog-python (PR #727).