Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Add support for script context and variables on Apple platforms ([#306](https://github.com/getsentry/sentry-godot/pull/306))

### Dependencies

- Bump Cocoa SDK from v8.54.0 to v8.55.0 ([#318](https://github.com/getsentry/sentry-godot/pull/318))
Expand Down
17 changes: 15 additions & 2 deletions src/sentry/cocoa/cocoa_event.mm
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,21 @@
cocoa_frame.inApp = bool_to_objc(frame.in_app);
cocoa_frame.platform = string_to_objc(frame.platform);

// TODO: unable to pass context_line, pre_context, post_context.
// TODO: unable to pass local/member vars.
if (!frame.context_line.is_empty()) {
cocoa_frame.contextLine = string_to_objc(frame.context_line);
cocoa_frame.preContext = string_array_to_objc(frame.pre_context);
cocoa_frame.postContext = string_array_to_objc(frame.post_context);
}

if (!frame.vars.is_empty()) {
NSMutableDictionary *objc_vars = [NSMutableDictionary dictionaryWithCapacity:frame.vars.size()];
for (const auto &var : frame.vars) {
NSString *key = string_to_objc(var.first);
id value = variant_to_objc(var.second);
objc_vars[key] = value;
}
cocoa_frame.vars = objc_vars;
}

[mut_frames addObject:cocoa_frame];
}
Expand Down
1 change: 1 addition & 0 deletions src/sentry/cocoa/cocoa_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ _FORCE_INLINE_ NSNumber *double_to_objc(double p_num) {

NSObject *variant_to_objc(const godot::Variant &p_value, int p_depth = 0);
NSDictionary *dictionary_to_objc(const godot::Dictionary &p_dictionary);
NSArray<NSString *> *string_array_to_objc(const godot::PackedStringArray &p_array);

} //namespace sentry::cocoa

Expand Down
8 changes: 8 additions & 0 deletions src/sentry/cocoa/cocoa_util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,12 @@
return (NSDictionary *)variant_to_objc(p_dictionary);
}

NSArray<NSString *> *string_array_to_objc(const godot::PackedStringArray &p_array) {
NSMutableArray<NSString *> *objc_array = [NSMutableArray arrayWithCapacity:p_array.size()];
for (int i = 0; i < p_array.size(); i++) {
[objc_array addObject:string_to_objc(p_array[i])];
}
return objc_array;
}

} // namespace sentry::cocoa
Loading