Skip to content

Treblle/treblle-utils

Repository files navigation

treblle-utils

treblle-utils exposes common methods(utils), that is needed to build JavaScript SDKs for Treblle.

Installation

npm i @treblle/utils --save

Usage

sendPayloadToTreblle()

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.

generateFieldsToMask()

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

maskSensitiveValues()

Masks sensitive values in the payload to be sent.

const { maskSensitiveValues } = require('@treblle/utils')

const maskedRequestPayload = maskSensitiveValues(payload, fieldsToMask)

getRequestDuration()

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.