Skip to content

Commit 83fefcd

Browse files
committed
adding user setting APIs to context init chain
1 parent 03cffc3 commit 83fefcd

File tree

1 file changed

+37
-16
lines changed

1 file changed

+37
-16
lines changed

Crashlytics/Crashlytics/FIRCrashlytics.m

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ @interface FIRCrashlytics () <FIRLibrary,
111111
// Dependencies common to each of the Controllers
112112
@property(nonatomic, strong) FIRCLSManagerData *managerData;
113113

114+
@property(nonatomic, nullable) FBLPromise *contextInitPromise;
115+
114116
@end
115117

116118
@implementation FIRCrashlytics
@@ -197,14 +199,15 @@ - (instancetype)initWithApp:(FIRApp *)app
197199
});
198200
}
199201

200-
[[[_reportManager startWithProfiling] then:^id _Nullable(NSNumber *_Nullable value) {
201-
if (![value boolValue]) {
202-
FIRCLSErrorLog(@"Crash reporting could not be initialized");
203-
}
204-
return value;
205-
}] catch:^void(NSError *error) {
206-
FIRCLSErrorLog(@"Crash reporting failed to initialize with error: %@", error);
207-
}];
202+
_contextInitPromise =
203+
[[[_reportManager startWithProfiling] then:^id _Nullable(NSNumber *_Nullable value) {
204+
if (![value boolValue]) {
205+
FIRCLSErrorLog(@"Crash reporting could not be initialized");
206+
}
207+
return value;
208+
}] catch:^void(NSError *error) {
209+
FIRCLSErrorLog(@"Crash reporting failed to initialize with error: %@", error);
210+
}];
208211

209212
// RemoteConfig subscription should be made after session report directory created.
210213
if (remoteConfig) {
@@ -307,7 +310,10 @@ - (void)processDidCrashDuringPreviousExecution {
307310

308311
#pragma mark - API: Logging
309312
- (void)log:(NSString *)msg {
310-
FIRCLSLog(@"%@", msg);
313+
[_contextInitPromise then:^id _Nullable(id _Nullable value) {
314+
FIRCLSLog(@"%@", msg);
315+
return nil;
316+
}];
311317
}
312318

313319
- (void)logWithFormat:(NSString *)format, ... {
@@ -350,17 +356,26 @@ - (void)deleteUnsentReports {
350356

351357
#pragma mark - API: setUserID
352358
- (void)setUserID:(nullable NSString *)userID {
353-
FIRCLSUserLoggingRecordInternalKeyValue(FIRCLSUserIdentifierKey, userID);
359+
[_contextInitPromise then:^id _Nullable(id _Nullable value) {
360+
FIRCLSUserLoggingRecordInternalKeyValue(FIRCLSUserIdentifierKey, userID);
361+
return nil;
362+
}];
354363
}
355364

356365
#pragma mark - API: setCustomValue
357366

358367
- (void)setCustomValue:(nullable id)value forKey:(NSString *)key {
359-
FIRCLSUserLoggingRecordUserKeyValue(key, value);
368+
[_contextInitPromise then:^id _Nullable(id _Nullable value) {
369+
FIRCLSUserLoggingRecordUserKeyValue(key, value);
370+
return nil;
371+
}];
360372
}
361373

362374
- (void)setCustomKeysAndValues:(NSDictionary *)keysAndValues {
363-
FIRCLSUserLoggingRecordUserKeysAndValues(keysAndValues);
375+
[_contextInitPromise then:^id _Nullable(id _Nullable value) {
376+
FIRCLSUserLoggingRecordUserKeysAndValues(keysAndValues);
377+
return nil;
378+
}];
364379
}
365380

366381
#pragma mark - API: Development Platform
@@ -383,8 +398,11 @@ - (NSString *)developmentPlatformName {
383398
}
384399

385400
- (void)setDevelopmentPlatformName:(NSString *)developmentPlatformName {
386-
FIRCLSUserLoggingRecordInternalKeyValue(FIRCLSDevelopmentPlatformNameKey,
387-
developmentPlatformName);
401+
[_contextInitPromise then:^id _Nullable(id _Nullable value) {
402+
FIRCLSUserLoggingRecordInternalKeyValue(FIRCLSDevelopmentPlatformNameKey,
403+
developmentPlatformName);
404+
return nil;
405+
}];
388406
}
389407

390408
- (NSString *)developmentPlatformVersion {
@@ -393,8 +411,11 @@ - (NSString *)developmentPlatformVersion {
393411
}
394412

395413
- (void)setDevelopmentPlatformVersion:(NSString *)developmentPlatformVersion {
396-
FIRCLSUserLoggingRecordInternalKeyValue(FIRCLSDevelopmentPlatformVersionKey,
397-
developmentPlatformVersion);
414+
[_contextInitPromise then:^id _Nullable(id _Nullable value) {
415+
FIRCLSUserLoggingRecordInternalKeyValue(FIRCLSDevelopmentPlatformVersionKey,
416+
developmentPlatformVersion);
417+
return nil;
418+
}];
398419
}
399420

400421
#pragma mark - API: Errors and Exceptions

0 commit comments

Comments
 (0)