File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
8383
8484- (void )addInstrumentationDictionaryKey : (NSString *)key value : (NSString *)value ;
8585- (NSMutableDictionary *)instrumentationDictionary ;
86+ - (NSDictionary *)instrumentationParameters ; // a safe copy to use in a POST body
8687- (void )clearInstrumentationDictionary ;
8788
8889- (void )saveBranchAnalyticsData : (NSDictionary *)analyticsData ;
Original file line number Diff line number Diff 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) {
Original file line number Diff line number Diff line change @@ -453,10 +453,12 @@ - (NSMutableDictionary *)prepareParamDict:(NSDictionary *)params
453453 fullParamDict[BRANCH_REQUEST_KEY_STATE] = metadata;
454454 }
455455 // we only send instrumentation info in the POST body request
456- if (self.preferenceHelper .instrumentationDictionary .count && [reqType isEqualToString: @" POST" ]) {
457- fullParamDict[BRANCH_REQUEST_KEY_INSTRUMENTATION] = self.preferenceHelper .instrumentationDictionary ;
456+ if ([reqType isEqualToString: @" POST" ]) {
457+ NSDictionary *instrumentationDictionary = self.preferenceHelper .instrumentationParameters ;
458+ if (instrumentationDictionary) {
459+ fullParamDict[BRANCH_REQUEST_KEY_INSTRUMENTATION] = instrumentationDictionary;
460+ }
458461 }
459-
460462 return fullParamDict;
461463}
462464
You can’t perform that action at this time.
0 commit comments