From affbe3291c534349a358f23b0540d0a3918438f0 Mon Sep 17 00:00:00 2001 From: BrandonStalnaker Date: Thu, 28 Sep 2023 09:47:11 -0400 Subject: [PATCH] feat:Remove User Attribute Limits --- UnitTests/MPBackendControllerTests.mm | 9 ++++----- mParticle-Apple-SDK/Event/MPBaseEvent.m | 7 ------- mParticle-Apple-SDK/MPBackendController.h | 1 - mParticle-Apple-SDK/MPBackendController.mm | 9 --------- mParticle-Apple-SDK/MPIConstants.h | 1 - mParticle-Apple-SDK/MPIConstants.m | 1 - 6 files changed, 4 insertions(+), 24 deletions(-) diff --git a/UnitTests/MPBackendControllerTests.mm b/UnitTests/MPBackendControllerTests.mm index 0e24c078..5f5faa04 100644 --- a/UnitTests/MPBackendControllerTests.mm +++ b/UnitTests/MPBackendControllerTests.mm @@ -456,14 +456,13 @@ - (void)testCheckAttributeArrayValueInvalidLongAttribute { } -- (void)testCheckAttributeTooManyAttributes { +- (void)testCheckAttributeNoMaximum { id mockAttributes = [OCMockObject mockForClass:[NSMutableDictionary class]]; - OCMStub([mockAttributes count]).andReturn(LIMIT_ATTR_COUNT); + OCMStub([mockAttributes count]).andReturn(200); NSError *error = nil; BOOL success = [MPBackendController checkAttribute:mockAttributes key:@"foo" value:@"bar" error:&error]; - XCTAssertFalse(success); - XCTAssertNotNil(error); - XCTAssertEqual(kExceededAttributeCountLimit, error.code); + XCTAssertTrue(success); + XCTAssertNil(error); } - (void)testCheckAttributeKeyTooLong { diff --git a/mParticle-Apple-SDK/Event/MPBaseEvent.m b/mParticle-Apple-SDK/Event/MPBaseEvent.m index 1a1f7cc4..972d073d 100644 --- a/mParticle-Apple-SDK/Event/MPBaseEvent.m +++ b/mParticle-Apple-SDK/Event/MPBaseEvent.m @@ -46,13 +46,6 @@ - (void)setCustomAttributes:(NSDictionary *)attributes { NSUInteger numberOfEntries = attributes.count; - NSAssert(numberOfEntries <= LIMIT_ATTR_COUNT, @"Event info has more than 100 key/value pairs."); - - if (numberOfEntries > LIMIT_ATTR_COUNT) { - MPILogError(@"Number of attributes exceeds the maximum number of attributes allowed per event. Discarding attributes."); - return; - } - if (([attributes isKindOfClass:[NSDictionary class]]) && (numberOfEntries > 0)) { __block BOOL respectsConstraints = YES; diff --git a/mParticle-Apple-SDK/MPBackendController.h b/mParticle-Apple-SDK/MPBackendController.h index b06ecb9e..13e8694b 100644 --- a/mParticle-Apple-SDK/MPBackendController.h +++ b/mParticle-Apple-SDK/MPBackendController.h @@ -48,7 +48,6 @@ typedef NS_ENUM(NSUInteger, MPExecStatus) { extern const NSTimeInterval kMPRemainingBackgroundTimeMinimumThreshold; extern const NSInteger kNilAttributeValue; -extern const NSInteger kExceededAttributeCountLimit; extern const NSInteger kExceededAttributeValueMaximumLength; extern const NSInteger kExceededAttributeKeyMaximumLength; extern const NSInteger kInvalidDataType; diff --git a/mParticle-Apple-SDK/MPBackendController.mm b/mParticle-Apple-SDK/MPBackendController.mm index 3a33a2bb..a97efd1e 100644 --- a/mParticle-Apple-SDK/MPBackendController.mm +++ b/mParticle-Apple-SDK/MPBackendController.mm @@ -40,7 +40,6 @@ #endif const NSInteger kNilAttributeValue = 101; -const NSInteger kExceededAttributeCountLimit = 103; const NSInteger kExceededAttributeValueMaximumLength = 104; const NSInteger kExceededAttributeKeyMaximumLength = 105; const NSInteger kInvalidDataType = 106; @@ -1282,14 +1281,6 @@ - (void)beginTimedEvent:(MPEvent *)event completionHandler:(void (^)(MPEvent *ev + (BOOL)checkAttribute:(NSDictionary *)attributesDictionary key:(NSString *)key value:(id)value error:(out NSError *__autoreleasing *)error { static NSString *attributeValidationErrorDomain = @"Attribute Validation"; - if (attributesDictionary.count >= LIMIT_ATTR_COUNT) { - if (error) { - *error = [NSError errorWithDomain:attributeValidationErrorDomain code:kExceededAttributeCountLimit userInfo:nil]; - } - MPILogError(@"Error while setting attribute: there are more attributes than the maximum number allowed."); - return NO; - } - if (MPIsNull(key)) { if (error) { *error = [NSError errorWithDomain:attributeValidationErrorDomain code:kInvalidKey userInfo:nil]; diff --git a/mParticle-Apple-SDK/MPIConstants.h b/mParticle-Apple-SDK/MPIConstants.h index b08dacd4..deed1019 100644 --- a/mParticle-Apple-SDK/MPIConstants.h +++ b/mParticle-Apple-SDK/MPIConstants.h @@ -467,7 +467,6 @@ extern const NSInteger SEARCH_ADS_ATTRIBUTION_MAX_RETRIES; extern const NSTimeInterval NETWORK_REQUEST_MAX_WAIT_SECONDS; // Attributes limits -extern const NSInteger LIMIT_ATTR_COUNT; extern const NSInteger LIMIT_ATTR_KEY_LENGTH; extern const NSInteger LIMIT_ATTR_VALUE_LENGTH; extern const NSInteger MAX_USER_ATTR_LIST_SIZE; diff --git a/mParticle-Apple-SDK/MPIConstants.m b/mParticle-Apple-SDK/MPIConstants.m index 1399e4e1..9218005b 100644 --- a/mParticle-Apple-SDK/MPIConstants.m +++ b/mParticle-Apple-SDK/MPIConstants.m @@ -428,7 +428,6 @@ const NSTimeInterval NETWORK_REQUEST_MAX_WAIT_SECONDS = 10; // Attributes limits -const NSInteger LIMIT_ATTR_COUNT = 100; const NSInteger LIMIT_ATTR_KEY_LENGTH = 256; const NSInteger LIMIT_ATTR_VALUE_LENGTH = 4096; const NSInteger MAX_USER_ATTR_LIST_SIZE = 1000;