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

Convert event.app from NSDictionary to a structured class #520

Merged
merged 2 commits into from
Apr 6, 2020

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Apr 2, 2020

Goal

Converts event.app from an NSDictionary to a structured class where each field is represented as a property.

BugsnagApp is used for sessions, and contains stateless properties that do not change over the lifecycle of an application. BugsnagAppWithState extends this class and is used for events, and contains stateful properties that change for each error - e.g. durationInForeground.

Changeset

  • Added BugsnagApp and BugsnagAppWithState classes with properties for each field in the spec
  • Updated BugsnagConfiguration to have a default value for appType, rather than parsing in the BugsnagEvent
  • Altered BugsnagEvent to use readonly BugsnagAppWithState for event.app
  • Refactored BSGParseApp and BSGParseAppWithState methods into new BugsnagApp classes, so that they can parse a KSCrash report and populate their fields
  • Extracted JSON serialization into BugsnagApp/WithState from BugsnagEvent
  • Removed app.name as it is the same as app.id

Tests

  • Added unit test to verify that BugsnagApp and BugsnagAppWithState populate correctly, and that they serialize JSON correctly
  • Updated existing test coverage
  • Ran example app and verified that app data is sent to the dashboard for an event

@fractalwrench fractalwrench changed the title feat: add App/AppWithState interface Make event.app a structured class Apr 2, 2020
@fractalwrench fractalwrench changed the title Make event.app a structured class Convert event.app from NSDictionary to a structured class Apr 2, 2020
@fractalwrench fractalwrench force-pushed the v6-structured-app branch 3 times, most recently from ae67b46 to 554956a Compare April 2, 2020 16:33
@fractalwrench fractalwrench marked this pull request as ready for review April 3, 2020 08:28
Source/BugsnagEvent.m Outdated Show resolved Hide resolved
Tests/BugsnagAppTest.m Outdated Show resolved Hide resolved
Source/BugsnagApp.m Outdated Show resolved Hide resolved
Copy link
Contributor

@robinmacharg robinmacharg left a comment

Choose a reason for hiding this comment

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

From what I understand, looks good. And 68% coverage on unit tests, which is definitely going in the right direction! Couple of in-line comments, mostly opinionated nits over formatting.

Is it worth putting new structured containers in a group in XCode to make working with them easier? Assuming that the podspec needs updated to match any folder nesting. The list of files is now considerable (i.e. more than a screen-full). Failing that the new additions should be arranged alphabetically in XCode.

@fractalwrench
Copy link
Contributor Author

Is it worth putting new structured containers in a group in XCode to make working with them easier?

This is definitely worth doing - I'll raise a separate PR to address this.

Copy link
Contributor

@robinmacharg robinmacharg left a comment

Choose a reason for hiding this comment

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

Looking good.

@fractalwrench fractalwrench merged commit 2cf8800 into v6 Apr 6, 2020
@fractalwrench fractalwrench deleted the v6-structured-app branch April 6, 2020 08:08
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