Skip to content

Commit

Permalink
feat: add EndpointConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Apr 16, 2020
1 parent f7cb9cc commit 30418a0
Show file tree
Hide file tree
Showing 14 changed files with 192 additions and 58 deletions.
1 change: 1 addition & 0 deletions Bugsnag.podspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"Source/BugsnagConfiguration.h",
"Source/BugsnagDevice.h",
"Source/BugsnagDeviceWithState.h",
"Source/BugsnagEndpointConfiguration.h",
"Source/BugsnagError.h",
"Source/BugsnagEvent.h",
"Source/BugsnagMetadata.h",
Expand Down
46 changes: 30 additions & 16 deletions OSX/Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
8A87352C1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A87352B1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h */; settings = {ATTRIBUTES = (Public, ); }; };
8AD1E3FA23EDDD4F0044F919 /* BSGConnectivityTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD1E3F823EDDD3F0044F919 /* BSGConnectivityTest.m */; };
8AD9FA891E086351002859A7 /* BugsnagConfigurationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD9FA851E0862DC002859A7 /* BugsnagConfigurationTests.m */; };
E71DB9F6244763B400D0161E /* BugsnagEndpointConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = E71DB9F4244763B400D0161E /* BugsnagEndpointConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
E71DB9F7244763B400D0161E /* BugsnagEndpointConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = E71DB9F5244763B400D0161E /* BugsnagEndpointConfiguration.m */; };
E71DBA0224485D1D00D0161E /* BugsnagSessionTrackerStopTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E71DB9FC24485D1C00D0161E /* BugsnagSessionTrackerStopTest.m */; };
E71DBA0324485D1D00D0161E /* BugsnagClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E71DB9FE24485D1D00D0161E /* BugsnagClientTests.m */; };
E71DBA0424485D1D00D0161E /* BugsnagTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E71DB9FF24485D1D00D0161E /* BugsnagTests.m */; };
E71DBA0524485D1D00D0161E /* BugsnagMetadataTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E71DBA0024485D1D00D0161E /* BugsnagMetadataTests.m */; };
E71DBA0624485D1D00D0161E /* BugsnagPluginTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E71DBA0124485D1D00D0161E /* BugsnagPluginTest.m */; };
E722105E243B6A0F0083CF15 /* BugsnagStackframeTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E722105D243B6A0E0083CF15 /* BugsnagStackframeTest.m */; };
E72352C11F55924A00436528 /* BSGConnectivity.h in Headers */ = {isa = PBXBuildFile; fileRef = E72352BF1F55924A00436528 /* BSGConnectivity.h */; };
E72352C21F55924A00436528 /* BSGConnectivity.m in Sources */ = {isa = PBXBuildFile; fileRef = E72352C01F55924A00436528 /* BSGConnectivity.m */; };
Expand Down Expand Up @@ -274,6 +281,14 @@
8A87352B1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_KSCrashReportWriter.h; path = ../Source/BSG_KSCrashReportWriter.h; sourceTree = SOURCE_ROOT; };
8AD1E3F823EDDD3F0044F919 /* BSGConnectivityTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSGConnectivityTest.m; sourceTree = "<group>"; };
8AD9FA851E0862DC002859A7 /* BugsnagConfigurationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagConfigurationTests.m; path = ../Tests/BugsnagConfigurationTests.m; sourceTree = SOURCE_ROOT; };
E71DB9F4244763B400D0161E /* BugsnagEndpointConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BugsnagEndpointConfiguration.h; path = ../Source/BugsnagEndpointConfiguration.h; sourceTree = "<group>"; };
E71DB9F5244763B400D0161E /* BugsnagEndpointConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagEndpointConfiguration.m; path = ../Source/BugsnagEndpointConfiguration.m; sourceTree = "<group>"; };
E71DB9FC24485D1C00D0161E /* BugsnagSessionTrackerStopTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagSessionTrackerStopTest.m; sourceTree = "<group>"; };
E71DB9FD24485D1D00D0161E /* BugsnagTestConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BugsnagTestConstants.h; sourceTree = "<group>"; };
E71DB9FE24485D1D00D0161E /* BugsnagClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagClientTests.m; sourceTree = "<group>"; };
E71DB9FF24485D1D00D0161E /* BugsnagTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagTests.m; sourceTree = "<group>"; };
E71DBA0024485D1D00D0161E /* BugsnagMetadataTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagMetadataTests.m; sourceTree = "<group>"; };
E71DBA0124485D1D00D0161E /* BugsnagPluginTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagPluginTest.m; sourceTree = "<group>"; };
E722105D243B6A0E0083CF15 /* BugsnagStackframeTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagStackframeTest.m; sourceTree = "<group>"; };
E72352BF1F55924A00436528 /* BSGConnectivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSGConnectivity.h; path = ../Source/BSGConnectivity.h; sourceTree = SOURCE_ROOT; };
E72352C01F55924A00436528 /* BSGConnectivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSGConnectivity.m; path = ../Source/BSGConnectivity.m; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -535,36 +550,26 @@
00F9393223FC168F008C7073 /* BugsnagBaseUnitTest.m */,
8A2C8FE01C6BC38200846019 /* BugsnagBreadcrumbsTest.m */,
E790C41F2432314A006FFB26 /* BugsnagClientMirrorTest.m */,
E71DB9FE24485D1D00D0161E /* BugsnagClientTests.m */,
4B406C1622CAD96400464D1D /* BugsnagCollectionsBSGDictMergeTest.m */,
4B406C1722CAD96400464D1D /* BugsnagCollectionsBSGDictSetSafeObjectTest.m */,
4B775FD222CBE02A004839C5 /* BugsnagCollectionsBSGDictInsertIfNotNilTest.m */,
8AD9FA851E0862DC002859A7 /* BugsnagConfigurationTests.m */,
E7A9E56C2436365300D99F8A /* BugsnagDeviceTest.m */,
00D7ACA223E984B300FBE4A7 /* BugsnagEventTests.m */,
E762E9F71F73F7E900E82B43 /* BugsnagHandledStateTest.m */,
E71DBA0024485D1D00D0161E /* BugsnagMetadataTests.m */,
E7AB4B9D2423E184004F015A /* BugsnagOnBreadcrumbTest.m */,
E71DBA0124485D1D00D0161E /* BugsnagPluginTest.m */,
E791482D1FD82B0C003EFEBF /* BugsnagSessionTest.m */,
E791482B1FD82B0C003EFEBF /* BugsnagSessionTrackerTest.m */,
E71DB9FC24485D1C00D0161E /* BugsnagSessionTrackerStopTest.m */,
E791482C1FD82B0C003EFEBF /* BugsnagSessionTrackingPayloadTest.m */,
8A2C8FE21C6BC38200846019 /* BugsnagSinkTests.m */,
00F9393B23FD2D9B008C7073 /* BugsnagTestsDummyClass.h */,
00F9393A23FD2D9B008C7073 /* BugsnagTestsDummyClass.m */,
E791482E1FD82B0C003EFEBF /* BugsnagUserTest.m */,
E7D2E675243B8FB6005A3041 /* BugsnagStacktraceTest.m */,
E722105D243B6A0E0083CF15 /* BugsnagStackframeTest.m */,
00F9393B23FD2D9B008C7073 /* BugsnagTestsDummyClass.h */,
00F9393A23FD2D9B008C7073 /* BugsnagTestsDummyClass.m */,
E7529FA1243CAE3F006B4932 /* BugsnagThreadSerializationTest.m */,
E7529F9F243CAE34006B4932 /* BugsnagThreadTest.m */,
E791482E1FD82B0C003EFEBF /* BugsnagUserTest.m */,
E791482E1FD82B0C003EFEBF /* BugsnagUserTest.m */,
00F9393B23FD2D9B008C7073 /* BugsnagTestsDummyClass.h */,
00F9393A23FD2D9B008C7073 /* BugsnagTestsDummyClass.m */,
E7529FA1243CAE3F006B4932 /* BugsnagThreadSerializationTest.m */,
E7529F9F243CAE34006B4932 /* BugsnagThreadTest.m */,
E791482E1FD82B0C003EFEBF /* BugsnagUserTest.m */,
E7D2E675243B8FB6005A3041 /* BugsnagStacktraceTest.m */,
E722105D243B6A0E0083CF15 /* BugsnagStackframeTest.m */,
E71DB9FF24485D1D00D0161E /* BugsnagTests.m */,
E71DB9FD24485D1D00D0161E /* BugsnagTestConstants.h */,
00F9393B23FD2D9B008C7073 /* BugsnagTestsDummyClass.h */,
00F9393A23FD2D9B008C7073 /* BugsnagTestsDummyClass.m */,
E7529FA1243CAE3F006B4932 /* BugsnagThreadSerializationTest.m */,
Expand Down Expand Up @@ -747,6 +752,8 @@
E72352C01F55924A00436528 /* BSGConnectivity.m */,
E791483E1FD82B35003EFEBF /* BugsnagApiClient.h */,
E791483D1FD82B35003EFEBF /* BugsnagApiClient.m */,
E71DB9F4244763B400D0161E /* BugsnagEndpointConfiguration.h */,
E71DB9F5244763B400D0161E /* BugsnagEndpointConfiguration.m */,
E79E6AFE1F4E3847002B35F9 /* BugsnagErrorReportApiClient.h */,
E79E6AFF1F4E3847002B35F9 /* BugsnagErrorReportApiClient.m */,
E79148411FD82B35003EFEBF /* BugsnagSessionTrackingApiClient.h */,
Expand Down Expand Up @@ -877,6 +884,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
E71DB9F6244763B400D0161E /* BugsnagEndpointConfiguration.h in Headers */,
E790C47C24349CE2006FFB26 /* BugsnagThread.h in Headers */,
E790C47A24349CE2006FFB26 /* BugsnagStackframe.h in Headers */,
E790C47624349CE2006FFB26 /* BugsnagError.h in Headers */,
Expand Down Expand Up @@ -1071,6 +1079,7 @@
8A2C8FDE1C6BC2C800846019 /* BugsnagSink.m in Sources */,
0089B6EB2411682000D5A7F2 /* BugsnagClient.m in Sources */,
E79E6BBE1F4E3850002B35F9 /* BSG_KSMach.c in Sources */,
E71DB9F7244763B400D0161E /* BugsnagEndpointConfiguration.m in Sources */,
E79E6B991F4E3850002B35F9 /* BSG_KSCrashType.c in Sources */,
E79E6BC01F4E3850002B35F9 /* BSG_KSMach_Arm.c in Sources */,
E79E6B8F1F4E3850002B35F9 /* BSG_KSCrashDoctor.m in Sources */,
Expand Down Expand Up @@ -1167,14 +1176,19 @@
00F9393323FC168F008C7073 /* BugsnagBaseUnitTest.m in Sources */,
E7CE78BE1FD94E77001D07E0 /* KSCrashSentry_NSException_Tests.m in Sources */,
E7CE78C21FD94E77001D07E0 /* KSDynamicLinker_Tests.m in Sources */,
E71DBA0524485D1D00D0161E /* BugsnagMetadataTests.m in Sources */,
E71DBA0324485D1D00D0161E /* BugsnagClientTests.m in Sources */,
E722105E243B6A0F0083CF15 /* BugsnagStackframeTest.m in Sources */,
E7CE78CA1FD94E77001D07E0 /* KSString_Tests.m in Sources */,
E762E9F91F73F7F300E82B43 /* BugsnagHandledStateTest.m in Sources */,
E71DBA0624485D1D00D0161E /* BugsnagPluginTest.m in Sources */,
E7CE78C51FD94E77001D07E0 /* KSLogger_Tests.m in Sources */,
E7CE78C11FD94E77001D07E0 /* KSCrashState_Tests.m in Sources */,
E7529FA0243CAE35006B4932 /* BugsnagThreadTest.m in Sources */,
E7AB4B9E2423E184004F015A /* BugsnagOnBreadcrumbTest.m in Sources */,
E71DBA0424485D1D00D0161E /* BugsnagTests.m in Sources */,
E7CE78C31FD94E77001D07E0 /* KSFileUtils_Tests.m in Sources */,
E71DBA0224485D1D00D0161E /* BugsnagSessionTrackerStopTest.m in Sources */,
E7CE78BC1FD94E77001D07E0 /* KSCrashReportStore_Tests.m in Sources */,
E79148611FD82BB7003EFEBF /* BugsnagSessionTrackerTest.m in Sources */,
E79148591FD82BAE003EFEBF /* BugsnagSessionTest.m in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Source/Bugsnag.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import "BugsnagAppWithState.h"
#import "BugsnagDevice.h"
#import "BugsnagDeviceWithState.h"
#import "BugsnagEndpointConfiguration.h"
#import "BugsnagError.h"
#import "BugsnagStackframe.h"
#import "BugsnagThread.h"
Expand Down
5 changes: 2 additions & 3 deletions Source/BugsnagConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import "BugsnagMetadataStore.h"

@class BugsnagUser;
@class BugsnagEndpointConfiguration;

/**
* BugsnagConfiguration error constants
Expand Down Expand Up @@ -198,9 +199,7 @@ typedef NS_OPTIONS(NSUInteger, BSGErrorType) {
*
* @throws an assertion if the notify endpoint is not a valid URL
*/

