@lautmaler/jovo-plugin-turninfo
v0.5.0
Published
extract some infos about the request just processed and log it as a json
Downloads
72
Readme
TurnInfoLogPlugin
The TurnInfoLogPlugin
is a Jovo
plugin that performs data aggregation of request and state data, e.g. requestId
, sessionData
and much more.
Installation
Install the plugin in your Jovo project using npm
:
$ npm install @lautmaler/jovo-plugin-turninfo
After successfully installing the plugin, you can add it to your app configuration:
const app = new App({
// ...
plugins: [
// ...
new TurnInfoLogPlugin({
// ...
}),
],
});
The plugin accepts the following configuration:
new TurnInfoLogPlugin({
enabled: true,
override(jovo: Jovo) {
return {
// ...
};
},
skipTests: true,
});
enabled
: Whether to enable the plugin in the current context or notoverride
: Function used to override properties or add new ones, e.g. platform-specific fields, see overriding propertiesskipTests
: Whether to enable/disable this plugin when running unit tests
Overriding properties
It is common to log platform-specific properties when working with the TurnInfoLogPlugin
, since it only logs standard, globally accessible properties by default. To work around this, you can use the override()
function in the configuration to override and add properties to your log. Simply return an object of key-value pairs, that will later on be merged with the default logging object.
new TurnInfoLogPlugin({
override(jovo: Jovo) {
return {
requestId: jovo.$request.id,
intent: jovo.$input.nlu.intent,
// ...
}
}
})
You can even type the parameter to match your platform, e.g. using CorePlatform
:
new TurnInfoLogPlugin({
override(core: Core) {
return {
timeZone: core.$request.timeZone,
// ...
}
}
})
Just keep in mind that if you're using multiple platforms, you'll have to disambiguate what platform you're using in your override()
function.