{"id":21571096,"url":"https://github.com/treblle/treblle-utils","last_synced_at":"2025-04-10T14:20:28.913Z","repository":{"id":129658092,"uuid":"562869719","full_name":"Treblle/treblle-utils","owner":"Treblle","description":"Common utilities for Treblle JavaScript SDKs","archived":false,"fork":false,"pushed_at":"2025-01-09T14:53:40.000Z","size":125,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-24T13:01:39.244Z","etag":null,"topics":["api","api-monitoring","backend","javascript","nodejs","treblle","treblle-sdk"],"latest_commit_sha":null,"homepage":"https://treblle.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Treblle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-11-07T12:37:04.000Z","updated_at":"2025-01-09T14:48:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd28b09c-24bc-4730-98f0-63500cf1bd35","html_url":"https://github.com/Treblle/treblle-utils","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ftreblle-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ftreblle-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ftreblle-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ftreblle-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Treblle","download_url":"https://codeload.github.com/Treblle/treblle-utils/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248233935,"owners_count":21069493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-monitoring","backend","javascript","nodejs","treblle","treblle-sdk"],"created_at":"2024-11-24T11:14:52.201Z","updated_at":"2025-04-10T14:20:28.892Z","avatar_url":"https://github.com/Treblle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# treblle-utils\n\n`treblle-utils` exposes common methods(utils), that is needed to build JavaScript SDKs for Treblle.\n\n## Installation\n\n```sh\nnpm i @treblle/utils --save\n```\n\n## Usage\n\n### `sendPayloadToTreblle()`\n\nSends payload to Treblle.\n\n```js\nconst { sendPayloadToTreblle } = require('@treblle/utils')\n\ntry {\n  sendPayloadToTreblle(payload, '\u003cYOUR_TREBLLE_API_KEY\u003e')\n} catch (error) {\n  console.log(error)\n}\n```\n\n\u003e 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.\n\n### `generateFieldsToMask()`\n\nGenerates fields to be masked.\n\n```js\nconst { generateFieldsToMask } = require('@treblle/utils')\n\nconst fieldsToMask = generateFieldsToMask(['field1', 'field2'])\n```\n\nThe `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)\n\n### `maskSensitiveValues()`\n\nMasks sensitive values in the payload to be sent.\n\n```js\nconst { maskSensitiveValues } = require('@treblle/utils')\n\nconst maskedRequestPayload = maskSensitiveValues(payload, fieldsToMask)\n```\n\n### `getRequestDuration()`\n\nUseful in frameworks that don't calculate requests duration.\n\n```js\nconst { getRequestDuration } = require('@treblle/utils')\n\nconst requestStartTime = process.hrtime()\n\nconst loadTime = getRequestDuration(requestStartTime)\n```\n\n\u003e Check out the [Treblle docs](https://docs.treblle.com) for steps to integrate Treblle in your JavaScript(Node.js) projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreblle%2Ftreblle-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreblle%2Ftreblle-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreblle%2Ftreblle-utils/lists"}