- (void)setEndpointsForNotify:(NSString *_Nonnull)notify
sessions:(NSString *_Nonnull)sessions NS_SWIFT_NAME(setEndpoints(notify:sessions:));
@property(nonnull, nonatomic) BugsnagEndpointConfiguration *endpoints;

// =============================================================================
// MARK: - User
Expand Down
12 changes: 7 additions & 5 deletions Source/BugsnagConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#import "BugsnagBreadcrumbs.h"
#import "BugsnagMetadataStore.h"
#import "BSGSerialization.h"
#import "BugsnagEndpointConfiguration.h"

static NSString *const kHeaderApiPayloadVersion = @"Bugsnag-Payload-Version";
static NSString *const kHeaderApiKey = @"Bugsnag-Api-Key";
Expand Down Expand Up @@ -123,8 +124,7 @@ - (nonnull id)copyWithZone:(nullable NSZone *)zone {
[copy setEnabledReleaseStages:self.enabledReleaseStages];
[copy setMaxBreadcrumbs:self.maxBreadcrumbs];
[copy setMetadata: [[BugsnagMetadata alloc] initWithDictionary:[[self.metadata toDictionary] mutableCopy]]];
[copy setEndpointsForNotify:self.notifyURL.absoluteString
sessions:self.sessionURL.absoluteString];
[copy setEndpoints:self.endpoints];
[copy setOnBreadcrumbBlocks:[self.onBreadcrumbBlocks mutableCopy]];
[copy setOnCrashHandler:self.onCrashHandler];
[copy setOnSendBlocks:[self.onSendBlocks mutableCopy]];
Expand Down Expand Up @@ -183,6 +183,7 @@ - (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey
_metadata = [[BugsnagMetadata alloc] init];
_config = [[BugsnagMetadata alloc] init];
_apiKey = apiKey;
_endpoints = [BugsnagEndpointConfiguration new];
_sessionURL = [NSURL URLWithString:@"https://sessions.bugsnag.com"];
_autoDetectErrors = YES;
_notifyURL = [NSURL URLWithString:BSGDefaultNotifyUrl];
Expand Down Expand Up @@ -324,9 +325,10 @@ - (NSDictionary *)sessionApiHeaders {
};
}

- (void)setEndpointsForNotify:(NSString *_Nonnull)notify sessions:(NSString *_Nonnull)sessions {
_notifyURL = [NSURL URLWithString:notify];
_sessionURL = [NSURL URLWithString:sessions];
- (void)setEndpoints:(BugsnagEndpointConfiguration *)endpoints {
_endpoints = endpoints;
_notifyURL = [NSURL URLWithString:endpoints.notify];
_sessionURL = [NSURL URLWithString:endpoints.sessions];

NSAssert([self isValidUrl:_notifyURL], @"Invalid URL supplied for notify endpoint");

Expand Down
34 changes: 34 additions & 0 deletions Source/BugsnagEndpointConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// BugsnagEndpointConfiguration.h
// Bugsnag
//
// Created by Jamie Lynch on 15/04/2020.
// Copyright © 2020 Bugsnag. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* Set the endpoints to send data to. By default we'll send error reports to
* https://notify.bugsnag.com, and sessions to https://sessions.bugsnag.com, but you can
* override this if you are using Bugsnag Enterprise to point to your own Bugsnag endpoints.
*/
@interface BugsnagEndpointConfiguration : NSObject

/**
* Configures the endpoint to which events should be sent
*/
@property NSString *notify;

/**
* Configures the endpoint to which sessions should be sent
*/
@property NSString *sessions;

- (instancetype)initWithNotify:(NSString *)notify sessions:(NSString *)sessions;

@end

NS_ASSUME_NONNULL_END
28 changes: 28 additions & 0 deletions Source/BugsnagEndpointConfiguration.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// BugsnagEndpointConfiguration.m
// Bugsnag
//
// Created by Jamie Lynch on 15/04/2020.
// Copyright © 2020 Bugsnag. All rights reserved.
//

#import "BugsnagEndpointConfiguration.h"

@implementation BugsnagEndpointConfiguration

- (instancetype)init {
if (self = [super init]) {
_notify = @"https://notify.bugsnag.com";
_sessions = @"https://sessions.bugsnag.com";
}
return self;
}

- (instancetype)initWithNotify:(NSString *)notify sessions:(NSString *)sessions {
if (self = [super init]) {
_notify = notify;
_sessions = sessions;
}
return self;
}
@end
Loading

0 comments on commit 30418a0

Please sign in to comment.