From 64f6324ca87493df5a7c1c15907cf613dcc47590 Mon Sep 17 00:00:00 2001 From: ShashaankKrishnatray Date: Mon, 16 Sep 2024 23:58:11 +0530 Subject: [PATCH 1/3] ignore error for no matching rule --- packages/rule-engine/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rule-engine/src/index.ts b/packages/rule-engine/src/index.ts index f59efb3..d949a69 100644 --- a/packages/rule-engine/src/index.ts +++ b/packages/rule-engine/src/index.ts @@ -61,7 +61,7 @@ export class RuleEngine { await ActionExecutor.handleActions(integrations, firstMatchingRule.actions, payload, apis, customPlaceholders, options, ruleAlias); } } catch (err) { - if (options.enableLogger || err !== 'no matching rule') { + if (options.enableLogger || err !== 'Error: no matching rule') { Utils.log(payload, integrations, ErrorCodes.FreshchatAction, { error: err as AnyJson}, LogSeverity.ALERT); } throw err; // Rethrow the error to be handled by the caller. From 7a75cf23fcf2cba9317a872df55934e415749f1f Mon Sep 17 00:00:00 2001 From: ShashaankKrishnatray Date: Sun, 3 Nov 2024 20:28:00 +0530 Subject: [PATCH 2/3] erro update --- packages/rule-engine/package.json | 2 +- packages/rule-engine/src/RuleProcessor.ts | 4 ++-- packages/rule-engine/src/index.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/rule-engine/package.json b/packages/rule-engine/package.json index 2c24cab..c1e307f 100644 --- a/packages/rule-engine/package.json +++ b/packages/rule-engine/package.json @@ -1,6 +1,6 @@ { "name": "@freshworks-jaya/rule-engine", - "version": "0.18.3", + "version": "0.18.6-beta-40", "description": "Provides methods to process rules in product events in marketplace app", "repository": "git@github.com:freshdesk/jaya-lib.git", "main": "lib/index.js", diff --git a/packages/rule-engine/src/RuleProcessor.ts b/packages/rule-engine/src/RuleProcessor.ts index 3d76647..c3d535c 100644 --- a/packages/rule-engine/src/RuleProcessor.ts +++ b/packages/rule-engine/src/RuleProcessor.ts @@ -229,7 +229,7 @@ export class RuleProcessor { rules: Rule[], integrations: Integrations, options: RuleEngineOptions, - ): Promise { + ): Promise { for (const rule of rules) { if (this.isEnabledNonTimerRule(rule)) { try { @@ -240,6 +240,6 @@ export class RuleProcessor { } } } - throw new Error('no matching rule'); + return null; } } \ No newline at end of file diff --git a/packages/rule-engine/src/index.ts b/packages/rule-engine/src/index.ts index d949a69..bb9e976 100644 --- a/packages/rule-engine/src/index.ts +++ b/packages/rule-engine/src/index.ts @@ -56,12 +56,12 @@ export class RuleEngine { // Process regular rules and get the actions of the first matching rule. try { const firstMatchingRule = await RuleProcessor.getFirstMatchingRule(payload.event, payload.data, rules, integrations, options); - if (firstMatchingRule.actions?.length) { + if (firstMatchingRule?.actions?.length) { const ruleAlias = firstMatchingRule.ruleAlias || ''; await ActionExecutor.handleActions(integrations, firstMatchingRule.actions, payload, apis, customPlaceholders, options, ruleAlias); } } catch (err) { - if (options.enableLogger || err !== 'Error: no matching rule') { + if (options.enableLogger) { Utils.log(payload, integrations, ErrorCodes.FreshchatAction, { error: err as AnyJson}, LogSeverity.ALERT); } throw err; // Rethrow the error to be handled by the caller. From 4bbfdc3a9967964f151da9dcf638d366e2884ea4 Mon Sep 17 00:00:00 2001 From: ShashaankKrishnatray Date: Sun, 3 Nov 2024 20:49:15 +0530 Subject: [PATCH 3/3] version update --- packages/rule-engine/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rule-engine/package.json b/packages/rule-engine/package.json index a1e7942..3ec2060 100644 --- a/packages/rule-engine/package.json +++ b/packages/rule-engine/package.json @@ -1,6 +1,6 @@ { - "name": "@freshworks-jaya/rule-engine" - "version": "0.18.6-beta-40", + "name": "@freshworks-jaya/rule-engine", + "version": "0.18.6-beta-41", "description": "Provides methods to process rules in product events in marketplace app", "repository": "git@github.com:freshdesk/jaya-lib.git", "main": "lib/index.js",