The Otter Framework provides a Chrome Extension to help you debug your Rulesets.
The extension is only compatible with applications running with the debug mode of the Otter rules engine.
You can activate it via the forRoot
method of the rules engine module:
import {inject, runInInjectionContext} from '@angular/core';
import {OTTER_RULES_ENGINE_DEVTOOLS_OPTIONS, RulesEngineRunnerModule, RulesEngineDevtoolsModule, RulesEngineDevtoolsMessageService} from '@o3r/rules-engine';
import {AppComponent} from './app.component';
bootstrapApplication(AppComponent, {
imports: [
RulesEngineDevtoolsModule,
RulesEngineRunnerModule.forRoot({debug: true}) // Activate rule engine debug mode
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [
{provide: OTTER_RULES_ENGINE_DEVTOOLS_OPTIONS, useValue: {isActivatedOnBootstrap: true}}
]
})
.then((m) => {
runInInjectionContext(m.injector, () => {
inject(RulesEngineDevtoolsMessageService)
});
})
// eslint-disable-next-line no-console
.catch(err => console.error(err));
If you forgot to activate the rules engine debug mode, you will not be able to interact with the panel.
The Chrome Extension has a dedicated tab for your rulesets debugging. It displays a view listing all ruleset executions, from the most recent to the oldest. If your ruleset has never been executed, you will not find it here.
The list is reactive. Its content will be updated whenever a new execution has been processed.
A rule execution can result in one of these four possible states:
[!WARNING] If a Ruleset has never been executed because its linked components and its validity range conditions have never been met, the Ruleset will not be part of the list. It will not be shown as deactivated.
You can expand a ruleset execution to find more information on the mentioned execution.
The collapsed view will provide some basic information on your ruleset execution:
name
Ruleset property but will transform '-' into spaces for
readability reasons. The expanded view provides much more details to debug your rule:
[!WARNING] This view is only a description of the rules and not the resulting actions.
[!INFO] A rule can result in another rule
The detailed view differs a bit for failed rulesets as no action will be triggered after the rule execution.
Failed rules are identified by a red 'Error' capsule.
The output list is replaced with the error message in the Rules Evaluation section.
In case a rule resulted in an error, there will be no output actions resulting from the Ruleset execution. Hence, all override actions will be removed from the list of resulting actions.
However, the error may come from one of the temporary facts set in one of the rules.
For this reason, the actions impacting the Ruleset temporary facts that have been run successfully will be displayed.