Skip to content

WIP: feat: WER integration#1837

Draft
jpnurmi wants to merge 13 commits into
masterfrom
jpnurmi/feat/wer-integration
Draft

WIP: feat: WER integration#1837
jpnurmi wants to merge 13 commits into
masterfrom
jpnurmi/feat/wer-integration

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Warning

WIP    🚧🔨⏳⛔

The WER (Windows Error Reporting) integration:

  • enabled via cmake -DSENTRY_INTEGRATION_WER=ON (inspired by the existing Qt integration)
  • automatically wired up during sentry_init
  • based on the scope observer API (sentry_scope_observer_t, also WIP)
  • syncs tags and attachments to WER
    • WerRegisterCustomMetadata / WerUnregisterCustomMetadata (Windows 10 1703+)
    • WerRegisterFile / WerUnregisterFile
    • WerRegisterMemoryBlock / WerUnregisterMemoryBlock

jpnurmi added 13 commits July 2, 2026 15:31
Adds a sentry_integration_t struct with a register_func callback that is
called from sentry_init() while the scope lock is held. Integrations can
use this to create and register scope observers.

sentry_options_add_integration() stores integrations in options, which
takes ownership. An optional free_func is called before the integration
struct is freed.
Adds sentry_integration_wer_new() which creates an integration that uses
a scope observer to sync sentry scope state to Windows Error Reporting:

- Tags are synced via WerRegisterCustomMetadata (loaded dynamically for
  compatibility with pre-19H1 Windows 10 builds).
- File attachments are registered with WerRegisterFile.
- Buffer attachments are registered with WerRegisterMemoryBlock.

When tags or attachments are removed via the sentry API, the
corresponding WER registrations are cleaned up.
Replace the generic sentry_integration_t approach with a simpler pattern
matching the existing Qt integration (SENTRY_INTEGRATION_QT):

- Remove sentry_integration_t, sentry_options_add_integration(), and all
  the dynamic array management in options.
- Add a SENTRY_INTEGRATION_WER CMake option that conditionally compiles
  the WER integration source and sets the compile definition.
- sentry_integration_setup_wer(scope, options) is called from
  sentry_init() inside SENTRY_WITH_SCOPE_MUT.
- The WER integration uses static globals for wer.dll function pointers
  instead of a heap-allocated state struct.
The source file is already guarded with #ifdef SENTRY_PLATFORM_WINDOWS,
so it quietly becomes a no-op on other platforms without needing a
FATAL_ERROR.
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- WER integration ([#1837](https://github.com/getsentry/sentry-native/pull/1837))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against de2ad2d

@jpnurmi jpnurmi marked this pull request as draft July 2, 2026 13:52

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit de2ad2d. Configure here.

observer->remove_attachment = wer_remove_attachment;

sentry__scope_add_observer(scope, observer);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pre-init attachments skip WER

High Severity

During sentry_init, attachments from sentry_options_add_attachment are moved onto the global scope before WER setup registers its observer, and no add_attachment notifications run for that list. Those files never reach WerRegisterFile / WerRegisterMemoryBlock, so WER crash reports miss attachments that Sentry and crash backends still include.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de2ad2d. Configure here.

Comment thread src/sentry_scope.c
sentry_scope_set_level(sentry_scope_t *scope, sentry_level_t level)
{
scope->level = level;
SENTRY_NOTIFY_OBSERVERS(scope, set_level, level);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Scope attach skips observers

Medium Severity

sentry_scope_attach_file_n and sentry_scope_attach_bytes_n append to the scope attachment list without SENTRY_NOTIFY_OBSERVERS, while WER integration only reacts to add_attachment callbacks. Attachments added through the public scope attach APIs on the global scope are omitted from WER even though they are sent with Sentry events.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de2ad2d. Configure here.

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.

1 participant