{"id":20767018,"url":"https://github.com/binded/the-best-winston-sentry","last_synced_at":"2025-03-11T18:51:28.645Z","repository":{"id":97906466,"uuid":"94372413","full_name":"binded/the-best-winston-sentry","owner":"binded","description":"Winston logger transport for Sentry","archived":false,"fork":false,"pushed_at":"2017-06-20T18:24:42.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-18T06:28:14.110Z","etag":null,"topics":["nodejs","sentry","winston"],"latest_commit_sha":null,"homepage":"","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/binded.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-14T20:55:33.000Z","updated_at":"2017-06-14T20:57:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"337a5eea-1956-43d0-8719-803e89ffc2b2","html_url":"https://github.com/binded/the-best-winston-sentry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fthe-best-winston-sentry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fthe-best-winston-sentry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fthe-best-winston-sentry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fthe-best-winston-sentry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binded","download_url":"https://codeload.github.com/binded/the-best-winston-sentry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243094608,"owners_count":20235531,"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":["nodejs","sentry","winston"],"created_at":"2024-11-17T11:27:18.607Z","updated_at":"2025-03-11T18:51:28.625Z","avatar_url":"https://github.com/binded.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/binded/the-best-winston-sentry.svg?branch=master)](https://travis-ci.org/binded/the-best-winston-sentry)\n\n# the-best-winston-sentry\n\nThe best [winston logger](https://github.com/winstonjs/winston)\ntransport for Sentry / Raven 😁\n\n## Install\n\n```bash\nnpm i the-best-winston-sentry\n```\n\n## Usage\n\nFollow this sample configuration to use:\n\n```javascript\nconst winston = require('winston')\nconst SentryTransport = require('the-best-winston-sentry')\n\nconst sentryTransport = new SentryTransport({\n  level: 'warn',\n  dsn: '{{ YOUR SENTRY DSN }}',\n  tags: { key: 'value' },\n  extra: { key: 'value' },\n})\n\nconst logger = new winston.Logger({\n  transports: [\n    new winston.transports.Console({level: 'silly'}),\n    sentryTransport,\n  ],\n})\n\n// raven can be accessed from the transport object:\nsentryTransport.raven\n// or\nlogger.transports.sentry.raven\n```\n\nTo catch and report all uncaught errors to Sentry with, simply set the\n`patchGlobal` option to `true` and it will call `Raven.install()`:\n\n```javascript\nnew SentryTransport({ patchGlobal: true })\n```\n\nWinston logging levels are mapped to the default sentry levels like this:\n\n```javascript\n{\n    silly: 'debug',\n    verbose: 'debug',\n    info: 'info',\n    debug: 'debug',\n    warn: 'warning',\n    error: 'error'\n}\n```\n\nYou can customize how log levels are mapped using the `levelsMap` option:\n\n```javascript\nnew Sentry({\n  levelsMap: {\n    verbose: 'info',\n  },\n})\n```\n\n### Supported metadata\n\n```javascript\n{\n  user, // user object\n  req, // http request object\n  tags, // sentry tags, must be mapping of string -\u003e string\n  extra, // sentry extra, can be arbitrary JSON\n  fingerprint, // used by sentry to group errors\n  // ...\n  // unknown props are merged with extra\n}\n```\n\n### Reporting exceptions\n\nWhen logging an error, there are three ways to pass the error and\nmetadata:\n\n- By assigning known properties directly to the error object\n\n```javascript\nconst err = new Error('some error')\nerr.user = user\nerr.req = req\nerr.tags = { foo: 'bar' }\nlogger.error('oops!', err)\n```\n\n- By passing the error as the message (this might break other\n    transports)\n\n```javascript\nconst err = new Error('some error')\nlogger.error(err, { user, req, tags: { foo: 'bar' } })\n```\n\n- **Recommended**: by passing the error as an `err` property on the metadata\n\n```javascript\nconst err = new Error('some error')\nlogger.error('oops!', {\n  err,\n  user,\n  req,\n  tags: { foo: 'bar' },\n})\n```\n\nWhen logging an error, the error's message will be concatenated with the\nmessage passed to the Winston logger, following the following format:\n`{msg} cause: {err.message}`, e.g.:\n\n```javascript\nlogger.error('Oops!', new Error('some error'))\n```\n\nwill show the following error message in sentry:\n\n```\nOops! cause: some error\n```\n\nThe sentry event ID is added as a `sentryId` on the error object:\n\n```javascript\nconst testErr = new Error('some error')\nlogger.error('Oops!', testErr, () =\u003e {\n  console.log(testErr.sentryId)\n  // =\u003e 21479ebd4eec4afaaf9426617196a10a\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinded%2Fthe-best-winston-sentry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinded%2Fthe-best-winston-sentry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinded%2Fthe-best-winston-sentry/lists"}