diff --git a/Bugsnag/BugsnagSessionTracker.h b/Bugsnag/BugsnagSessionTracker.h index d26549a55..0f5ea3c18 100644 --- a/Bugsnag/BugsnagSessionTracker.h +++ b/Bugsnag/BugsnagSessionTracker.h @@ -11,6 +11,8 @@ #import #import +#import "BSGSessionUploader.h" + NS_ASSUME_NONNULL_BEGIN @interface BugsnagSessionTracker : NSObject @@ -82,6 +84,8 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nullable, readonly, nonatomic) BugsnagSession *runningSession; +@property (strong, nonatomic) BSGSessionUploader *sessionUploader; + - (void)addRuntimeVersionInfo:(NSString *)info withKey:(NSString *)key; diff --git a/Bugsnag/BugsnagSessionTracker.m b/Bugsnag/BugsnagSessionTracker.m index 6d2c7a8ec..f0fbbd237 100644 --- a/Bugsnag/BugsnagSessionTracker.m +++ b/Bugsnag/BugsnagSessionTracker.m @@ -10,7 +10,6 @@ #import "BSGAppKit.h" #import "BSGDefines.h" -#import "BSGSessionUploader.h" #import "BSGUIKit.h" #import "BSGWatchKit.h" #import "BSG_KSSystemInfo.h" @@ -31,7 +30,6 @@ @interface BugsnagSessionTracker () @property (strong, nonatomic) BugsnagConfiguration *config; @property (weak, nonatomic) BugsnagClient *client; -@property (strong, nonatomic) BSGSessionUploader *sessionUploader; @property (strong, nonatomic) NSDate *backgroundStartTime; @property (nonatomic) NSMutableDictionary *extraRuntimeInfo; @end diff --git a/Bugsnag/Client/BugsnagClient.m b/Bugsnag/Client/BugsnagClient.m index 208a6125c..ea69fa4fb 100644 --- a/Bugsnag/Client/BugsnagClient.m +++ b/Bugsnag/Client/BugsnagClient.m @@ -462,6 +462,7 @@ - (void)setupConnectivityListener { __strong typeof(weakSelf) strongSelf = weakSelf; if (connected) { [strongSelf.eventUploader uploadStoredEvents]; + [strongSelf.sessionTracker.sessionUploader processStoredSessions]; } [strongSelf addAutoBreadcrumbOfType:BSGBreadcrumbTypeState diff --git a/Bugsnag/Delivery/BSGSessionUploader.h b/Bugsnag/Delivery/BSGSessionUploader.h index e7e21da52..d8c3ec2e2 100644 --- a/Bugsnag/Delivery/BSGSessionUploader.h +++ b/Bugsnag/Delivery/BSGSessionUploader.h @@ -17,6 +17,9 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithConfig:(BugsnagConfiguration *)configuration notifier:(BugsnagNotifier *)notifier; +/// Scans previously persisted sessions and either discards or attempts upload. +- (void)processStoredSessions; + - (void)uploadSession:(BugsnagSession *)session; @property (copy, nonatomic) NSString *codeBundleId; diff --git a/CHANGELOG.md b/CHANGELOG.md index 80663f2e4..1d0032b2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ Changelog ### Bug fixes +* Attempt to send sessions stored on disk when connection regained. + [#1445](https://github.com/bugsnag/bugsnag-cocoa/pull/1445) + * Set `user.id` to to `device.id` for all events and sessions if `BugsnagClient.user.id` is set to nil. To prevent collection, set it to an empty string or update it in `OnSendError` / `OnSession`. [#1442](https://github.com/bugsnag/bugsnag-cocoa/pull/1442)