Skip to content

Commit c17b654

Browse files
committed
Always add the flags context (even if empty) but only for error events.
1 parent a5c6da2 commit c17b654

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sentry_sdk/scope.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,10 +1378,10 @@ def _apply_contexts_to_event(self, event, hint, options):
13781378
else:
13791379
contexts["trace"] = self.get_trace_context()
13801380

1381-
# Add "flags" context
1381+
def _apply_flags_to_event(self, event, hint, options):
1382+
# type: (Event, Hint, Optional[Dict[str, Any]]) -> None
13821383
flags = self.flags.get()
1383-
if len(flags) > 0:
1384-
contexts.setdefault("flags", {}).update({"values": flags})
1384+
event.setdefault("contexts", {}).setdefault("flags", {}).update({"values": flags})
13851385

13861386
def _drop(self, cause, ty):
13871387
# type: (Any, str) -> Optional[Any]
@@ -1481,6 +1481,7 @@ def apply_to_event(
14811481

14821482
if not is_transaction and not is_check_in:
14831483
self._apply_breadcrumbs_to_event(event, hint, options)
1484+
self._apply_flags_to_event(event, hint, options)
14841485

14851486
event = self.run_error_processors(event, hint)
14861487
if event is None:

0 commit comments

Comments
 (0)