Skip to content

Commit 287b331

Browse files
committed
seg: remove use of mutable traits, use immutable live context
1 parent 3f28928 commit 287b331

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Analytics/Integrations/Segmentio/SEGSegmentioIntegration.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ - (NSDictionary *)staticContext {
171171
return dict;
172172
}
173173

174-
- (NSMutableDictionary *)liveContext {
174+
- (NSDictionary *)liveContext {
175175
NSMutableDictionary *context = [[NSMutableDictionary alloc] init];
176176

177177
[context addEntriesFromDictionary:self.context];
@@ -209,7 +209,7 @@ - (NSMutableDictionary *)liveContext {
209209
traits;
210210
});
211211

212-
return context;
212+
return [context copy];
213213
}
214214

215215
- (void)dispatchBackground:(void(^)(void))block {
@@ -343,7 +343,7 @@ - (void)enqueueAction:(NSString *)action dictionary:(NSDictionary *)dictionary o
343343
payload[@"type"] = action;
344344
payload[@"timestamp"] = [[NSDate date] description];
345345
payload[@"messageId"] = GenerateUUIDString();
346-
346+
347347
[self dispatchBackground:^{
348348
// attach userId and anonymousId inside the dispatch_async in case
349349
// they've changed (see identify function)
@@ -354,9 +354,10 @@ - (void)enqueueAction:(NSString *)action dictionary:(NSDictionary *)dictionary o
354354

355355
NSDictionary *defaultContext = [self liveContext];
356356
NSDictionary *customContext = options[@"context"];
357-
int capacity = customContext.count + defaultContext.count;
357+
358+
NSUInteger capacity = customContext.count + defaultContext.count;
358359
NSMutableDictionary *context = [NSMutableDictionary dictionaryWithCapacity:capacity];
359-
[context setValue:_traits forKey:@"traits"];
360+
360361
[context addEntriesFromDictionary:defaultContext];
361362
[context addEntriesFromDictionary:customContext]; // let the custom context override ours
362363
[payload setValue:context forKey:@"context"];

0 commit comments

Comments
 (0)