Skip to content

fix(android): preserve manually set releaseIdentifier - #661

Merged
marandaneto merged 1 commit into
mainfrom
fix/preserve-release-identifier
Jul 29, 2026
Merged

fix(android): preserve manually set releaseIdentifier#661
marandaneto merged 1 commit into
mainfrom
fix/preserve-release-identifier

Conversation

@cat-ph

@cat-ph cat-ph commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

PostHogMetaPropertiesApplier.applyToConfig had an inverted guard: the comment said "if releaseIdentifier is already set, we don't need to do anything", but the condition overwrote a manually configured releaseIdentifier with the auto-generated fallback (applicationId@versionName+versionCode). Anyone setting releaseIdentifier in PostHogAndroidConfig (as documented) lost it on init, breaking proguard symbolication due to the map-id mismatch.

This fixes the precedence to:

  1. A pre-set releaseIdentifier is preserved (the asset read is skipped entirely).
  2. Otherwise the map-id from posthog-meta.properties is used when present.
  3. Otherwise the fallback is applied — including the previously broken case where the meta file exists but contains no map-id, which used to leave releaseIdentifier null.

💚 How did you test it?

  • New unit tests in PostHogMetaPropertiesApplierTest covering all five paths (preserve manual value, use meta map-id, fallback on missing file / missing key / read error).
  • Full unit test gate (./gradlew testDebugUnitTest) and spotlessCheck pass.

📝 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


@Test
fun `uses fallback when meta properties do not contain map id`() {
mockMetaProperties("some.other.property=value")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is actually a more important case I saw in prod, tens of thousands of frames per week here at a first/quick look (although some could be older versions who don't have a releaseIdentifier in the first place).

the first one with manual releaseIdentifier isn't as common

@cat-ph
cat-ph marked this pull request as ready for review July 28, 2026 18:28
@cat-ph
cat-ph requested a review from a team as a code owner July 28, 2026 18:28
@cat-ph
cat-ph requested review from a team, ablaszkiewicz and hpouillot July 28, 2026 18:28
@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(android): preserve manually set rele..." | Re-trigger Greptile

@marandaneto

Copy link
Copy Markdown
Member

will check, i remember testing this so quite surprise its a bug, maybe a regression

@marandaneto

Copy link
Copy Markdown
Member

Was it a regression?

Your memory is correct:

  • The initial implementation in PR chore: proguard support #316, commit 00d4e33 from November 5, correctly did:
      if (config.releaseIdentifier.isNullOrEmpty()) {
          config.releaseIdentifier = fallback
      }
  • The November 28 refactor in commit bd1373f introduced PostHogMetaPropertiesApplier and accidentally inverted that
    behavior.
  • It shipped in posthog-android 3.27.0.

So it was a regression during development of PR #316, likely after you tested it. Strictly speaking, it was broken in
the first stable release containing releaseIdentifier, so it was not a regression between stable SDK releases.

@marandaneto
marandaneto merged commit d23697e into main Jul 29, 2026
15 checks passed
@marandaneto
marandaneto deleted the fix/preserve-release-identifier branch July 29, 2026 06:51
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