Skip to content
This repository was archived by the owner on Sep 14, 2020. It is now read-only.

Commit 333c971

Browse files
Merge pull request #254 from bugsnag/next
Next release
2 parents af8f87b + 10e591b commit 333c971

16 files changed

Lines changed: 177 additions & 71 deletions

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ jobs:
1616
- android-26
1717
- extra-google-m2repository
1818
- extra-android-m2repository
19+
before_cache:
20+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
21+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
22+
cache:
23+
directories:
24+
- $HOME/.gradle/caches/
25+
- $HOME/.gradle/wrapper/
26+
- $HOME/.android/build-cache
1927
env:
2028
- ANDROID_TARGET=android-26 ANDROID_ABI=armeabi-v7a
2129
- ADB-INSTALL_TIMEOUT=5
@@ -42,6 +50,9 @@ jobs:
4250
language: objective-c
4351
os: osx
4452
osx_image: xcode9.3
53+
cache:
54+
- bundler
55+
- cocoapods
4556
xcode_project: ./cocoa/BugsnagReactNative.xcodeproj
4657
xcode_scheme: BugsnagReactNative
4758
install:

CHANGELOG.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
11
Changelog
22
=========
33

4+
## 2.10.0 (2018-07-03)
45

5-
## TBD
6+
This release alters the behaviour of the notifier to track sessions automatically.
7+
A session will be automatically captured on each app launch and sent to [https://sessions.bugsnag.com](https://sessions.bugsnag.com).
8+
9+
If you use Bugsnag On-Premise, it is recommended that you set your notify and session endpoints
10+
via `config.setEndpoints(String notify, String sessions)` on Android, and `config.setEndpoints(notify:sessions:)` on iOS. You should also initialise the Android/iOS components by passing a `config` parameter:
11+
12+
```java
13+
Configuration config = new Configuration("your-api-key-here");
14+
config.setEndpoints("https://notify.example.com", "https://sessions.example.com");
15+
BugsnagReactNative.start(this, config);
16+
```
17+
18+
```objc
19+
BugsnagConfiguration *config = [BugsnagConfiguration new];
20+
[config setEndpointsForNotify:@"http://notify.example.com"
21+
sessions:@"http://sessions.example.com"];
22+
[BugsnagReactNative startWithConfiguration:config];
23+
```
24+
25+
* Upgrade bugsnag-android to v4.5.0:
26+
* Enable automatic session tracking by default [#314](https://github.com/bugsnag/bugsnag-android/pull/314)
27+
* Trim long stacktraces to max limit of 200 [#324](https://github.com/bugsnag/bugsnag-android/pull/324)
28+
29+
* Upgrade bugsnag-cocoa to v5.16.0:
30+
* Enable automatic session tracking by default [#286](https://github.com/bugsnag/bugsnag-cocoa/pull/286)
31+
* Handle potential nil content value in RegisterErrorData class [#289](https://github.com/bugsnag/bugsnag-cocoa/pull/289)
632
733
### Bug fixes
834

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Bugsnag exception reporter for React Native
2-
[![Documentation](https://img.shields.io/badge/documentation-2.9.5-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)
2+
[![Documentation](https://img.shields.io/badge/documentation-2.10.0-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)
33

44
Automatic [React Native crash reporting](https://www.bugsnag.com/platforms/react-native-error-reporting/) with Bugsnag helps you detect both native OS and JavaScript errors in your React Native apps.
55

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ android {
88
minSdkVersion 16
99
targetSdkVersion 23
1010
versionCode 4
11-
versionName '2.9.5'
11+
versionName '2.10.0'
1212
}
1313
}
1414

1515
dependencies {
16-
compile 'com.bugsnag:bugsnag-android:4.4.1'
16+
compile 'com.bugsnag:bugsnag-android:4.5.0'
1717
compile 'com.facebook.react:react-native:+'
1818
}

android/src/main/java/com/bugsnag/BugsnagReactNative.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,23 @@ private void configureRuntimeOptions(Client client, ReadableMap options) {
207207
client.setAppVersion(version);
208208
}
209209

210+
String notify = null;
211+
String sessions = null;
212+
210213
if (options.hasKey("endpoint")) {
211-
String endpoint = options.getString("endpoint");
212-
if (endpoint != null && endpoint.length() > 0)
213-
client.setEndpoint(endpoint);
214+
notify = options.getString("endpoint");
214215
}
215-
216216
if (options.hasKey("sessionsEndpoint")) {
217-
String endpoint = options.getString("sessionsEndpoint");
218-
if (endpoint != null && endpoint.length() > 0)
219-
config.setSessionEndpoint(endpoint);
217+
sessions = options.getString("sessionsEndpoint");
220218
}
221219

220+
if (notify != null && notify.length() > 0) {
221+
config.setEndpoints(notify, sessions);
222+
} else if (sessions != null && sessions.length() > 0) {
223+
logger.warning("The session tracking endpoint should not be set without the error reporting endpoint.");
224+
}
225+
226+
222227
if (options.hasKey("releaseStage")) {
223228
String releaseStage = options.getString("releaseStage");
224229
if (releaseStage != null && releaseStage.length() > 0)

cocoa/BugsnagReactNative.m

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,12 @@ + (void)startWithConfiguration:(BugsnagConfiguration *)config {
247247
return !([report.errorClass hasPrefix:@"RCTFatalException"]
248248
&& [report.errorMessage hasPrefix:@"Unhandled JS Exception"]);
249249
}];
250-
if (sessionURLPath.length > 0) {
251-
NSURL *sessionURL = [NSURL URLWithString:sessionURLPath];
252-
if (sessionURL)
253-
config.sessionURL = sessionURL;
254-
}
250+
255251
if (notifyURLPath.length > 0) {
256-
NSURL *notifyURL = [NSURL URLWithString:notifyURLPath];
257-
if (notifyURL)
258-
config.notifyURL = notifyURL;
252+
[config setEndpointsForNotify:notifyURLPath
253+
sessions:sessionURLPath];
259254
}
255+
260256
if (appVersion.length > 0) {
261257
config.appVersion = appVersion;
262258
}

cocoa/vendor/bugsnag-cocoa/Source/BugsnagApiClient.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ - (void)sendData:(id)data
5959
NSError *error = nil;
6060
NSData *jsonData =
6161
[NSJSONSerialization dataWithJSONObject:payload
62-
options:NSJSONWritingPrettyPrinted
62+
options:0
6363
error:&error];
6464

6565
if (jsonData == nil) {

cocoa/vendor/bugsnag-cocoa/Source/BugsnagConfiguration.h

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
typedef void (^BugsnagNotifyBlock)(BugsnagCrashReport *_Nonnull report);
4343

4444
/**
45-
* A handler for modifying data before sending it to Bugsnag
45+
* A handler for modifying data before sending it to Bugsnag.
46+
*
47+
* beforeSendBlocks will be invoked on a dedicated
48+
* background queue, which will be different from the queue where the block was originally added.
4649
*
4750
* @param rawEventData The raw event data written at crash time. This
4851
* includes data added in onCrashHandler.
@@ -70,10 +73,6 @@ typedef NSDictionary *_Nullable (^BugsnagBeforeNotifyHook)(
7073
* The API key of a Bugsnag project
7174
*/
7275
@property(readwrite, retain, nullable) NSString *apiKey;
73-
/**
74-
* The URL used to notify Bugsnag
75-
*/
76-
@property(readwrite, retain, nullable) NSURL *notifyURL;
7776
/**
7877
* The release stage of the application, such as production, development, beta
7978
* et cetera
@@ -100,7 +99,7 @@ typedef NSDictionary *_Nullable (^BugsnagBeforeNotifyHook)(
10099
/**
101100
* The current user
102101
*/
103-
@property(nullable) BugsnagUser *currentUser;
102+
@property(retain, nullable) BugsnagUser *currentUser;
104103

105104
/**
106105
* Additional information about the state of the app or environment at the
@@ -139,15 +138,45 @@ BugsnagBreadcrumbs *breadcrumbs;
139138
@property BOOL autoNotify;
140139

141140
/**
142-
* Determines whether app sessions should be tracked automatically. By default this value is false.
141+
* Determines whether app sessions should be tracked automatically. By default this value is true.
143142
*/
144143
@property BOOL shouldAutoCaptureSessions;
145144

146145
/**
147-
* Set the endpoint to which tracked sessions reports are sent. This defaults to https://sessions.bugsnag.com,
148-
* but should be overridden if you are using Bugsnag On-premise, to point to your own Bugsnag endpoint.
146+
* Retrieves the endpoint used to notify Bugsnag of errors
147+
*
148+
* NOTE: If you want to set this value, you should do so via setEndpointsForNotify:sessions: instead.
149+
*
150+
* @see setEndpointsForNotify:sessions:
151+
*/
152+
@property(readonly, retain, nullable) NSURL *notifyURL;
153+
154+
/**
155+
* Retrieves the endpoint used to send tracked sessions to Bugsnag
156+
*
157+
* NOTE: If you want to set this value, you should do so via setEndpointsForNotify:sessions: instead.
158+
*
159+
* @see setEndpointsForNotify:sessions:
149160
*/
150-
@property(readwrite, retain, nullable) NSURL *sessionURL;
161+
@property(readonly, retain, nullable) NSURL *sessionURL;
162+
163+
/**
164+
* Set the endpoints to send data to. By default we'll send error reports to
165+
* https://notify.bugsnag.com, and sessions to https://sessions.bugsnag.com, but you can
166+
* override this if you are using Bugsnag Enterprise to point to your own Bugsnag endpoint.
167+
*
168+
* Please note that it is recommended that you set both endpoints. If the notify endpoint is
169+
* missing, an assertion will be thrown. If the session endpoint is missing, a warning will be
170+
* logged and sessions will not be sent automatically.
171+
*
172+
* @param notify the notify endpoint
173+
* @param sessions the sessions endpoint
174+
*
175+
* @throws an assertion if the notify endpoint is not a valid URL
176+
*/
177+
178+
- (void)setEndpointsForNotify:(NSString *_Nonnull)notify
179+
sessions:(NSString *_Nonnull)sessions NS_SWIFT_NAME(setEndpoints(notify:sessions:));
151180

152181
/**
153182
* Set user metadata
@@ -191,8 +220,8 @@ BugsnagBreadcrumbs *breadcrumbs;
191220
- (NSDictionary *_Nonnull)errorApiHeaders;
192221
- (NSDictionary *_Nonnull)sessionApiHeaders;
193222

194-
@property(nullable) NSString *codeBundleId;
195-
@property(nullable) NSString *notifierType;
223+
@property(retain, nullable) NSString *codeBundleId;
224+
@property(retain, nullable) NSString *notifierType;
196225

197226
- (BOOL)hasValidApiKey;
198227

cocoa/vendor/bugsnag-cocoa/Source/BugsnagConfiguration.m

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ - (id)init {
6565
_notifyReleaseStages = nil;
6666
_breadcrumbs = [BugsnagBreadcrumbs new];
6767
_automaticallyCollectBreadcrumbs = YES;
68+
_shouldAutoCaptureSessions = YES;
69+
6870
if ([NSURLSession class]) {
6971
_session = [NSURLSession
7072
sessionWithConfiguration:[NSURLSessionConfiguration
@@ -87,7 +89,7 @@ - (BOOL)shouldSendReports {
8789
- (void)setUser:(NSString *)userId
8890
withName:(NSString *)userName
8991
andEmail:(NSString *)userEmail {
90-
92+
9193
self.currentUser = [[BugsnagUser alloc] initWithUserId:userId name:userName emailAddress:userEmail];
9294

9395
[self.metaData addAttribute:BSGKeyId withValue:userId toTabWithName:BSGKeyUser];
@@ -225,7 +227,7 @@ - (BOOL)shouldAutoCaptureSessions {
225227
- (void)setShouldAutoCaptureSessions:(BOOL)shouldAutoCaptureSessions {
226228
@synchronized (self) {
227229
_shouldAutoCaptureSessions = shouldAutoCaptureSessions;
228-
230+
229231
if (shouldAutoCaptureSessions) { // track any existing sessions
230232
BugsnagSessionTracker *sessionTracker = [Bugsnag notifier].sessionTracker;
231233
[sessionTracker onAutoCaptureEnabled];
@@ -249,6 +251,22 @@ - (NSDictionary *)sessionApiHeaders {
249251
};
250252
}
251253

254+
- (void)setEndpointsForNotify:(NSString *_Nonnull)notify sessions:(NSString *_Nonnull)sessions {
255+
_notifyURL = [NSURL URLWithString:notify];
256+
_sessionURL = [NSURL URLWithString:sessions];
257+
258+
NSAssert([self isValidUrl:_notifyURL], @"Invalid URL supplied for notify endpoint");
259+
260+
if (![self isValidUrl:_sessionURL]) {
261+
_sessionURL = nil;
262+
}
263+
}
264+
265+
- (BOOL)isValidUrl:(NSURL *)url {
266+
return url != nil && url.scheme != nil && url.host != nil;
267+
}
268+
269+
252270
- (BOOL)hasValidApiKey {
253271
return [_apiKey length] > 0;
254272
}

cocoa/vendor/bugsnag-cocoa/Source/BugsnagCrashReport.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,16 @@ + (instancetype)errorDataFromThreads:(NSArray *)threads {
630630
}
631631
NSString *contentValue = data[@"value"];
632632

633+
#pragma clang diagnostic push
634+
#pragma ide diagnostic ignored "OCDFAInspection"
635+
if (contentValue == nil || ![contentValue isKindOfClass:[NSString class]]) {
636+
continue;
637+
}
638+
#pragma clang diagnostic pop
639+
633640
if ([self isReservedWord:contentValue]) {
634641
reservedWord = contentValue;
635-
} else if (!([[contentValue componentsSeparatedByString:@"/"] count] > 2)) {
642+
} else if ([[contentValue componentsSeparatedByString:@"/"] count] <= 2) {
636643
// must be a string that isn't a reserved word and isn't a filepath
637644
[interestingValues addObject:contentValue];
638645
}

0 commit comments

Comments
 (0)