Skip to content

chore(jvm): keep PostHogConfig copy and default-argument constructor linkable - #116

Merged
turnipdabeets merged 4 commits into
feat/kmp-set-app-languagefrom
fix/kmp-config-copy-binary-compat
Nov 9, 2026
Merged

turnipdabeets merged 4 commits into
feat/kmp-set-app-languagefrom
fix/kmp-config-copy-binary-compat

Conversation

@turnipdabeets

Copy link
Copy Markdown
Collaborator

💡 Motivation and Context

Stacked on #115. Adding evaluationContexts to the PostHogConfig primary constructor changed two JVM signatures that 0.10 consumers link against, and #115 only kept the plain 20-parameter constructor:

JVM member from 0.10 Who calls it Before this PR
copy(<20 params>) / copy$default(...) any Kotlin config.copy(...) missing → NoSuchMethodError
<init>(<20 params>, int, DefaultConstructorMarker) Kotlin PostHogConfig(...) calls that name capturePushNotificationSubscriptions or capturePushNotificationOpened and rely on defaults missing → NoSuchMethodError

Changes:

  • Add a @Deprecated(level = HIDDEN) 20-parameter copy, matching the existing hidden apiKey copy overloads. Hidden keeps it out of Kotlin overload resolution.
  • Give the retained 20-parameter constructor its default values back, so Kotlin emits the default-argument constructor again. Source resolution is unchanged in practice: PostHogConfig(projectToken = ...) still picks the 18-parameter overload (fewest unused defaults), and calls passing evaluationContexts only match the primary constructor.
  • Drop the duplicated evaluationContexts = config.evaluationContexts line in PostHog.android.kt and PostHog.jvm.kt.

No changeset: nothing changes relative to 0.10.

💚 How did you test it?

  • Added two reflection tests in PostHogConfigJavaTest that call copy$default and the default-argument constructor by their 0.10 signatures, as prebuilt Kotlin code does. The copy test fails with NoSuchMethodException without the fix; javap confirmed the constructor signature was missing too.
  • ./gradlew :posthog-kmp:jvmTest (all pass), :posthog-kmp:compileAndroidMain, :posthog-kmp:compileKotlinJs. Run locally against com.posthog:posthog:7.0.0 from mavenLocal since it isn't on Maven Central yet.
  • detekt reports 2 EmptyFunctionBlock issues in PostHog.js.kt / PostHog.wasmJs.kt that already exist on feat: add PostHog.setAppLanguage() and send $locale as BCP 47 on JVM #115. The iOS compile didn't run locally because the Swift package resolve failed.

📝 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.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code, from a pre-release review of #115. The repo has no binary-compatibility-validator or .api dumps, so the reflection tests are the guard.

🤖 Generated with Claude Code

…nkable

Adding evaluationContexts changed the data class copy and the
synthetic default-argument constructor, so JVM code compiled against
0.10 that calls copy(...) or PostHogConfig(..., capturePush...= ...)
hit NoSuchMethodError. Add a hidden 20-parameter copy and give the
retained 20-parameter constructor its defaults back.

Also drop the duplicated evaluationContexts assignment on Android and
JVM.
@turnipdabeets turnipdabeets self-assigned this Nov 8, 2026
@sampo-s-bot

sampo-s-bot Bot commented Nov 8, 2026

Copy link
Copy Markdown

⚠️ No changeset detected

No new .sampo/changesets/*.md files were detected in this PR. To add one:

  • run sampo add
  • follow the prompts to pick the affected packages and describe the change
  • commit the generated file to this pull request, and it will be detected automatically

If this PR isn't supposed to introduce any changes (e.g., documentation updates), you can ignore this message.

@turnipdabeets
turnipdabeets marked this pull request as ready for review November 8, 2026 17:30
@turnipdabeets
turnipdabeets requested a review from a team as a code owner November 8, 2026 17:30
@turnipdabeets turnipdabeets changed the title fix(jvm): keep PostHogConfig copy and default-argument constructor linkable chore(jvm): keep PostHogConfig copy and default-argument constructor linkable Nov 8, 2026

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code looks good; no qualifying findings. Verdict: correct.

@turnipdabeets
turnipdabeets merged commit fa5c7db into feat/kmp-set-app-language Nov 9, 2026
10 checks passed
@turnipdabeets
turnipdabeets deleted the fix/kmp-config-copy-binary-compat branch November 9, 2026 14:08
turnipdabeets added a commit that referenced this pull request Nov 9, 2026
…115)

* feat: add PostHog.setAppLanguage() and send $locale as BCP 47 on JVM

Set $app_language on every platform: forwarded to the native SDKs on
Android, JVM, iOS and macOS, and added in before_send on JS and Wasm,
where posthog-js has no such property. Document the Compose Multiplatform
resources gap in MIGRATION.md.

* fix(web): skip $app_language when denylisted or on minimal flag-called events

* fix(web): drop $app_language on JS and Wasm until posthog-js supports it

* docs: scope setAppLanguage() to native targets and note it needs setup() on Android and JVM

* chore: give the JS and Wasm setAppLanguage no-ops a body so detekt passes

* chore(jvm): keep PostHogConfig copy and default-argument constructor linkable (#116)

* fix(jvm): keep PostHogConfig copy and default-argument constructor linkable

Adding evaluationContexts changed the data class copy and the
synthetic default-argument constructor, so JVM code compiled against
0.10 that calls copy(...) or PostHogConfig(..., capturePush...= ...)
hit NoSuchMethodError. Add a hidden 20-parameter copy and give the
retained 20-parameter constructor its defaults back.

Also drop the duplicated evaluationContexts assignment on Android and
JVM.

* test(config): use assertNull for the null evaluation contexts check

* chore: re-run CI after retitling to chore
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