BugsnagMetadataStore

Objective-C

@protocol BugsnagMetadataStore <NSObject>

Swift

protocol BugsnagMetadataStore : NSObjectProtocol

An internal protocol defining methods a Bugsnag metadata store must implement.

  • Merge supplied and existing metadata.

    • Non-null values will replace existing values for identical keys.

    • Null values will remove the existing key/value pair if the key exists. Where null-valued keys do not exist they will not be set. (Since ObjC dicts can’t store ‘nil’ directly we assume [NSNUll null])

    • Tabs are only created if at least one value is valid.

    • Invalid values (i.e. unserializable to JSON) are logged and ignored.

    Declaration

    Objective-C

    - (void)addMetadata:(NSDictionary *_Nonnull)metadata
              toSection:(NSString *_Nonnull)sectionName;

    Swift

    func addMetadata(_ metadata: [AnyHashable : Any], section sectionName: String)

    Parameters

    metadata

    A dictionary of string -> id key/value pairs. Values should be serializable to JSON.

    sectionName

    The name of the metadata section

  • Add a piece of metadata to a particular key in a particular section.

    • Non-null values will replace existing values for identical keys.

    • Null values will remove the existing key/value pair if the key exists. Where null-valued keys do not exist they will not be set. (Since ObjC dicts can’t store ‘nil’ directly we assume [NSNUll null])

    • Tabs are only created if at least one value is valid.

    • Invalid values (i.e. unserializable to JSON) are logged and ignored.

    Declaration

    Objective-C

    - (void)addMetadata:(id _Nullable)metadata
                withKey:(NSString *_Nonnull)key
              toSection:(NSString *_Nonnull)sectionName;

    Swift

    func addMetadata(_ metadata: Any?, key: String, section sectionName: String)

    Parameters

    metadata

    A dictionary of string -> id key/value pairs. Values should be serializable to JSON.

    key

    The metadata key to store the value under

    sectionName

    The name of the metadata section

  • Get a named metadata section

    Declaration

    Objective-C

    - (NSMutableDictionary *_Nullable)getMetadataFromSection:
        (NSString *_Nonnull)sectionName;

    Swift

    func getMetadata(section sectionName: String) -> NSMutableDictionary?

    Parameters

    sectionName

    The name of the section @returns The mutable dictionary representing the metadata section, if it exists, or nil if not.

  • Get a keyed value from a named metadata section

    Declaration

    Objective-C

    - (id _Nullable)getMetadataFromSection:(NSString *_Nonnull)sectionName
                                   withKey:(NSString *_Nonnull)key;

    Swift

    func getMetadata(section sectionName: String, key: String) -> Any?

    Parameters

    sectionName

    The name of the section

    key

    The key @returns The value if it exists, or nil if not.

  • Remove a named metadata section, if it exists.

    Declaration

    Objective-C

    - (void)clearMetadataFromSection:(NSString *_Nonnull)sectionName;

    Swift

    func clearMetadata(section sectionName: String)

    Parameters

    sectionName

    The section name

  • Remove a specific value for a specific key in a specific metadata section. If either section or key do not exist no action is taken.

    Declaration

    Objective-C

    - (void)clearMetadataFromSection:(NSString *_Nonnull)sectionName
                             withKey:(NSString *_Nonnull)key;

    Swift

    func clearMetadata(section sectionName: String, key: String)

    Parameters

    sectionName

    The section name

    key

    the metadata key