-
Notifications
You must be signed in to change notification settings - Fork 48
feat(gradle-plugin): default release mode to event #739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| 'posthog-android-gradle-plugin': minor | ||
| --- | ||
|
|
||
| Default `posthog.releaseMode` to `event`. The proguard mapping now uploads release-independent. Each event resolves its own release from the `$app_namespace` / `$app_version` / `$app_build` the SDK already sends. Two releases that ship the same mapping no longer both report whichever release uploaded it first. | ||
|
|
||
| Set `posthog.releaseMode=symbol-set`, or `POSTHOG_RELEASE_MODE=symbol-set`, to keep stamping the release onto the uploaded mapping. | ||
|
|
||
| Event mode needs posthog-cli 0.13.0 or newer. That version added `--release-mode` to `proguard upload`. The release coordinates the build sends must match the app's applicationId, versionName and versionCode. |
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
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
55 changes: 55 additions & 0 deletions
55
posthog-android-gradle-plugin/src/test/java/com/posthog/android/PostHogReleaseModeTest.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package com.posthog.android | ||
|
|
||
| import org.gradle.api.Project | ||
| import org.gradle.testfixtures.ProjectBuilder | ||
| import org.junit.Test | ||
| import kotlin.test.assertEquals | ||
| import kotlin.test.assertFailsWith | ||
|
|
||
| internal class PostHogReleaseModeTest { | ||
| // Not `apply`: Project has its own apply(), so the scope function would resolve to Gradle's. | ||
| private fun project(releaseMode: String? = null): Project { | ||
| val project = ProjectBuilder.builder().build() | ||
| releaseMode?.let { project.extensions.extraProperties.set(POSTHOG_RELEASE_MODE_PROPERTY, it) } | ||
| return project | ||
| } | ||
|
|
||
| @Test | ||
| fun `a build that configures nothing uploads its mapping release-independent`() { | ||
| assertEquals(PostHogReleaseMode.EVENT, resolvePostHogReleaseMode(project(), emptyMap())) | ||
| } | ||
|
|
||
| @Test | ||
| fun `the gradle property selects the mode`() { | ||
| assertEquals( | ||
| PostHogReleaseMode.SYMBOL_SET, | ||
| resolvePostHogReleaseMode(project(releaseMode = "symbol-set"), emptyMap()), | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `the environment variable selects the mode`() { | ||
| assertEquals( | ||
| PostHogReleaseMode.SYMBOL_SET, | ||
| resolvePostHogReleaseMode(project(), mapOf(POSTHOG_RELEASE_MODE_ENV to "symbol-set")), | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `the gradle property wins over the environment variable`() { | ||
| assertEquals( | ||
| PostHogReleaseMode.SYMBOL_SET, | ||
| resolvePostHogReleaseMode( | ||
| project(releaseMode = "symbol-set"), | ||
| mapOf(POSTHOG_RELEASE_MODE_ENV to "event"), | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `an unrecognized value fails the build instead of picking a mode`() { | ||
| assertFailsWith<IllegalStateException> { | ||
| resolvePostHogReleaseMode(project(releaseMode = "symbolset"), emptyMap()) | ||
| } | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.