Skip to content

chore: deprecate APIs that 4.0 hides or removes - #884

Merged
turnipdabeets merged 1 commit into
mainfrom
chore/deprecate-v4-hidden-apis
Oct 1, 2026
Merged

turnipdabeets merged 1 commit into
mainfrom
chore/deprecate-v4-hidden-apis

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

PostHog iOS 4.0 hides or removes several public APIs (#874) and raises the minimum iOS version to 15 (#876). Most of those APIs were never marked deprecated. This adds deprecation warnings in 3.x where that can be done without side effects, so app developers hear about the change before it breaks their build.

Deprecated, with a compiler warning:

Symbol In 4.0 Replacement
PostHogSessionManager.shared, setSessionId(_:) SDK-internal (SPI) PostHogSDK.getSessionId(), startSession(), endSession()
dateToMillis(_:) SDK-internal (SPI) Int64(date.timeIntervalSince1970 * 1000)
imageToBase64(_:_:) SDK-internal (SPI) none
UIColor.hexDescription(_:) removed from the public API none

None of these is used inside the SDK, so the SDK's own build gains no warnings. Annotations only; behaviour is unchanged.

Changing in 4.0 without a 3.x warning

The SDK calls these internally. Deprecating them in place makes Swift warn at every internal call site, which was 171 warnings in the SDK's own macOS build, and CocoaPods users compile the SDK from source and would see them. Warning only external callers would need internal forwarders and about 110 renamed call sites. They are listed in the changeset instead, so the 3.x changelog still announces them.

  • Becoming SDK-internal: postHogSdkName, postHogVersion, PostHogConfig.storageManager, PostHogConfig.snapshotEndpoint
  • Removed from the public API: toISO8601String(_:), toISO8601Date(_:), sanitizeDictionary(_:), deleteSafely(_:), postHogiOSSdkName, UIColor.init(hex:), Gzip, GzipError, CompressionLevel, ReachabilityError

The iOS 15 minimum is also announced in the changeset only, since Swift cannot warn about an app's deployment target at compile time.

Wrapper SDKs

No wrapper treats warnings as errors, so nothing breaks.

  • The React Native plugin will see a warning for PostHogSessionManager.shared.setSessionId.
  • posthog-flutter will see warnings for dateToMillis and imageToBase64.
  • Both already import with @_spi(PostHogInternal), which keeps these available in 4.0 but doesn't silence the warning on 3.x.

💚 How did you test it?

  • make buildSdk: all seven builds pass (iOS, SwiftPM macOS, macOS, Mac Catalyst, tvOS, watchOS, visionOS), with no deprecation warnings from the SDK module.
  • make test (macOS): the first full run had one failure, activates survey when event name and properties match (PostHogSurveysTest.swift:688). PostHogSurveysTest then passed 3 of 3 runs on this branch and 3 of 3 on main, and a second full run passed (910 tests). This PR changes no survey logic, only a deprecation attribute on UIColor.hexDescription(_:).
  • make apiCheck: snapshot up to date.
  • Before this was split down to one commit, a scratch Swift package built against it got the deprecation warning for each symbol on macOS and iOS and still compiled.
  • Not run on this exact commit: the iOS simulator tests.

📝 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

The changeset is minor and was written by hand in the changeset format.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

  • Written with Claude Code (Opus 5.5).
  • A second commit that deprecated the internally used symbols through internal forwarders was built and tested, then left out: about 110 call-site renames and 84 new warnings in the SDK's test target, mostly to warn about SDK plumbing that only PostHog's own wrappers use.
  • Gzip, GzipError, CompressionLevel and ReachabilityError are not deprecated: no public API accepts or returns them, and warning about them would mean restructuring the bundled third-party code.

🤖 Generated with Claude Code

Deprecate PostHogSessionManager.shared, setSessionId(_:), dateToMillis(_:),
imageToBase64(_:_:) and UIColor.hexDescription(_:). None of them is used
inside the SDK, so the annotations add no warnings to the SDK's own build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 1, 2026 15:25
@turnipdabeets turnipdabeets self-assigned this Oct 1, 2026
@turnipdabeets
turnipdabeets merged commit a60a2b0 into main Oct 1, 2026
48 checks passed
@turnipdabeets
turnipdabeets deleted the chore/deprecate-v4-hidden-apis branch October 1, 2026 18:11
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