Skip to content

Commit

Permalink
- Added normalisation for event property name also.
Browse files Browse the repository at this point in the history
- Added unit test.
  • Loading branch information
nishant-clevertap committed Nov 22, 2024
1 parent 909b924 commit a87ad48
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CleverTapSDK/InApps/Matchers/CTEventAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "CTEventAdapter.h"
#import "CTConstants.h"
#import "CTUtils.h"

static NSDictionary<NSString*, NSString*> *systemPropToKey;

Expand Down Expand Up @@ -96,6 +97,14 @@ - (CTTriggerValue *)propertyValueNamed:(NSString *)name {

- (id)getActualPropertyValue:(NSString *)propertyName {
id value = self.eventProperties[propertyName];

// Check if event properties name are normalized equal
for (NSString *key in self.eventProperties) {
if ([CTUtils areEqualNormalizedName:key andName:propertyName]) {
value = self.eventProperties[key];
break;
}
}
if (value == nil) {
if ([propertyName isEqualToString:CLTAP_PROP_CAMPAIGN_ID]) {
value = self.eventProperties[CLTAP_PROP_WZRK_ID];
Expand Down
38 changes: 38 additions & 0 deletions CleverTapSDKTests/InApps/CTTriggersMatcherTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,44 @@ - (void)testMatchEqualsExtectedStringWithActualString {
XCTAssertFalse(match);
}

- (void)testMatchEqualsPropertyNameWithNormalization {
NSArray *whenTriggers = @[
@{
@"eventName": @"event1",
@"eventProperties": @[
@{
@"propertyName": @"prop1",
@"operator": @1,
@"propertyValue": @"test"
}
]
}
];

CTTriggersMatcher *triggerMatcher = [[CTTriggersMatcher alloc] init];

BOOL match = [triggerMatcher matchEventWhenTriggers:whenTriggers eventName:@"event1" eventProperties:@{
@"prop 1": @"test"
}];
XCTAssertTrue(match);

match = [triggerMatcher matchEventWhenTriggers:whenTriggers eventName:@"event1" eventProperties:@{
@"Prop 1": @"test"
}];
XCTAssertTrue(match);

match = [triggerMatcher matchEventWhenTriggers:whenTriggers eventName:@"E vent1" eventProperties:@{
@"Prop 1": @"test"
}];
XCTAssertTrue(match);

match = [triggerMatcher matchEventWhenTriggers:whenTriggers eventName:@"event1" eventProperties:@{
@"Prop.1": @"test"
}];
XCTAssertFalse(match);
}


- (void)testMatchEqualsExtectedNumberWithActualString {
NSArray *whenTriggers = @[
@{
Expand Down

0 comments on commit a87ad48

Please sign in to comment.