Skip to content

Rename apiKey to projectToken with aliases - #573

Merged
marandaneto merged 9 commits into
mainfrom
feat/project-token-aliases
Apr 24, 2026
Merged

marandaneto merged 9 commits into
mainfrom
feat/project-token-aliases

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

The iOS SDK still uses apiKey as the public name for the project credential. This draft updates the public surface to prefer projectToken, while keeping apiKey working as a backwards-compatible alias.

It also improves the runtime messaging around the old name by:

  • warning when apiKey is used
  • making empty-value logs clearer with an explicit either/or message

💚 How did you test it?

  • Updated PostHogConfigTest to cover the new projectToken surface and the deprecated apiKey alias.
  • This is a draft PR for early review; I have not run the full iOS test suite yet.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file
  • Added the release label to the PR

@github-actions

github-actions Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

posthog-ios Compliance Report

Date: 2026-04-23 13:35:12 UTC
Duration: 985ms

⚠️ Some Tests Failed

0/1 tests passed, 1 failed


Feature_Flags Tests

⚠️ 0/1 tests passed, 1 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ❌ 166ms

Failures

request_payload.request_with_person_properties_device_id

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

Comment thread .changeset/gentle-tigers-hunt.md Resolved
@marandaneto
marandaneto marked this pull request as ready for review April 23, 2026 12:58
@marandaneto
marandaneto requested a review from a team as a code owner April 23, 2026 12:58
Comment thread PostHog/PostHogSDK.swift
}

let sessionId = resumeCurrent
guard (resumeCurrent

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing build warning:
removed unused sessionId binding by guarding on presence directly

boolValue = PostHogSDK.shared.isFeatureEnabled("4535-funnel-bar-viz")
stringValue = PostHogSDK.shared.getFeatureFlag("multivariant") as? String
payloadValue = PostHogSDK.shared.getFeatureFlagPayload("multivariant") as? [String: String]
payloadValue = PostHogSDK.shared.getFeatureFlagResult("multivariant")?.payload as? [String: String]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed build warnings

// This will throw an NSInvalidArgumentException
NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
[mutableArray insertObject:nil atIndex:0]; // Inserting nil object
#pragma clang diagnostic push

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed build warnings

@marandaneto
marandaneto requested a review from ioannisj April 23, 2026 13:27

@ioannisj ioannisj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, looked at public api changes and I think everything is covered

Comment thread PostHog/PostHogConfig.swift Resolved
@marandaneto
marandaneto merged commit 47aaf2f into main Apr 24, 2026
33 checks passed
@marandaneto
marandaneto deleted the feat/project-token-aliases branch April 24, 2026 08:31
eareyereading pushed a commit to eareyereading/posthog-ios that referenced this pull request May 6, 2026

This branch was previously deployed

1 inactive deployment
Release — f2d90deb Deployed Apr 24, 2026 by marandaneto via Bump version and commit to main #213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants