Skip to content

Commit

Permalink
feat:Remove User Attribute Limits (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker authored Oct 2, 2023
1 parent b08e840 commit d8a79f1
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 24 deletions.
9 changes: 4 additions & 5 deletions UnitTests/MPBackendControllerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions mParticle-Apple-SDK/Event/MPBaseEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ - (void)setCustomAttributes:(NSDictionary<NSString *,id> *)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<NSString *,id> class]]) && (numberOfEntries > 0)) {
__block BOOL respectsConstraints = YES;

Expand Down
1 change: 0 additions & 1 deletion mParticle-Apple-SDK/MPBackendController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions mParticle-Apple-SDK/MPBackendController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
1 change: 0 additions & 1 deletion mParticle-Apple-SDK/MPIConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion mParticle-Apple-SDK/MPIConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d8a79f1

Please sign in to comment.