Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Device time of report capture to JSON payload #315

Merged
merged 8 commits into from Oct 31, 2018
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,13 @@
Changelog
=========

## 5.17.1 (TBD)

### Bug Fixes

* Add Device time of report capture to JSON payload
[#315](https://github.com/bugsnag/bugsnag-cocoa/pull/315)

## 5.17.0 (2018-09-25)

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions Source/BugsnagKSCrashSysInfoParser.m
Expand Up @@ -33,6 +33,7 @@
[report valueForKeyPath:@"system.memory.free"],
@"freeMemory");

BSGDictSetSafeObject(device, [report valueForKeyPath:@"report.timestamp"], @"time");

NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(
Expand Down
6 changes: 4 additions & 2 deletions Tests/BugsnagSinkTests.m
Expand Up @@ -259,9 +259,9 @@ - (void)testEventDevice {
NSDictionary *device = event[@"device"];
XCTAssertNotNil(device);
#if TARGET_OS_IPHONE || TARGET_OS_TV || TARGET_IPHONE_SIMULATOR
XCTAssertEqual(18, device.count);
XCTAssertEqual(19, device.count);
#else
XCTAssertEqual(17, device.count);
XCTAssertEqual(18, device.count);
#endif

XCTAssertEqualObjects(device[@"id"], @"f6d519a74213a57f8d052c53febfeee6f856d062");
Expand All @@ -277,6 +277,8 @@ - (void)testEventDevice {
XCTAssertEqualObjects(device[@"jailbroken"], @YES);
XCTAssertEqualObjects(device[@"freeMemory"], @742920192);
XCTAssertEqualObjects(device[@"orientation"], @"unknown");
XCTAssertEqualObjects(device[@"time"], @"2014-12-02T01:56:13Z");

#if defined(__LP64__)
XCTAssertEqualObjects(device[@"wordSize"], @64);
#else
Expand Down
1 change: 1 addition & 0 deletions features/crashprobe.feature
Expand Up @@ -218,6 +218,7 @@ Scenario: Throw a NSException
And the "method" of stack frame 0 equals "__exceptionPreprocess"
And the "method" of stack frame 1 equals "objc_exception_throw"
And the "method" of stack frame 2 equals "-[ObjCExceptionScenario run]"
And the event "device.time" is within 30 seconds of the current timestamp

Scenario: Access a non-object as an object
When I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
Expand Down
1 change: 1 addition & 0 deletions features/handled_errors.feature
Expand Up @@ -6,6 +6,7 @@ Scenario: Override errorClass and message from a notifyError() callback
And the request is a valid for the error reporting API
And the exception "errorClass" equals "Bar"
And the exception "message" equals "Foo"
And the event "device.time" is within 30 seconds of the current timestamp

Scenario: Reporting an NSError
When I run "HandledErrorScenario" with the defaults on "iPhone8-11.2"
Expand Down
9 changes: 9 additions & 0 deletions features/steps/ios_steps.rb
Expand Up @@ -63,3 +63,12 @@
end, "No event matches the following values: #{values}")
end
end

Then("the event {string} is within {int} seconds of the current timestamp") do |field, threshold_secs|
value = read_key_path(find_request(0)[:body], "events.0.#{field}")
assert_not_nil(value, "Expected a timestamp")
nowSecs = Time.now.to_i
thenSecs = Time.parse(value).to_i
delta = nowSecs - thenSecs
assert_true(delta.abs < threshold_secs, "Expected current timestamp, but received #{value}")
end