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

Make metadata interface consistent across config client and event #513

Conversation

robinmacharg
Copy link
Contributor

@robinmacharg robinmacharg commented Mar 31, 2020

Goal

Implement a consistent metadata interface across Config, Client and Event classes.

Design

A BugsnagMetadataStore instance-level protocol is defined, as well as a class-level version of the same, containing the following methods:

  • addMetadata:toSection:
  • addMetadata:withKey:toSection:
  • getMetadataFromSection:
  • getMetadataFromSection:withKey:
  • clearMetadataFromSection:
  • clearMetadataFromSection:withKey:

Bugsnag, BugsnagClient, BugsnagEvent, BugsnagConfig and BugsnagMetadata classes are all changed to conform to this.

Internal dictionary metadata implementations are replaced with BugsnagMetadata objects.

Changeset

A wide range of files, not limited to those mentioned above, since many references to object metadata also needed updated. Test apps have also been updated.

Tests

No significant new tests added, but many changes to existing ones to adopt the new non-dictionary access syntax.

Review

Outstanding Questions

  • This pull request is ready for:
    • Initial review of the intended approach, not yet feature complete
    • Structural review of the classes, functions, and properties modified
    • Final review
  • The correct target branch has been selected (master for fixes, next for
    features)
  • Consistency across platforms for structures or concepts added or modified
  • Consistency between the changeset and the goal stated above
  • Internal consistency with the rest of the library - is there any overlap between existing interfaces and any which have been added?
  • Usage friction - is the proposed change in usage cumbersome or complicated?
  • Performance and complexity - are there any cases of unexpected O(n^3) when iterating, recursing, flat mapping, etc?
  • Concurrency concerns - if components are accessed asynchronously, what issues will arise
  • Thoroughness of added tests and any missing edge cases
  • Idiomatic use of the language

Source/BugsnagClient.m Outdated Show resolved Hide resolved
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

Happy with the overall plan, and the public signature changes made in this changeset.

Making BugsnagMetadata conform to the protocol would be good, as the implementation for adding/getting/clearing metadata could be contained within there. BugsnagClient and BugsnagEvent could then hold a property of type BugsnagMetadata and forward on any method calls to it, rather than implementing each call in multiple classes. We've done something similar on Android here.

Robin Macharg added 6 commits March 31, 2020 10:23
- Added NS_SWIFT_NAMES to protocol.
- Added class-level MetadataStore protocol for Bugsnag.
- Removed header declarations.
- Added missing method to Bugsnag
- (temporary)Corrected source of metadata in a couple of places.
- Corrected interface mutability of dictionaries.
- Fixed up tests
Added deep dict and array copy to enable metadata copying
- Removed erroneous parse code
- Updated tests
- Made Event initialisation allow nullable Metadata (new object is subbed)
- Fixed Bugsnag top-level addMetadata methods
- Removed <NSMutableCopying> from BugsnagMetadata
@robinmacharg robinmacharg force-pushed the robin/Make-metadata-interface-consistent-across-Config-Client-and-Event branch from 2cdc05f to 7eb62ba Compare April 1, 2020 06:39
Robin Macharg added 2 commits April 1, 2020 13:45
…erface-consistent-across-Config-Client-and-Event

# Conflicts:
#	Source/Bugsnag.h
@robinmacharg robinmacharg marked this pull request as ready for review April 1, 2020 12:59
@fractalwrench fractalwrench requested review from fractalwrench and removed request for tomlongridge April 1, 2020 14:49
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

This looks good - and is a hard thing to change. I've left a few inline comments but think this is basically there and will be ready for merging once they've been resolved.

CHANGELOG.md Outdated Show resolved Hide resolved
Source/BugsnagMetadataStore.h Outdated Show resolved Hide resolved
Tests/BugsnagClientTests.m Outdated Show resolved Hide resolved
Source/BugsnagEvent.m Show resolved Hide resolved
Source/Bugsnag.m Show resolved Hide resolved
Source/BugsnagMetadata.m Outdated Show resolved Hide resolved
Source/BugsnagMetadata.m Outdated Show resolved Hide resolved
Source/BugsnagMetadata.m Show resolved Hide resolved
Source/BugsnagEvent.m Outdated Show resolved Hide resolved
Source/BugsnagEvent.m Outdated Show resolved Hide resolved
- Added docs
- Renamed <BugsnagMetadataStore> parameters
- Removed unnecessary deepCopies and mutating modifiers
@robinmacharg robinmacharg force-pushed the robin/Make-metadata-interface-consistent-across-Config-Client-and-Event branch from 0707d65 to 79cb452 Compare April 2, 2020 10:29
Robin Macharg added 2 commits April 2, 2020 11:34
…erface-consistent-across-Config-Client-and-Event

# Conflicts:
#	Bugsnag.podspec.json
@robinmacharg robinmacharg merged commit 56e0e4e into v6 Apr 2, 2020
@robinmacharg robinmacharg deleted the robin/Make-metadata-interface-consistent-across-Config-Client-and-Event branch April 2, 2020 19:35
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