Skip to content

Commit

Permalink
Migration related changes, so that conversation properties doen't bre…
Browse files Browse the repository at this point in the history
…ak (#104)

* All changes

* package update
  • Loading branch information
aishik-biswas authored Oct 6, 2023
1 parent 4b389d3 commit f6ece55
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/marketplace-models/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freshworks-jaya/marketplace-models",
"version": "0.1.21-beta-1",
"version": "0.1.23",
"description": "Provides type definitions for models in marketplace product events",
"repository": "[email protected]:freshdesk/jaya-lib.git",
"main": "lib/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/marketplace-models/src/types/PayloadData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface Channel {

export interface UserProperty {
name: string;
oldName?: string;
value: string;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rule-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freshworks-jaya/rule-engine",
"version": "0.17.21-beta-7",
"version": "0.17.23",
"description": "Provides methods to process rules in product events in marketplace app",
"repository": "[email protected]:freshdesk/jaya-lib.git",
"main": "lib/index.js",
Expand Down Expand Up @@ -46,7 +46,7 @@
"dependencies": {
"@freshworks-jaya/freshchat-api": "0.7.33-beta-09",
"@freshworks-jaya/kairos-api": "^0.1.5",
"@freshworks-jaya/marketplace-models": "0.1.21-beta-1",
"@freshworks-jaya/marketplace-models": "0.1.23",
"@freshworks-jaya/utilities": "^1.0.0",
"@google-cloud/logging": "^9.3.1",
"axios": "^0.21.4",
Expand Down
5 changes: 5 additions & 0 deletions packages/rule-engine/src/ActionExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ export class ActionExecutor {
user.properties.forEach((userProperty) => {
const placeholderKey = `user.properties.${userProperty.name}`;
dynamicPlaceholders[placeholderKey] = userProperty.value;
// For backward compatibility with migrated accounts
if (userProperty.oldName) {
const oldPlaceholderKey = `user.properties.${userProperty.oldName}`;
dynamicPlaceholders[oldPlaceholderKey] = userProperty.value;
}
});
// Register empty placeholder for conversation properties which are not filled
Utils.registerEmptyPlaceholder(convFieldsMap, conversation, dynamicPlaceholders);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const evaluateUserPropertyCondition = (
ruleAlias: string,
): Promise<void> => {
const matchedProperty =
userObj.properties && userObj.properties.find((property) => property.name === conditionValue.propertyKey);
userObj.properties &&
userObj.properties.find(
(property) => property.name === conditionValue.propertyKey || property.oldName === conditionValue.propertyKey,
);

return Utils.evaluateCondition(
operator,
Expand Down

0 comments on commit f6ece55

Please sign in to comment.