Skip to content

Commit d45a496

Browse files
committed
Merge branch 'staging' into CORE-1358-optional-FB-sync
2 parents 9c3626c + 015ab1e commit d45a496

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Branch-SDK/BNCPreferenceHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
8585

8686
- (void)addInstrumentationDictionaryKey:(NSString *)key value:(NSString *)value;
8787
- (NSMutableDictionary *)instrumentationDictionary;
88+
- (NSDictionary *)instrumentationParameters; // a safe copy to use in a POST body
8889
- (void)clearInstrumentationDictionary;
8990

9091
- (void)saveBranchAnalyticsData:(NSDictionary *)analyticsData;

Branch-SDK/BNCPreferenceHelper.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ - (void)setRequestMetadataKey:(NSString *)key value:(NSObject *)value {
492492
}
493493
}
494494

495+
- (NSDictionary *)instrumentationParameters {
496+
@synchronized (self) {
497+
if (_instrumentationDictionary.count == 0) {
498+
return nil; // this avoids the .count check in prepareParamDict
499+
}
500+
return [[NSDictionary alloc] initWithDictionary:_instrumentationDictionary];
501+
}
502+
}
503+
495504
- (NSMutableDictionary *)instrumentationDictionary {
496505
@synchronized (self) {
497506
if (!_instrumentationDictionary) {

Branch-SDK/BNCServerInterface.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,12 @@ - (NSMutableDictionary *)prepareParamDict:(NSDictionary *)params
443443
fullParamDict[BRANCH_REQUEST_KEY_STATE] = metadata;
444444
}
445445
// we only send instrumentation info in the POST body request
446-
if (self.preferenceHelper.instrumentationDictionary.count && [reqType isEqualToString:@"POST"]) {
447-
fullParamDict[BRANCH_REQUEST_KEY_INSTRUMENTATION] = self.preferenceHelper.instrumentationDictionary;
446+
if ([reqType isEqualToString:@"POST"]) {
447+
NSDictionary *instrumentationDictionary = self.preferenceHelper.instrumentationParameters;
448+
if (instrumentationDictionary) {
449+
fullParamDict[BRANCH_REQUEST_KEY_INSTRUMENTATION] = instrumentationDictionary;
450+
}
448451
}
449-
450452
return fullParamDict;
451453
}
452454

0 commit comments

Comments
 (0)