fix(amplitude-session) + feat: prerelease channels - recover lastEventTime & implement branch-specific releases#1198
Open
fix(amplitude-session) + feat: prerelease channels - recover lastEventTime & implement branch-specific releases#1198
Conversation
6872c0c to
41a5d02
Compare
… Fetch iOS Background Fetch can briefly trigger AppState 'active' without user interaction, causing rapid session creation/destruction cycles. Add a 1-second timestamp guard in onForeground() to prevent new sessions from starting within 1 second of the last session creation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace incorrect 1-second timestamp guard with proper root cause fix. The 0-second session bug is caused by non-atomic AsyncStorage persistence: when the app is killed (e.g. during iOS Background Fetch), sessionId may persist while lastEventTime does not. On relaunch, lastEventTime === -1 with a valid sessionId falsely triggers session expiration, ending the just-created session immediately. The fix recovers lastEventTime from sessionId when partial persistence is detected, preventing the false expiration. Also adds hypothesis-driven reproduction tests that verify the fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix CI formatting check failures. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
41a5d02 to
8d6874c
Compare
Changed from a single "beta" prerelease channel to branch-specific channels: - fix/* → x.x.x-fix.N - feat/* → x.x.x-feat.N - chore/* → x.x.x-chore.N - beta → x.x.x-beta.N (explicit) This provides better semantic meaning for prerelease versions. Instead of all non-master branches being "beta", each category gets its own channel. Examples: - fix/ios-zero-second-sessions → 2.22.1-fix.1 - feat/new-feature → 2.22.1-feat.1 - beta → 2.22.1-beta.1 Updated workflow to use new "Publish-Prerelease" environment instead of "Publish-Beta" to reflect the broader scope. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added comprehensive documentation for the new branch-specific prerelease system including: - GitHub environment setup instructions - npm token vs OIDC setup options - Testing and verification steps - Troubleshooting guide - Migration notes from old beta setup Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Removed chore/* branches from prerelease channels since they're for internal changes not meant for client distribution. Only fix/* and feat/* branches (plus explicit beta) will publish now. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed the workflow input from 'beta' to 'prerelease' to avoid confusion. The input triggers prerelease publishing for any prerelease channel (fix, feat, or beta), not just the beta channel. Now you select: - dry-run → test without publishing - prerelease → publish fix/feat/beta channels - production → production release from main Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR includes two sets of changes:
Part 1: Amplitude Session Fix
Changes
startNewSessionIfNecessary()for partial AsyncStorage persistencelastEventTimefromsessionIdwhenlastEventTime === -1butsessionId >= 0lastEventTime === -1fromisSessionExpiredcheck (now handled by recovery)onForeground()Why
Plugin persists
sessionIdandlastEventTimevia independent fire-and-forget writes. If app is killed before all writes complete (common during iOS Background Fetch),sessionIdmay persist whilelastEventTimedoesn't. On next launch,lastEventTime === -1with validsessionIdfalsely triggers session expiration, ending the just-created session immediately.Part 2: Branch-Specific Prerelease Channels
Changes
1. Updated
release.config.js:Before: All non-master branches published as
x.x.x-beta.NAfter: Each branch type gets its own channel and dist-tag
Examples:
fix/ios-zero-second-sessions→2.22.1-fix.1(dist-tag:fix)feat/new-analytics→2.22.1-feat.1(dist-tag:feat)beta→2.22.1-beta.1(dist-tag:beta)2. GitHub Environment:
Publish-PrereleaseenvironmentPublish-Prereleaseinstead ofPublish-Beta3. Workflow Input Clarity:
Renamed workflow input from
betatoprerelease:4. Documentation:
Added
PRERELEASE_SETUP.mdwith complete setup and troubleshooting guide.Benefits
x.x.x-fix.1is clearer thanx.x.x-beta.1for a bug fixbetachannel still worksTesting
After merge, the workflow will show the new
prereleaseoption. To test:No npm-side setup needed - we already use npm OIDC with provenance.
🤖 Generated with Claude Code