From fb8f354890419aa69ddc123640fabe5792c1f60a Mon Sep 17 00:00:00 2001 From: Brandon Stalnaker Date: Thu, 17 Nov 2022 12:00:33 -0500 Subject: [PATCH 1/4] fix: Add Hash Method when Implementing isEqual --- mParticle-Apple-SDK/Custom Modules/MPCustomModule.m | 4 ++++ mParticle-Apple-SDK/Data Model/MPBreadcrumb.m | 4 ++++ mParticle-Apple-SDK/Data Model/MPConsumerInfo.mm | 4 ++++ mParticle-Apple-SDK/Data Model/MPForwardRecord.mm | 4 ++++ mParticle-Apple-SDK/Data Model/MPMessage.m | 4 ++++ mParticle-Apple-SDK/Data Model/MPSegment.m | 4 ++++ mParticle-Apple-SDK/Data Model/MPSegmentMembership.m | 4 ++++ mParticle-Apple-SDK/Data Model/MPSession.m | 4 ++++ mParticle-Apple-SDK/Data Model/MPUpload.m | 4 ++++ .../Data Model/MParticleUserNotification.m | 4 ++++ mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm | 4 ++++ mParticle-Apple-SDK/Ecommerce/MPProduct.mm | 4 ++++ mParticle-Apple-SDK/Ecommerce/MPPromotion.mm | 8 ++++++++ mParticle-Apple-SDK/Ecommerce/MPTransactionAttributes.m | 4 ++++ mParticle-Apple-SDK/Event/MPBaseEvent.m | 4 ++++ mParticle-Apple-SDK/Event/MPEvent.m | 4 ++++ mParticle-Apple-SDK/Kits/MPAttributeProjection.m | 4 ++++ mParticle-Apple-SDK/Kits/MPBaseProjection.m | 4 ++++ mParticle-Apple-SDK/Kits/MPEventProjection.mm | 8 ++++++++ mParticle-Apple-SDK/Kits/MPKitConfiguration.mm | 4 ++++ 20 files changed, 88 insertions(+) diff --git a/mParticle-Apple-SDK/Custom Modules/MPCustomModule.m b/mParticle-Apple-SDK/Custom Modules/MPCustomModule.m index fdc61f35..c0f7384e 100644 --- a/mParticle-Apple-SDK/Custom Modules/MPCustomModule.m +++ b/mParticle-Apple-SDK/Custom Modules/MPCustomModule.m @@ -66,6 +66,10 @@ - (BOOL)isEqual:(id)object { return [[self dictionaryRepresentation] isEqualToDictionary:[(MPCustomModule *)object dictionaryRepresentation]]; } +- (NSUInteger)hash { + return [[self dictionaryRepresentation] hash]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPCustomModule *copyObject = [[[self class] alloc] init]; diff --git a/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m b/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m index 176f1a33..8a398ec5 100644 --- a/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m +++ b/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m @@ -41,6 +41,10 @@ - (BOOL)isEqual:(MPBreadcrumb *)object { return isEqual; } +- (NSUInteger)hash { + return [self.uuid hash] ^ [self.sessionUUID hash] ^ [self.breadcrumbData hash]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPBreadcrumb *copyObject = [[MPBreadcrumb alloc] initWithSessionUUID:[_sessionUUID copy] diff --git a/mParticle-Apple-SDK/Data Model/MPConsumerInfo.mm b/mParticle-Apple-SDK/Data Model/MPConsumerInfo.mm index e949c2ad..35d7b0f9 100644 --- a/mParticle-Apple-SDK/Data Model/MPConsumerInfo.mm +++ b/mParticle-Apple-SDK/Data Model/MPConsumerInfo.mm @@ -48,6 +48,10 @@ - (BOOL)isEqual:(MPCookie *)object { return isEqual; } +- (NSUInteger)hash { + return [self.name hash]; +} + #pragma mark NSSecureCoding - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeObject:_name forKey:@"name"]; diff --git a/mParticle-Apple-SDK/Data Model/MPForwardRecord.mm b/mParticle-Apple-SDK/Data Model/MPForwardRecord.mm index e005c74d..5e038ede 100644 --- a/mParticle-Apple-SDK/Data Model/MPForwardRecord.mm +++ b/mParticle-Apple-SDK/Data Model/MPForwardRecord.mm @@ -173,6 +173,10 @@ - (BOOL)isEqual:(id)object { return isEqual; } +- (NSUInteger)hash { + return [self.dataDictionary hash] ^ [self.mpid hash]; +} + #pragma mark Public methods - (NSData *)dataRepresentation { if (MPIsNull(_dataDictionary) || ![_dataDictionary isKindOfClass:[NSDictionary class]]) { diff --git a/mParticle-Apple-SDK/Data Model/MPMessage.m b/mParticle-Apple-SDK/Data Model/MPMessage.m index 827129b1..8c05072d 100644 --- a/mParticle-Apple-SDK/Data Model/MPMessage.m +++ b/mParticle-Apple-SDK/Data Model/MPMessage.m @@ -123,6 +123,10 @@ - (BOOL)isEqual:(MPMessage *)object { return isEqual; } +- (NSUInteger)hash { + return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash] ^ [self.messageType hash] ^ [self.messageType hash] ^ [self.messageData hash]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPMessage *copyObject = [[MPMessage alloc] initWithSessionId:[_sessionId copy] diff --git a/mParticle-Apple-SDK/Data Model/MPSegment.m b/mParticle-Apple-SDK/Data Model/MPSegment.m index ccac67e5..3fb63347 100644 --- a/mParticle-Apple-SDK/Data Model/MPSegment.m +++ b/mParticle-Apple-SDK/Data Model/MPSegment.m @@ -71,6 +71,10 @@ - (BOOL)isEqual:(MPSegment *)object { return isEqual; } +- (NSUInteger)hash { + return [self.segmentId hash] ^ [self.name hash] ^ [self.memberships hash]; +} + #pragma mark KVO - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqualToString:@"memberships"]) { diff --git a/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m b/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m index dbfbf959..e949de47 100644 --- a/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m +++ b/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m @@ -54,6 +54,10 @@ - (BOOL)isEqual:(MPSegmentMembership *)object { return isEqual; } +- (NSUInteger)hash { + return self.segmentMembershipId ^ self.action; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPSegmentMembership *copyObject = [[MPSegmentMembership alloc] initWithSegmentId:_segmentId diff --git a/mParticle-Apple-SDK/Data Model/MPSession.m b/mParticle-Apple-SDK/Data Model/MPSession.m index 270eee5b..fd5e58c8 100644 --- a/mParticle-Apple-SDK/Data Model/MPSession.m +++ b/mParticle-Apple-SDK/Data Model/MPSession.m @@ -107,6 +107,10 @@ - (BOOL)isEqual:(MPSession *)object { return isEqual; } +- (NSUInteger)hash { + return [self.uuid hash]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPSession *copyObject = [[MPSession alloc] initWithSessionId:_sessionId diff --git a/mParticle-Apple-SDK/Data Model/MPUpload.m b/mParticle-Apple-SDK/Data Model/MPUpload.m index ed196fab..2f7964e0 100644 --- a/mParticle-Apple-SDK/Data Model/MPUpload.m +++ b/mParticle-Apple-SDK/Data Model/MPUpload.m @@ -57,6 +57,10 @@ - (BOOL)isEqual:(MPUpload *)object { return isEqual; } +- (NSUInteger)hash { + return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPUpload *copyObject = [[MPUpload alloc] initWithSessionId:[_sessionId copy] diff --git a/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m b/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m index a6beb228..b4281fb1 100644 --- a/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m +++ b/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m @@ -88,6 +88,10 @@ - (BOOL)isEqual:(MParticleUserNotification *)object { return isEqual; } +- (NSUInteger)hash { + return [self.uuid hash]; +} + #pragma mark Private methods - (NSString *)redactUserNotification:(NSDictionary *)notificationDictionary { NSString * (^dictionaryToString)(NSDictionary *) = ^(NSDictionary *dictionary) { diff --git a/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm b/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm index 636edcc8..64fadb4c 100644 --- a/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm +++ b/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm @@ -339,6 +339,10 @@ - (BOOL)isEqual:(MPCommerceEvent *)object { return isEqual; } +- (NSUInteger)hash { + return [self.productActionAttributes hash] ^ [self.beautifiedAttributes hash] ^ [self.productsList hash] ^ [self.productImpressions hash] ^ [self.promotionContainer hash] ^ [self.transactionAttributes hash] ^ [self.currency hash]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPCommerceEvent *copyObject = [super copyWithZone:zone]; diff --git a/mParticle-Apple-SDK/Ecommerce/MPProduct.mm b/mParticle-Apple-SDK/Ecommerce/MPProduct.mm index 0fdd9d13..ae6ccfcf 100644 --- a/mParticle-Apple-SDK/Ecommerce/MPProduct.mm +++ b/mParticle-Apple-SDK/Ecommerce/MPProduct.mm @@ -99,6 +99,10 @@ - (BOOL)isEqual:(id)object { return [_objectDictionary isEqualToDictionary:((MPProduct *)object)->_objectDictionary]; } +- (NSUInteger)hash { + return [self.objectDictionary hash]; +} + #pragma mark Private accessors - (NSMutableDictionary *)beautifiedAttributes { if (_beautifiedAttributes) { diff --git a/mParticle-Apple-SDK/Ecommerce/MPPromotion.mm b/mParticle-Apple-SDK/Ecommerce/MPPromotion.mm index 9cd3d1b9..6444f504 100644 --- a/mParticle-Apple-SDK/Ecommerce/MPPromotion.mm +++ b/mParticle-Apple-SDK/Ecommerce/MPPromotion.mm @@ -61,6 +61,10 @@ - (BOOL)isEqual:(id)object { } } +- (NSUInteger)hash { + return [self.attributes hash]; +} + #pragma mark Private accessors - (NSMutableDictionary *)attributes { if (_attributes) { @@ -249,6 +253,10 @@ - (BOOL)isEqual:(id)object { return isEqual; } +- (NSUInteger)hash { + return [self.promotionsArray hash]; +} + #pragma mark Private accessors - (NSMutableArray *)promotionsArray { if (_promotionsArray) { diff --git a/mParticle-Apple-SDK/Ecommerce/MPTransactionAttributes.m b/mParticle-Apple-SDK/Ecommerce/MPTransactionAttributes.m index 51d2a71d..50c3139d 100644 --- a/mParticle-Apple-SDK/Ecommerce/MPTransactionAttributes.m +++ b/mParticle-Apple-SDK/Ecommerce/MPTransactionAttributes.m @@ -50,6 +50,10 @@ - (BOOL)isEqual:(id)object { return [_attributes isEqualToDictionary:((MPTransactionAttributes *)object)->_attributes]; } +- (NSUInteger)hash { + return [self.attributes hash]; +} + #pragma mark Private accessors - (NSMutableDictionary *)attributes { if (_attributes) { diff --git a/mParticle-Apple-SDK/Event/MPBaseEvent.m b/mParticle-Apple-SDK/Event/MPBaseEvent.m index 2c5e1897..f28a75d0 100644 --- a/mParticle-Apple-SDK/Event/MPBaseEvent.m +++ b/mParticle-Apple-SDK/Event/MPBaseEvent.m @@ -153,6 +153,10 @@ - (BOOL)isEqual:(MPEvent *)object { return (self.type == object.type) && [self.customAttributes isEqualToDictionary:object.customAttributes]; } +- (NSUInteger)hash { + return [self.customAttributes hash]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPBaseEvent *copyObject = [[[self class] allocWithZone:zone] init]; diff --git a/mParticle-Apple-SDK/Event/MPEvent.m b/mParticle-Apple-SDK/Event/MPEvent.m index 2c2bac5f..d8ad5e15 100644 --- a/mParticle-Apple-SDK/Event/MPEvent.m +++ b/mParticle-Apple-SDK/Event/MPEvent.m @@ -91,6 +91,10 @@ - (BOOL)isEqual:(MPEvent *)object { return isEqual; } +- (NSUInteger)hash { + return [self.name hash] ^ [self.duration hash] ^ [self.category hash]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { MPEvent *copyObject = [super copyWithZone:zone]; diff --git a/mParticle-Apple-SDK/Kits/MPAttributeProjection.m b/mParticle-Apple-SDK/Kits/MPAttributeProjection.m index a03bcb66..dce90ca3 100644 --- a/mParticle-Apple-SDK/Kits/MPAttributeProjection.m +++ b/mParticle-Apple-SDK/Kits/MPAttributeProjection.m @@ -38,6 +38,10 @@ - (BOOL)isEqual:(id)object { return isEqual; } +- (NSUInteger)hash { + return [super hash]; +} + #pragma mark NSSecureCoding - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; diff --git a/mParticle-Apple-SDK/Kits/MPBaseProjection.m b/mParticle-Apple-SDK/Kits/MPBaseProjection.m index 7de86b78..f986248f 100644 --- a/mParticle-Apple-SDK/Kits/MPBaseProjection.m +++ b/mParticle-Apple-SDK/Kits/MPBaseProjection.m @@ -129,6 +129,10 @@ - (BOOL)isEqual:(id)object { return isEqual; } +- (NSUInteger)hash { + return [self.name hash] ^ [self.projectedName hash]; +} + - (NSString *)description { NSMutableString *description = [[NSMutableString alloc] init]; diff --git a/mParticle-Apple-SDK/Kits/MPEventProjection.mm b/mParticle-Apple-SDK/Kits/MPEventProjection.mm index b0924e7d..f58d86ee 100644 --- a/mParticle-Apple-SDK/Kits/MPEventProjection.mm +++ b/mParticle-Apple-SDK/Kits/MPEventProjection.mm @@ -20,6 +20,10 @@ - (BOOL)isEqual:(id)object { return isEqual; } +- (NSUInteger)hash { + return [self.attributeKey hash] ^ [self.attributeValues hash]; +} + #pragma mark NSSecureCoding - (void)encodeWithCoder:(NSCoder *)coder { if (self.attributeKey) { @@ -178,6 +182,10 @@ - (BOOL)isEqual:(id)object { return isEqual; } +- (NSUInteger)hash { + return [self.projectionMatches hash]; +} + #pragma mark NSSecureCoding - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; diff --git a/mParticle-Apple-SDK/Kits/MPKitConfiguration.mm b/mParticle-Apple-SDK/Kits/MPKitConfiguration.mm index 4276ea6e..01426192 100644 --- a/mParticle-Apple-SDK/Kits/MPKitConfiguration.mm +++ b/mParticle-Apple-SDK/Kits/MPKitConfiguration.mm @@ -99,6 +99,10 @@ - (BOOL)isEqual:(MPKitConfiguration *)object { return [_configurationHash isEqualToNumber:object.configurationHash]; } +- (NSUInteger)hash { + return [self.configurationHash hash]; +} + #pragma mark NSSecureCoding - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeObject:self.configurationDictionary forKey:@"configurationDictionary"]; From 912459c6a53cc3fe4e0f80f5cded5e5e806f5c22 Mon Sep 17 00:00:00 2001 From: Brandon Stalnaker Date: Thu, 17 Nov 2022 12:45:10 -0500 Subject: [PATCH 2/4] add number values --- mParticle-Apple-SDK/Data Model/MPBreadcrumb.m | 2 +- mParticle-Apple-SDK/Data Model/MPForwardRecord.mm | 2 +- mParticle-Apple-SDK/Data Model/MPMessage.m | 2 +- mParticle-Apple-SDK/Data Model/MPSegmentMembership.m | 2 +- mParticle-Apple-SDK/Data Model/MPSession.m | 2 +- mParticle-Apple-SDK/Data Model/MPUpload.m | 2 +- mParticle-Apple-SDK/Data Model/MParticleUserNotification.m | 2 +- mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm | 2 +- mParticle-Apple-SDK/Ecommerce/MPPromotion.mm | 2 +- mParticle-Apple-SDK/Event/MPBaseEvent.m | 2 +- mParticle-Apple-SDK/Kits/MPAttributeProjection.m | 2 +- mParticle-Apple-SDK/Kits/MPBaseProjection.m | 2 +- mParticle-Apple-SDK/Kits/MPEventProjection.mm | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m b/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m index 8a398ec5..f802b973 100644 --- a/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m +++ b/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m @@ -42,7 +42,7 @@ - (BOOL)isEqual:(MPBreadcrumb *)object { } - (NSUInteger)hash { - return [self.uuid hash] ^ [self.sessionUUID hash] ^ [self.breadcrumbData hash]; + return @(self.breadcrumbId).intValue ^ @(self.timestamp).intValue ^ [self.uuid hash] ^ [self.sessionUUID hash] ^ [self.breadcrumbData hash]; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Data Model/MPForwardRecord.mm b/mParticle-Apple-SDK/Data Model/MPForwardRecord.mm index 5e038ede..ea5dc2b1 100644 --- a/mParticle-Apple-SDK/Data Model/MPForwardRecord.mm +++ b/mParticle-Apple-SDK/Data Model/MPForwardRecord.mm @@ -174,7 +174,7 @@ - (BOOL)isEqual:(id)object { } - (NSUInteger)hash { - return [self.dataDictionary hash] ^ [self.mpid hash]; + return [self.dataDictionary hash] ^ self.forwardRecordId ^ [self.mpid hash]; } #pragma mark Public methods diff --git a/mParticle-Apple-SDK/Data Model/MPMessage.m b/mParticle-Apple-SDK/Data Model/MPMessage.m index 8c05072d..1df599ee 100644 --- a/mParticle-Apple-SDK/Data Model/MPMessage.m +++ b/mParticle-Apple-SDK/Data Model/MPMessage.m @@ -124,7 +124,7 @@ - (BOOL)isEqual:(MPMessage *)object { } - (NSUInteger)hash { - return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash] ^ [self.messageType hash] ^ [self.messageType hash] ^ [self.messageData hash]; + return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash] ^ self.messageId ^ @(self.timestamp).intValue ^ [self.messageType hash] ^ [self.messageData hash] ^ @(self.shouldUploadEvent).intValue; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m b/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m index e949de47..001baf25 100644 --- a/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m +++ b/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m @@ -55,7 +55,7 @@ - (BOOL)isEqual:(MPSegmentMembership *)object { } - (NSUInteger)hash { - return self.segmentMembershipId ^ self.action; + return self.segmentMembershipId ^ @(self.timestamp).intValue ^ self.action; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Data Model/MPSession.m b/mParticle-Apple-SDK/Data Model/MPSession.m index fd5e58c8..85e1d487 100644 --- a/mParticle-Apple-SDK/Data Model/MPSession.m +++ b/mParticle-Apple-SDK/Data Model/MPSession.m @@ -108,7 +108,7 @@ - (BOOL)isEqual:(MPSession *)object { } - (NSUInteger)hash { - return [self.uuid hash]; + return self.sessionId ^ self.eventCounter ^ [self.uuid hash]; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Data Model/MPUpload.m b/mParticle-Apple-SDK/Data Model/MPUpload.m index 2f7964e0..79f97ae2 100644 --- a/mParticle-Apple-SDK/Data Model/MPUpload.m +++ b/mParticle-Apple-SDK/Data Model/MPUpload.m @@ -58,7 +58,7 @@ - (BOOL)isEqual:(MPUpload *)object { } - (NSUInteger)hash { - return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash]; + return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash] ^ self.uploadId ^ @(self.timestamp).intValue; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m b/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m index b4281fb1..b9e1a852 100644 --- a/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m +++ b/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m @@ -89,7 +89,7 @@ - (BOOL)isEqual:(MParticleUserNotification *)object { } - (NSUInteger)hash { - return [self.uuid hash]; + return @(self.userNotificationId).intValue; } #pragma mark Private methods diff --git a/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm b/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm index 64fadb4c..6edc2a05 100644 --- a/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm +++ b/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm @@ -340,7 +340,7 @@ - (BOOL)isEqual:(MPCommerceEvent *)object { } - (NSUInteger)hash { - return [self.productActionAttributes hash] ^ [self.beautifiedAttributes hash] ^ [self.productsList hash] ^ [self.productImpressions hash] ^ [self.promotionContainer hash] ^ [self.transactionAttributes hash] ^ [self.currency hash]; + return [self.productActionAttributes hash] ^ [self.beautifiedAttributes hash] ^ [self.productsList hash] ^ [self.productImpressions hash] ^ [self.promotionContainer hash] ^ [self.transactionAttributes hash] ^ self->commerceEventKind ^ [self.currency hash]; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Ecommerce/MPPromotion.mm b/mParticle-Apple-SDK/Ecommerce/MPPromotion.mm index 6444f504..70906bd6 100644 --- a/mParticle-Apple-SDK/Ecommerce/MPPromotion.mm +++ b/mParticle-Apple-SDK/Ecommerce/MPPromotion.mm @@ -254,7 +254,7 @@ - (BOOL)isEqual:(id)object { } - (NSUInteger)hash { - return [self.promotionsArray hash]; + return self.action ^ [self.promotionsArray hash]; } #pragma mark Private accessors diff --git a/mParticle-Apple-SDK/Event/MPBaseEvent.m b/mParticle-Apple-SDK/Event/MPBaseEvent.m index f28a75d0..1a1f7cc4 100644 --- a/mParticle-Apple-SDK/Event/MPBaseEvent.m +++ b/mParticle-Apple-SDK/Event/MPBaseEvent.m @@ -154,7 +154,7 @@ - (BOOL)isEqual:(MPEvent *)object { } - (NSUInteger)hash { - return [self.customAttributes hash]; + return self.type ^ [self.customAttributes hash]; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Kits/MPAttributeProjection.m b/mParticle-Apple-SDK/Kits/MPAttributeProjection.m index dce90ca3..a29096ec 100644 --- a/mParticle-Apple-SDK/Kits/MPAttributeProjection.m +++ b/mParticle-Apple-SDK/Kits/MPAttributeProjection.m @@ -39,7 +39,7 @@ - (BOOL)isEqual:(id)object { } - (NSUInteger)hash { - return [super hash]; + return self.dataType ^ self.required; } #pragma mark NSSecureCoding diff --git a/mParticle-Apple-SDK/Kits/MPBaseProjection.m b/mParticle-Apple-SDK/Kits/MPBaseProjection.m index f986248f..03cb5619 100644 --- a/mParticle-Apple-SDK/Kits/MPBaseProjection.m +++ b/mParticle-Apple-SDK/Kits/MPBaseProjection.m @@ -130,7 +130,7 @@ - (BOOL)isEqual:(id)object { } - (NSUInteger)hash { - return [self.name hash] ^ [self.projectedName hash]; + return [self.name hash] ^ [self.projectedName hash] ^ self.matchType ^ self.projectionType; } - (NSString *)description { diff --git a/mParticle-Apple-SDK/Kits/MPEventProjection.mm b/mParticle-Apple-SDK/Kits/MPEventProjection.mm index f58d86ee..eb1c9d03 100644 --- a/mParticle-Apple-SDK/Kits/MPEventProjection.mm +++ b/mParticle-Apple-SDK/Kits/MPEventProjection.mm @@ -183,7 +183,7 @@ - (BOOL)isEqual:(id)object { } - (NSUInteger)hash { - return [self.projectionMatches hash]; + return [self.projectionMatches hash] ^ self.messageType ^ self.maxCustomParameters ^ self.appendAsIs ^ self.isDefault ^ [self.attributeProjections hash]; } #pragma mark NSSecureCoding From 5c4a0f5a687a574d1b60e5216b9b90f43a65407a Mon Sep 17 00:00:00 2001 From: Brandon Stalnaker Date: Thu, 17 Nov 2022 12:52:42 -0500 Subject: [PATCH 3/4] cast instead --- mParticle-Apple-SDK/Data Model/MPBreadcrumb.m | 2 +- mParticle-Apple-SDK/Data Model/MPMessage.m | 2 +- mParticle-Apple-SDK/Data Model/MPSegmentMembership.m | 2 +- mParticle-Apple-SDK/Data Model/MPUpload.m | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m b/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m index f802b973..b1634886 100644 --- a/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m +++ b/mParticle-Apple-SDK/Data Model/MPBreadcrumb.m @@ -42,7 +42,7 @@ - (BOOL)isEqual:(MPBreadcrumb *)object { } - (NSUInteger)hash { - return @(self.breadcrumbId).intValue ^ @(self.timestamp).intValue ^ [self.uuid hash] ^ [self.sessionUUID hash] ^ [self.breadcrumbData hash]; + return (NSUInteger)self.breadcrumbId ^ (NSUInteger)self.timestamp ^ [self.uuid hash] ^ [self.sessionUUID hash] ^ [self.breadcrumbData hash]; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Data Model/MPMessage.m b/mParticle-Apple-SDK/Data Model/MPMessage.m index 1df599ee..0c6c8339 100644 --- a/mParticle-Apple-SDK/Data Model/MPMessage.m +++ b/mParticle-Apple-SDK/Data Model/MPMessage.m @@ -124,7 +124,7 @@ - (BOOL)isEqual:(MPMessage *)object { } - (NSUInteger)hash { - return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash] ^ self.messageId ^ @(self.timestamp).intValue ^ [self.messageType hash] ^ [self.messageData hash] ^ @(self.shouldUploadEvent).intValue; + return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash] ^ self.messageId ^ (NSUInteger)self.timestamp ^ [self.messageType hash] ^ [self.messageData hash] ^ (NSUInteger)self.shouldUploadEvent; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m b/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m index 001baf25..ad84e0a4 100644 --- a/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m +++ b/mParticle-Apple-SDK/Data Model/MPSegmentMembership.m @@ -55,7 +55,7 @@ - (BOOL)isEqual:(MPSegmentMembership *)object { } - (NSUInteger)hash { - return self.segmentMembershipId ^ @(self.timestamp).intValue ^ self.action; + return self.segmentMembershipId ^ (NSUInteger)self.timestamp ^ self.action; } #pragma mark NSCopying diff --git a/mParticle-Apple-SDK/Data Model/MPUpload.m b/mParticle-Apple-SDK/Data Model/MPUpload.m index 79f97ae2..527b3747 100644 --- a/mParticle-Apple-SDK/Data Model/MPUpload.m +++ b/mParticle-Apple-SDK/Data Model/MPUpload.m @@ -58,7 +58,7 @@ - (BOOL)isEqual:(MPUpload *)object { } - (NSUInteger)hash { - return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash] ^ self.uploadId ^ @(self.timestamp).intValue; + return [self.sessionId hash] ^ [self.dataPlanId hash] ^ [self.dataPlanVersion hash] ^ self.uploadId ^ (NSUInteger)self.timestamp; } #pragma mark NSCopying From 3fcbe1a09988d0cd2a186039ec932a0cac037ad0 Mon Sep 17 00:00:00 2001 From: Brandon Stalnaker <33703490+BrandonStalnaker@users.noreply.github.com> Date: Thu, 17 Nov 2022 13:03:35 -0500 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Ben Baron --- mParticle-Apple-SDK/Data Model/MParticleUserNotification.m | 2 +- mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m b/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m index b9e1a852..2b6f7d7e 100644 --- a/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m +++ b/mParticle-Apple-SDK/Data Model/MParticleUserNotification.m @@ -89,7 +89,7 @@ - (BOOL)isEqual:(MParticleUserNotification *)object { } - (NSUInteger)hash { - return @(self.userNotificationId).intValue; + return (NSUInteger)self.userNotificationId; } #pragma mark Private methods diff --git a/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm b/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm index 6edc2a05..ddee410e 100644 --- a/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm +++ b/mParticle-Apple-SDK/Ecommerce/MPCommerceEvent.mm @@ -340,7 +340,7 @@ - (BOOL)isEqual:(MPCommerceEvent *)object { } - (NSUInteger)hash { - return [self.productActionAttributes hash] ^ [self.beautifiedAttributes hash] ^ [self.productsList hash] ^ [self.productImpressions hash] ^ [self.promotionContainer hash] ^ [self.transactionAttributes hash] ^ self->commerceEventKind ^ [self.currency hash]; + return [self.productActionAttributes hash] ^ [self.beautifiedAttributes hash] ^ [self.productsList hash] ^ [self.productImpressions hash] ^ [self.promotionContainer hash] ^ [self.transactionAttributes hash] ^ commerceEventKind ^ [self.currency hash]; } #pragma mark NSCopying