Skip to content

fix: send session start envelope immediately - #2242

Merged
JoshuaMoelans merged 11 commits into
masterfrom
joshua/feat/capture_session_start
Oct 28, 2026
Merged

JoshuaMoelans merged 11 commits into
masterfrom
joshua/feat/capture_session_start

Conversation

@JoshuaMoelans

@JoshuaMoelans JoshuaMoelans commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Sends the initial session update as soon as a session starts instead of with the first event or the end of the session, so a run that never sends anything else still counts. Defaults to on for Nintendo Switch and PlayStation, where the crash report embeds the live session, and off elsewhere.

Related to https://github.com/getsentry/sentry-playstation/pull/185 and https://github.com/getsentry/sentry-switch/pull/180

Implemented in https://github.com/getsentry/sentry-switch/pull/200

Comment thread include/sentry.h Outdated
Comment on lines +1962 to +1970
SENTRY_API void sentry_options_set_send_session_start_update(
sentry_options_t *opts, int val);

/**
* Returns true if the initial session update is sent when a session starts.
*/
SENTRY_API int sentry_options_get_send_session_start_update(
const sentry_options_t *opts);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's TBD whether we want this as an option, or just do this by default (I don't see a strong argument for not sending sessions by themselves tbqh)

@JoshuaMoelans JoshuaMoelans Oct 27, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Talked with @bitsandfoxes and we agree that, since this is not breaking with any spec, we decide to change the internals as it is an implementation detail on how/when sessions get sent (and this approach is arguably more "correct").

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.62%. Comparing base (a4c7507) to head (c2049a3).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2242      +/-   ##
==========================================
- Coverage   75.63%   75.62%   -0.01%     
==========================================
  Files         103      103              
  Lines       28281    28316      +35     
  Branches     5199     5208       +9     
==========================================
+ Hits        21389    21413      +24     
- Misses       5547     5563      +16     
+ Partials     1345     1340       -5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

JoshuaMoelans and others added 4 commits October 27, 2026 12:52
Sends the initial session update as soon as a session starts instead of
with the first event or the end of the session, so a run that never sends
anything else still counts. Defaults to on for Nintendo Switch and
PlayStation, where the crash report embeds the live session, and off
elsewhere.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
On the Switch and PlayStation the option is on by default, so the
concurrency, late release/environment and retry restore tests saw one
more session envelope than they count.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Drops the `send_session_start_update` option: `sentry_start_session` now
sends the initial update as its own envelope on every platform, so a run
that never sends anything else still counts. Tests expect the extra
envelope.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@JoshuaMoelans
JoshuaMoelans force-pushed the joshua/feat/capture_session_start branch from 2f5261f to eff4883 Compare October 27, 2026 11:53
The crash tests now crash a few milliseconds after the start update is
queued. On Linux CI that request was sometimes still in flight, so the
crash dump wrote it to disk as well and the next run sent it twice, or
it got lost. Draining the transport first keeps the envelope count fixed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
[
"log",
"start-session",
"flush",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In 616bff8 we "fix" the issue where requests in-flight are potentially duplicated to disk and sent twice; this can happen for normal events too, but the problem with Sessions (that predates this PR) is that there is no deduplication logic server-side for our sessions (since we currently have no identifier for a session).

Since Sessions are to-be-reworked anyway, I'm fine with leaving this as a gap in the current implementation (but am also open to discuss this)

@JoshuaMoelans JoshuaMoelans changed the title feat: add send_session_start_update option fix: send session start envelope immediately Oct 27, 2026
@JoshuaMoelans
JoshuaMoelans marked this pull request as ready for review October 27, 2026 14:47
@jpnurmi

jpnurmi commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Do you prefer to have this in master, or could it target v1?

Comment thread src/sentry_session.c Resolved
(this simplifies a bunch of test setups, since we have a need for opt-out more often than opt-in, it makes sense having this as the default)
@JoshuaMoelans
JoshuaMoelans requested a review from jpnurmi October 27, 2026 20:19
Comment thread src/sentry_session.c Resolved
Comment thread src/sentry_backend.h Resolved
JoshuaMoelans and others added 2 commits October 28, 2026 09:49
…_session_start

# Conflicts:
#	CHANGELOG.md
#	src/sentry_backend.h
Without consent the transport drops the start update unless caching is
on, which left `init` false and the whole session uncounted once the
update that followed went out. The session now keeps `init` until the
update can be sent, and `sentry_user_consent_give` sends it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread src/sentry_session.c Resolved
@JoshuaMoelans
JoshuaMoelans merged commit e4930c1 into master Oct 28, 2026
111 of 112 checks passed
@JoshuaMoelans
JoshuaMoelans deleted the joshua/feat/capture_session_start branch October 28, 2026 11:50
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.

3 participants