:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(cli): deprecate event release mode on the mobile uploads (#92401)
Aleksander Błaszkiewicz8a28e07ea71c
diff --git a/cli/.sampo/changesets/deprecate-mobile-release-mode.md b/cli/.sampo/changesets/deprecate-mobile-release-mode.mdnew file mode 100644index 000000000000..52e5f3fa7398--- /dev/null+++ b/cli/.sampo/changesets/deprecate-mobile-release-mode.md@@ -0,0 +1,7 @@+---+cargo/posthog-cli: minor+---++Deprecate `--release-mode` on `proguard upload` and `--no-release-bind` on `dsym upload`. Both flags are hidden no-ops now: each command uploads its symbol sets bound to the release it creates, which is what it did before the flags existed. A supplied flag prints a deprecation warning instead of changing the upload, so a released gradle plugin or upload-symbols.sh that still passes one keeps working. `proguard upload` no longer reads `POSTHOG_RELEASE_MODE`; the variable keeps steering `sourcemap inject`, `sourcemap process`, `sourcemap upload`, `hermes inject`, `hermes clone` and `hermes upload`.++Event mode pays off when two releases ship a byte-identical artifact. A proguard map id is a hash of the mapping, and a dSYM symbol set is keyed on the Mach-O `LC_UUID`, so an ordinary release that changes code already gets its own symbol set. The dSYM path also lost release attribution for embedded targets, because one upload covers every target's dSYM but creates one release.diff --git a/cli/src/dsym/upload.rs b/cli/src/dsym/upload.rsindex d450c2fcff54..2236378b4725 100644--- a/cli/src/dsym/upload.rs+++ b/cli/src/dsym/upload.rs@@ -36,10 +36,10 @@ pub struct Args {#[arg(long, default_value_t = false)]pub include_source: bool,- /// Don't bind the uploaded symbol sets to the release. The release is still created, so the- /// server resolves it from the app version and namespace the SDK sends on every event, but the- /// chunks stay content-addressed and release-independent. [default: false]- #[arg(long, default_value_t = false)]+ /// Deprecated: the symbol sets always bind to the release the build creates. The flag stays+ /// accepted so a released posthog-ios upload-symbols.sh that still passes it does not fail+ /// the Xcode build with a parse error.+ #[arg(long, default_value_t = false, hide = true)]pub no_release_bind: bool,}@@ -52,6 +52,14 @@ pub fn upload(args: &Args) -> Result<()> {include_source,no_release_bind,} = args;++ if *no_release_bind {+ tracing::warn!(+ "--no-release-bind is deprecated and does nothing. The symbol sets are uploaded bound \+ to the release this build creates. Remove the flag."+ );+ }+let release_args = release.resolve_info_plist()?;let directory = directory.canonicalize().map_err(|e| {@@ -175,14 +183,7 @@ pub fn upload(args: &Args) -> Result<()> {let release_id = created_release.map(|r| r.id.to_string());- // With --no-release-bind the release is still created above (so the server can resolve it from- // the app metadata the SDK sends on each event), but the uploaded chunks are left- // release-independent.- let chunk_release_id = if *no_release_bind {- None- } else {- release_id.clone()- };+ let chunk_release_id = release_id.clone();// Process each dSYMlet mut uploads: Vec<SymbolSetUpload> = Vec::new();@@ -229,3 +230,45 @@ pub fn upload(args: &Args) -> Result<()> {Ok(())}++#[cfg(test)]+mod tests {+ use super::*;+ use clap::{CommandFactory, Parser};++ #[derive(Parser)]+ struct DsymCli {+ #[command(subcommand)]+ command: crate::dsym::DsymSubcommand,+ }++ fn parse(extra: &[&str]) -> Args {+ let mut argv = vec!["dsym", "upload", "--directory", "dsyms"];+ argv.extend_from_slice(extra);+ let crate::dsym::DsymSubcommand::Upload(args) = DsymCli::parse_from(argv).command;+ args+ }++ #[test]+ fn accepts_the_deprecated_no_release_bind_flag() {+ // Released posthog-ios upload-symbols.sh passes `--no-release-bind` when+ // POSTHOG_NO_RELEASE_BIND=1. Rejecting the flag would fail the Xcode build phase with a+ // parse error on CLI upgrade.+ assert!(parse(&["--no-release-bind"]).no_release_bind);+ assert!(!parse(&[]).no_release_bind);+ }++ #[test]+ fn deprecated_no_release_bind_is_hidden() {+ let cmd = DsymCli::command();+ let upload = cmd+ .find_subcommand("upload")+ .expect("expected the upload subcommand");+ let arg = upload+ .get_arguments()+ .find(|a| a.get_id() == "no_release_bind")+ .expect("expected the no_release_bind argument");++ assert!(arg.is_hide_set());+ }+}diff --git a/cli/src/proguard/upload.rs b/cli/src/proguard/upload.rsindex a3b82cc5c66e..f55999b53504 100644--- a/cli/src/proguard/upload.rs+++ b/cli/src/proguard/upload.rs@@ -31,19 +31,11 @@ pub struct Args {#[clap(flatten)]pub conflict: UploadConflictArgs,- /// How the release is associated with exceptions. `symbol-set`, the default, stamps the- /// release id onto the uploaded mapping, and an exception takes the release of the mappings- /// its frames resolved against. EXPERIMENTAL `event` leaves the mapping- /// release-independent, and each event resolves its own release from the app version and- /// namespace the SDK already sends, so the release coordinates have to match the app's. The- /// release is created either way. Also settable via `POSTHOG_RELEASE_MODE`.- #[arg(- long,- env = "POSTHOG_RELEASE_MODE",- value_enum,- default_value = "symbol-set"- )]- pub release_mode: ReleaseMode,+ /// Deprecated: the mapping always binds to the release the build creates. The flag stays+ /// accepted so a gradle plugin that still passes it does not fail to parse, and it no longer+ /// reads `POSTHOG_RELEASE_MODE`, which keeps steering the sourcemap and hermes commands.+ #[arg(long, value_enum, hide = true)]+ pub release_mode: Option<ReleaseMode>,}pub fn upload(args: &Args) -> Result<()> {@@ -56,6 +48,13 @@ pub fn upload(args: &Args) -> Result<()> {release_mode,} = args;+ if release_mode.is_some() {+ warn!(+ "--release-mode is deprecated and does nothing. The mapping is uploaded bound to the \+ release this build creates. Remove the flag."+ );+ }+let resolved_release = release.resolve_info_plist()?;let ReleaseArgs {name,@@ -65,18 +64,6 @@ pub fn upload(args: &Args) -> Result<()> {skip_release_on_fail,} = &resolved_release;- // Event mode leaves nothing on the symbol set for the server to fall back to, so an- // exception resolves its release only from the app metadata on the event itself. Coordinates- // derived from git rather than passed explicitly will not match that metadata, and the- // exception then reports no release at all, silently.- if *release_mode == ReleaseMode::Event && (name.is_none() || version.is_none()) {- warn!(- "--release-mode=event resolves each exception's release from the app's namespace and \- version. Pass --release-name, --release-version and --build matching the app's \- applicationId, versionName and versionCode, or exceptions will report no release."- );- }-let path = path.canonicalize().map_err(|e| anyhow!("Path {} canonicalization failed: {}", path.display(), e))?;@@ -103,20 +90,11 @@ pub fn upload(args: &Args) -> Result<()> {.then(|| release_builder.fetch_or_create()).transpose()?;- // The release is created in both modes, so the server has a row to resolve an event's- // `$app_namespace` / `$app_version` / `$app_build` onto. Event mode only skips binding it to- // the mapping: a map id is derived from the mapping's own content, so the same mapping keeps- // one symbol set across releases instead of colliding with the release the first upload- // stamped on it.- //- // Unlike sourcemaps, event mode does not imply `--force` here. The uploaded bytes are the- // mapping itself, with no injected release id, so a rebuild of unchanged code produces- // identical content under the same id and never conflicts. A conflict means the caller reused- // a `--map-id` for a different mapping, which is worth reporting in either mode.- file.release_id = match release_mode {- ReleaseMode::Event => None,- ReleaseMode::SymbolSet => release.map(|r| r.id.to_string()),- };+ // Bind the mapping to the release this build resolved, so an exception symbolicated with this+ // mapping takes that release. A build with no release name or version resolves none, and the+ // upload then carries no release id. `--skip-release-on-fail` can also drop the binding when+ // the server rejects it.+ file.release_id = release.map(|r| r.id.to_string());let to_upload: SymbolSetUpload = file.try_into()?;@@ -135,7 +113,7 @@ pub fn upload(args: &Args) -> Result<()> {#[cfg(test)]mod tests {use super::*;- use clap::Parser;+ use clap::{CommandFactory, Parser};#[derive(Parser)]struct ProguardCli {@@ -159,17 +137,34 @@ mod tests {}#[test]- fn defaults_to_binding_the_release_to_the_mapping() {- // Every existing caller omits the flag, and they must keep uploading mappings stamped with- // their release.- assert_eq!(parse(&[]).release_mode, ReleaseMode::SymbolSet);- }-- #[test]- fn accepts_event_release_mode() {+ fn accepts_the_deprecated_release_mode_flag() {+ // Released gradle plugins pass `--release-mode event`. Rejecting the flag would fail+ // their builds with a parse error on CLI upgrade.assert_eq!(parse(&["--release-mode", "event"]).release_mode,- ReleaseMode::Event+ Some(ReleaseMode::Event)+ );+ assert_eq!(+ parse(&["--release-mode", "symbol-set"]).release_mode,+ Some(ReleaseMode::SymbolSet));+ assert_eq!(parse(&[]).release_mode, None);+ }++ #[test]+ fn deprecated_release_mode_is_hidden_and_reads_no_environment() {+ // A default or an env binding would mark unconfigured runs as deprecated callers, and+ // POSTHOG_RELEASE_MODE stays a real control for the sourcemap and hermes commands.+ let cmd = ProguardCli::command();+ let upload = cmd+ .find_subcommand("upload")+ .expect("expected the upload subcommand");+ let arg = upload+ .get_arguments()+ .find(|a| a.get_id() == "release_mode")+ .expect("expected the release_mode argument");++ assert!(arg.is_hide_set());+ assert!(arg.get_env().is_none());}}diff --git a/cli/src/sourcemaps/args.rs b/cli/src/sourcemaps/args.rsindex f6682e71177e..fe097ea9f983 100644--- a/cli/src/sourcemaps/args.rs+++ b/cli/src/sourcemaps/args.rs@@ -173,13 +173,14 @@ pub struct ReleaseArgs {#[derive(clap::Args, Clone, Default)]pub struct UploadConflictArgs {- /// Allow overwriting an existing symbol set whose content has changed. Always on with- /// `--release-mode=event`. [default: false]+ /// Allow overwriting an existing symbol set whose content has changed. The sourcemap and+ /// hermes uploads always overwrite in `event` release mode. [default: false]#[arg(long, default_value_t = false, conflicts_with = "skip_on_conflict")]pub force: bool,/// Skip symbol sets that already exist with different content instead of failing.- /// Existing symbol sets are left unchanged. Ignored with `--release-mode=event`. [default: false]+ /// Existing symbol sets are left unchanged. The sourcemap and hermes uploads ignore this in+ /// `event` release mode. [default: false]#[arg(long, default_value_t = false, conflicts_with = "force")]pub skip_on_conflict: bool,}