Skip to content

Treblle with Strapi

To integrate Treblle with Strapi, we provide an official SDK for Strapi which is a Strapi plugin - treblle-strapi.

Requirements

  • Strapi v4

Installation

Terminal window
npm i @treblle/strapi --save

After installation set the following environment variables your .env

You can find the values in your Treblle dashboard

  • TREBLLE_API_KEY
  • TREBLLE_PROJECT_ID

Setup

treblle-strapi exposes a middleware that you can add in your config/middlewares.js array like so:

module.exports = [
//...
'plugin::treblle.treblle',
]

And that’s it, Treblle will now monitor your Strapi content API.

Config

AdditionalFieldsToMask

You can specify additional fields to be masked before sending the Treblle payload. To do so, add the following config in config/plugins.js

module.exports = {
treblle: {
config: {
additionalFieldsToMask: ['FIELD_TO_MASK_1'],
},
},
}

Do replace FIELDS_TO_MASK_1 with the field you want to mask.

routesToMonitor

By default, this Strapi plugin will monitor only routes that starts has /api in the URL. You can override this by passing a routesToMonitor array in the config of the plugin.

module.exports = {
treblle: {
config: {
routesToMonitor: ['api'], // this is the default
},
},
}