Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/treblle/treblle-utils
Common utilities for Treblle JavaScript SDKs
https://github.com/treblle/treblle-utils
api api-monitoring backend javascript nodejs treblle treblle-sdk
Last synced: about 2 months ago
JSON representation
Common utilities for Treblle JavaScript SDKs
- Host: GitHub
- URL: https://github.com/treblle/treblle-utils
- Owner: Treblle
- License: mit
- Created: 2022-11-07T12:37:04.000Z (about 2 years ago)
- Default Branch: develop
- Last Pushed: 2023-10-03T15:07:10.000Z (over 1 year ago)
- Last Synced: 2024-04-16T09:02:04.790Z (9 months ago)
- Topics: api, api-monitoring, backend, javascript, nodejs, treblle, treblle-sdk
- Language: JavaScript
- Homepage: https://treblle.com
- Size: 120 KB
- Stars: 4
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# treblle-utils
`treblle-utils` exposes common methods(utils), that is needed to build JavaScript SDKs for Treblle.
## Installation
```sh
npm i @treblle/utils --save
```## Usage
### `sendPayloadToTreblle()`
Sends payload to Treblle.
```js
const { sendPayloadToTreblle } = require('@treblle/utils')try {
sendPayloadToTreblle(payload, '')
} catch (error) {
console.log(error)
}
```> You can check out [this](https://github.com/Treblle/treblle-utils/blob/develop/treblle-payload-schema.json) JSON schema for the shape of the payload to send to Treblle.
### `generateFieldsToMask()`
Generates fields to be masked.
```js
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](https://docs.treblle.com/en/security/masked-fields)
### `maskSensitiveValues()`
Masks sensitive values in the payload to be sent.
```js
const { maskSensitiveValues } = require('@treblle/utils')const maskedRequestPayload = maskSensitiveValues(payload, fieldsToMask)
```### `getRequestDuration()`
Useful in frameworks that don't calculate requests duration.
```js
const { getRequestDuration } = require('@treblle/utils')const requestStartTime = process.hrtime()
const loadTime = getRequestDuration(requestStartTime)
```> Check out the [Treblle docs](https://docs.treblle.com) for steps to integrate Treblle in your JavaScript(Node.js) projects.