treblle-utils
exposes common methods(utils), that is needed to build JavaScript SDKs for Treblle.
npm i @treblle/utils --save
Sends payload to Treblle.
const { sendPayloadToTreblle } = require('@treblle/utils')
try {
sendPayloadToTreblle(payload, '<YOUR_TREBLLE_API_KEY>')
} catch (error) {
console.log(error)
}
You can check out this JSON schema for the shape of the payload to send to Treblle.
Generates fields to be masked.
const { generateFieldsToMask } = require('@treblle/utils')
const fieldsToMask = generateFieldsToMask(['field1', 'field2'])
The field1
and field2
placeholder represent additional fields you want masked alongside the default fields that will be masked
Masks sensitive values in the payload to be sent.
const { maskSensitiveValues } = require('@treblle/utils')
const maskedRequestPayload = maskSensitiveValues(payload, fieldsToMask)
Useful in frameworks that don't calculate requests duration.
const { getRequestDuration } = require('@treblle/utils')
const requestStartTime = process.hrtime()
const loadTime = getRequestDuration(requestStartTime)
Check out the Treblle docs for steps to integrate Treblle in your JavaScript(Node.js) projects.