{"id":26452975,"url":"https://github.com/clever/sentry-node","last_synced_at":"2025-03-18T18:41:06.914Z","repository":{"id":12022167,"uuid":"14605682","full_name":"Clever/sentry-node","owner":"Clever","description":"simple node wrapper around the Sentry API","archived":false,"fork":false,"pushed_at":"2024-09-23T15:44:42.000Z","size":94,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":65,"default_branch":"master","last_synced_at":"2025-03-17T16:53:18.569Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Clever.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}},"created_at":"2013-11-22T01:35:19.000Z","updated_at":"2024-09-23T15:44:46.000Z","dependencies_parsed_at":"2023-01-11T20:17:26.581Z","dependency_job_id":null,"html_url":"https://github.com/Clever/sentry-node","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clever%2Fsentry-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clever%2Fsentry-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clever%2Fsentry-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clever%2Fsentry-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clever","download_url":"https://codeload.github.com/Clever/sentry-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244282976,"owners_count":20428104,"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":[],"created_at":"2025-03-18T18:41:05.434Z","updated_at":"2025-03-18T18:41:06.904Z","avatar_url":"https://github.com/Clever.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Sentry-node\n**Node v10 compatible**\n\n[![Build Status](https://travis-ci.org/Clever/sentry-node.png?branch=master)](https://travis-ci.org/Clever/sentry-node)\n\nA simple Node wrapper around the [Sentry](http://getsentry.com/) API.\n\n## Installation\n```\n$ npm install sentry-node\n```\n\n## Testing\n```\n$ npm test\n```\n\n## Usage\n\n### Creating the Client\n\n```javascript\nvar Sentry = require('sentry-node');\n```\n\nYou can initialize `sentry-node` by passing in a Sentry DSN:\n```javascript\nvar sentry = new Sentry('\u003cyour Sentry DSN\u003e');\n```\n\nYou can also pass in the individual parameters that make up the DSN as an object:\n```javascript\nvar sentry = new Sentry({\n  key: '\u003cyour sentry public key\u003e',\n  secret: '\u003cyour sentry secret key\u003e',\n  project_id: '\u003cyour sentry project id\u003e'\n});\n```\n\n**Note:** If the DSN passed to `Sentry` is invalid, the client will be disabled. You will still be able to call its methods, but no data will be sent to Sentry. This can be useful behavior for testing and development environments, where you may not want to be logging errors to Sentry.\n\n### Error\n```javascript\nsentry.error(err, logger, culprit, extra);\n```\n\n#### sample\n\n```javascript\nsentry.error(\n  new Error(\"The error method expected an Error instance as first argument.\"),\n  '/sentry-node.coffee',\n  \"Bad arguments to sentry-node:error method\",\n  {\n    note: \"to test sentry-node error method\",\n    version: \"0.1.0\"\n  }\n);\n```\n![image](http://i.imgur.com/VMTshz3.png)\n\n#### arguments\n\n* **err:** the error object to log, must be an instance of `Error`. `err.message` will be used for the smaller text that appears right under `culprit`\n* **logger:** the place where the error was detected\n* **culprit:** the location of the code that caused the error. If not known, should be `null`. If included, is the big text at the top of the sentry error.\n* **extra:** (optional) an object that gives more context about the error, it is augmented with `stacktrace` which contains `err.stack`\n\n### Message\n```javascript\nsentry.message(message, logger, extra);\n```\n\n#### sample\n\n```javascript\nsentry.message(\n  \"message\",\n  \"/trial.coffee\",\n  {\n    note: \"to test sentry-node api\",\n    type: \"message\"\n  }\n);\n```\n\n![image](http://i.imgur.com/kUMkhX2.png)\n\n#### arguments\n\n* **message:** text will be used for both the big text that appears at the top and the smaller text appears right under it\n* **logger:** the place where the error was detected\n* **extra:** (optional) an object that gives more context about the message\n\n### Wrapper\nWrapper can be used to wrap an async function, which will attempt to log any error's passed to the async function's callback with sentry.\n\n```javascript\nsentry.wrapper(logger, timeout).wrap(some_async_func);\n```\n\nWhen using wrapper, in case of an error, it's possible to pass extra context parameters by assigning them to the `wrapper.globals` variable:\n```\nwrapper = sentry_wrapper(logger, timeout)\nwrapper.wrap(function(cb) {\n  if (some_error_case) {\n    wrapper.globals.context = \"some context information to be logged\";\n    cb(new Error(\"error has occured\"));\n  }\n});\n```\n\n### sample\n\n```javascript\nwrapped = sentry.wrapper('logger', 1000).wrap(function(callback){\n    callback(new Error('error to be logged'));\n});\nwrapped();\n```\n\n### arguments\n\n* **logger:** value used as the logger argument to sentry.error\n* **timeout:** (optional) the timeout (in ms) to wait for sentry to log error.  If timeout is exceeded, wrapped async function's callback will return a sentry timeout error.\n\n## Events\n\nThe Sentry client emits three events that you can listen to:\n\n- `'logged'`: emitted when an error or message is successfully logged to Sentry\n- `'error'`: emitted when an error occurs within the Sentry client and an error or message fails to be logged to Sentry\n- `'warning'`:\n    * emitted when a value of the incorrect type is passed as err or logger\n    * emitted when a HTTP 429 (burst rate limiting) is returned from Sentry API\n\n```javascript\nsentry.on('logged', function(){\n  console.log('Yay, it worked!');\n});\nsentry.on('error', function(e){\n  console.log('oh well, Sentry is broke.');\n  console.log(e);\n})\nsentry.on('warning', function(e){\n  console.log('You did something sentry didn't expect', e);\n})\n```\n\n## Best Practices\n\nThe Sentry client expects an instance of `Error` - if it is given some other object, it will still send the error to Sentry, but much of the error content will be lost. This behavior is intended to align with the node.js best practice of always using `Error` instances. This means you should always take care to construct an `Error` object with an appropriate message before logging it to Sentry (really, you should always be using `Error` objects to represent error data throughout your codebase).\n\nYou should always give as much context as possible with your errors. Make liberal use of the `extra` parameter to send more information that may help someone (most likely your future self) diagnose the cause of the error.\n\nIf you attach other fields with important data to the `Error` instance, they will not show up in Sentry automatically. You should make sure to include those fields on the `extra` object.\n\nSentry asks for three main fields:\n* `message`: what was the exception? Always the message from the passed in error.\n* `logger`: what piece of code generated the message to Sentry? Usually just whatever application actually holds the Sentry client.\n* `extra`: what other information is needed to determine the cause of the error\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclever%2Fsentry-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclever%2Fsentry-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclever%2Fsentry-node/lists"}