Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOB-9258] fixed nested IsSet matching #427

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions src/anonymousUserTracking/criteriaCompletionChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

class CriteriaCompletionChecker {
private localStoredEventList: any[];

Check warning on line 39 in src/anonymousUserTracking/criteriaCompletionChecker.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

constructor(localStoredEventList: string) {
this.localStoredEventList = JSON.parse(localStoredEventList);
Expand Down Expand Up @@ -72,9 +72,9 @@
return matchingCriteria ? matchingCriteria.criteriaId : null;
}

private prepareEventsToProcess(): any[] {

Check warning on line 75 in src/anonymousUserTracking/criteriaCompletionChecker.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const eventsToProcess: any[] = this.getEventsWithCartItems();

Check warning on line 76 in src/anonymousUserTracking/criteriaCompletionChecker.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const nonPurchaseEvents: any[] = this.getNonCartEvents();

Check warning on line 77 in src/anonymousUserTracking/criteriaCompletionChecker.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

nonPurchaseEvents.forEach((event) => {
eventsToProcess.push(event);
Expand All @@ -83,7 +83,7 @@
return eventsToProcess;
}

private getEventsWithCartItems(): any[] {

Check warning on line 86 in src/anonymousUserTracking/criteriaCompletionChecker.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const processedEvents: any[] = [];

this.localStoredEventList.forEach((localEventData) => {
Expand Down Expand Up @@ -346,7 +346,7 @@
}

if (field.includes('.')) {
const valueFromObj = this.getValueFromNestedObject(eventData, field);
const valueFromObj = this.getFieldValue(eventData, field);
if (valueFromObj) {
return this.evaluateComparison(
query.comparatorType,
Expand All @@ -371,20 +371,6 @@
return matchResult;
}

private getValueFromNestedObject(eventData: any, field: string): any {
const valueFromObj = this.getFieldValue(eventData, field);
if (typeof valueFromObj === 'object' && valueFromObj !== null) {
const keys = Object.keys(valueFromObj);
return keys.reduce((acc, key) => {
if (acc === undefined) {
return this.getValueFromNestedObject(valueFromObj, key);
}
return acc;
}, undefined);
}
return valueFromObj;
}

private getFieldValue(data: any, field: string): any {
const fields = field.split('.');
return fields.reduce(
Expand Down
Loading