Skip to content

feat: add sentry_update_context#1835

Merged
JoshuaMoelans merged 7 commits into
masterfrom
joshua/feat/merge_context
Jul 2, 2026
Merged

feat: add sentry_update_context#1835
JoshuaMoelans merged 7 commits into
masterfrom
joshua/feat/merge_context

Conversation

@JoshuaMoelans

@JoshuaMoelans JoshuaMoelans commented Jul 1, 2026

Copy link
Copy Markdown
Member

Adding this for downstream SDKs, so they can avoid fully overwriting pre-set context from our native SDK init.

Popped up as part of https://github.com/getsentry/sentry-xbox/pull/151 where the unreal integration test calls AddDeviceContext which does a plain set_by_key, making us lose device.X context set by the console SDK.

Now with sentry_update_context we only overwrite existing keys' values, and also add the new keys from the passed-in object to the context. For example

ctx={a:0, b:1, c:2}
sentry_update_context(ctx, {a:-1, d:3})
// ctx becomes {a:-1, b:1, c:2, d:3}

@JoshuaMoelans JoshuaMoelans changed the title feat: add sentry_merge_context (WIP) feat: add sentry_merge_context Jul 1, 2026
Comment thread src/sentry_core.c Outdated
Comment thread src/sentry_core.c
Comment thread include/sentry.h Outdated
Comment thread include/sentry.h
- does the same but different, updating overwrites values of keys that collide & adds the new passed-in-value's keys to the context too. (before, it would NOT overwrite, only add)
@JoshuaMoelans JoshuaMoelans changed the title (WIP) feat: add sentry_merge_context feat: add sentry_update_context Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 7ddd241

@jpnurmi jpnurmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

@JoshuaMoelans JoshuaMoelans merged commit 8ae6676 into master Jul 2, 2026
102 of 103 checks passed
@JoshuaMoelans JoshuaMoelans deleted the joshua/feat/merge_context branch July 2, 2026 12:44
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.

2 participants