{"id":13575256,"url":"https://github.com/ntegral/nestjs-sentry","last_synced_at":"2025-05-15T14:08:04.584Z","repository":{"id":35032519,"uuid":"198686970","full_name":"ntegral/nestjs-sentry","owner":"ntegral","description":"Provides an injectable sentry.io client to provide enterprise logging nestjs modules","archived":false,"fork":false,"pushed_at":"2024-09-11T23:34:08.000Z","size":1006,"stargazers_count":383,"open_issues_count":55,"forks_count":97,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T14:15:49.022Z","etag":null,"topics":["enterprise-logging","nestjs","sentry"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntegral.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":"2019-07-24T18:10:17.000Z","updated_at":"2025-03-07T14:48:05.000Z","dependencies_parsed_at":"2024-01-16T21:09:43.767Z","dependency_job_id":"2a33e6e9-c6fd-4c52-bd11-d15aae5bd7a4","html_url":"https://github.com/ntegral/nestjs-sentry","commit_stats":{"total_commits":52,"total_committers":15,"mean_commits":3.466666666666667,"dds":0.75,"last_synced_commit":"f80c538bb827450bcd5bfb07e22b1d35ee8a12d9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntegral%2Fnestjs-sentry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntegral%2Fnestjs-sentry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntegral%2Fnestjs-sentry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntegral%2Fnestjs-sentry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntegral","download_url":"https://codeload.github.com/ntegral/nestjs-sentry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253831001,"owners_count":21971007,"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":["enterprise-logging","nestjs","sentry"],"created_at":"2024-08-01T15:00:59.427Z","updated_at":"2025-05-15T14:07:59.572Z","avatar_url":"https://github.com/ntegral.png","language":"HTML","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=PM2PTQ6Z2XATQ\u0026source=url"],"categories":["HTML"],"sub_categories":[],"readme":"[![npm version](http://img.shields.io/npm/v/@ntegral/nestjs-sentry.svg?style=flat)](https://npmjs.org/package/@ntegral/nestjs-sentry \"View this project on npm\")\n[![Codecov Coverage](https://img.shields.io/codecov/c/github/ntegral/nestjs-sentry/master.svg?style=flat-square)](https://codecov.io/gh/ntegral/nestjs-sentry)\n[![ISC license](http://img.shields.io/badge/license-ISC-brightgreen.svg)](http://opensource.org/licenses/ISC)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=PM2PTQ6Z2XATQ\u0026source=url)\n\n\u003cp align=\"center\"\u003e\n  \u003ch3 align=\"center\"\u003e\n    @ntegral/nestjs-sentry\n  \u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    Provides an injectable sentry.io client to provide enterprise logging nestjs modules\n  \u003c/p\u003e\n\u003c/p\u003e\n\n## Table Of Contents\n\n- [NestJS 8 Support](#nestjs-8-support)\n- [About](#about)\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [Contributing](#contributing)\n- [License](#license)\n- [Acknowledgements](#acknowledgements)\n\n## NestJS 10 Support\nVersion 4.x.x will support NestJS 10+. If you need support for older versions please see reference below.  Thanks for you support!\n\n## NestJS 8 Support\nVersion 3.x.x will support NestJS 8+. If you need support for NestJS 7 please continue to use Version 2.x.x.  Thanks for you support!\n\n## About\n\n`@ntegral/nestjs-sentry` implements a module, `SentryModule`, which when imported into\nyour nestjs project provides a Sentry.io client to any class that injects it. This\nlets Sentry.io be worked into your dependency injection workflow without having to\ndo any extra work outside of the initial setup.\n\n## Installation\n\n```bash\nnpm install --save @ntegral/nestjs-sentry @sentry/node\n```\n\n## Github Sample Project using @ntegral/nestjs-sentry\n\nThe following project was created as a sample starter project to get you going... (if needed...).\n- [@ntegral/nestjs-sentry sample](https://github.com/ntegral/nestjs-sentry-example)\n\n## Getting Started\n\nThe simplest way to use `@ntegral/nestjs-sentry` is to use `SentryModule.forRoot`\n\n```typescript\nimport { Module } from '@nestjs-common';\nimport { SentryModule } from '@ntegral/nestjs-sentry';\n\n@Module({\n  imports: [\n    SentryModule.forRoot({\n      dsn: 'sentry_io_dsn',\n      debug: true | false,\n      environment: 'dev' | 'production' | 'some_environment',\n      release: 'some_release', | null, // must create a release in sentry.io dashboard\n      logLevels: ['debug'] //based on sentry.io loglevel //\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nThe async way `@ntegral/nestjs-sentry` is to use `SentryModule.forRootAsync`\n\n```typescript\nimport { Module } from '@nestjs-common';\nimport { SentryModule } from '@ntegral/nestjs-sentry';\nimport { ConfigModule } from '@ntegral/nestjs-config';\nimport { ConfigService } from '@ntegral/nestjs-config';\n\n@Module({\n  imports: [\n    SentryModule.forRootAsync({\n      imports: [ConfigModule],\n      useFactory: async (cfg:ConfigService) =\u003e ({\n        dsn: cfg.get('SENTRY_DSN'),\n        debug: true | false,\n        environment: 'dev' | 'production' | 'some_environment',\n        release: 'some_release', | null, // must create a release in sentry.io dashboard\n        logLevels: ['debug'] //based on sentry.io loglevel //\n      }),\n      inject: [ConfigService],\n    })\n  ]\n})\n\nexport class AppModule {}\n```\n\nYou can then inject the Sentry client into any of your injectables by using a\ncustom decorator\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { InjectSentry, SentryService } from '@ntegral/nestjs-sentry';\n\n@Injectable()\nexport class AppService {\n  public constructor(@InjectSentry() private readonly client: SentryService) {\n      client.instance().captureMessage(message, Sentry.Severity.Log);\n      client.instance().captureException(exception);\n      ... and more\n  }\n}\n```\n\nYou can instruct Nest to use the SentryService as the default logger:\n\n```typescript\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule, { logger: false });\n\n  app.useLogger(SentryService.SentryServiceInstance());\n  await app.listen(3000);\n}\nbootstrap();\n```\n\nYou can instuct use the SentryService to log non-error messages as breadcrumbs or use the native Sentry.addBreadcrumb method.\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { InjectSentry, SentryService } from '@ntegral/nestjs-sentry';\n\n@Injectable()\nexport class AppService {\n  constructor(@InjectSentry() private readonly client: SentryService) {\n    client.log('AppSevice Loaded','test', true); // creates log asBreadcrumb //\n    client.instance().addBreadcrumb({level: 'debug' , message: 'How to use native breadcrumb', data: { context: 'WhatEver'}})\n    client.debug('AppService Debug', 'context');\n  }\n  getHello(): string {\n    return 'Hello World!';\n  }\n}\n```\n\n## Interceptors\n\nBREAKING CHANGES: The SentryInterceptor can be used in projects that don't require GraphQL. If you will be needed GraphQL support, use the GraphqlInterceptor.  Using the GraphqlInterceptor will create a dependancy for the @nestjs/graphql package.\n\n```bash\nnpm install --save @nestjs/graphql\n```\n\nUsing graphql interceptor globally\n```typescript\nimport { Module } from '@nestjs/common';\nimport { APP_INTERCEPTOR } from '@nestjs/core';\nimport { GraphqlInterceptor } from '@ntegral/nestjs-sentry';\n\n@Module({\n  ....\n  providers: [\n    {\n      provide: APP_INTERCEPTOR,\n      useFactory: () =\u003e new GraphqlInterceptor(),\n    },\n  ],\n})\nexport class AppModule {}\n```\n\nUsing the sentry interceptor globally\n```typescript\nimport { Module } from '@nestjs/common';\nimport { APP_INTERCEPTOR } from '@nestjs/core';\nimport { SentryInterceptor } from '@ntegral/nestjs-sentry';\n\n@Module({\n  ....\n  providers: [\n    {\n      provide: APP_INTERCEPTOR,\n      useFactory: () =\u003e new SentryInterceptor({\n        filters: [{\n          type: HttpException,\n          filter: (exception: HttpException) =\u003e 500 \u003e exception.getStatus() // Only report 500 errors\n        }]\n      }),\n    }\n  ],\n})\nexport class AppModule {}\n```\n\n## Flushing sentry\nSentry does not flush all the errors by itself, it does it in background so that it doesn't block the main thread. If \nyou kill the nestjs app forcefully some exceptions have to be flushed and logged successfully.\n\nIf you want to force that behaviour use the close flag in your options. That is handy if using nestjs as a console\nrunner. Keep in mind that you need to have ```app.enableShutdownHooks();``` enabled in order \nfor closing (flushing) to work.\n\n```typescript\nimport { Module } from '@nestjs-common';\nimport { SentryModule } from '@ntegral/nestjs-sentry';\n\n@Module({\n  imports: [\n    SentryModule.forRoot({\n      dsn: 'sentry_io_dsn',\n      debug: true | false,\n      environment: 'dev' | 'production' | 'some_environment',\n      release: 'some_release', | null, // must create a release in sentry.io dashboard\n      logLevels: ['debug'] //based on sentry.io loglevel //\n      close: {\n        enabled: true,\n        // Time in milliseconds to forcefully quit the application  \n        timeout?: number,  \n      }\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n\n## Contributing\n\nI would greatly appreciate any contributions to make this project better. Please\nmake sure to follow the below guidelines before getting your hands dirty.\n\n1. Fork the repository\n2. Create your branch (`git checkout -b my-branch`)\n3. Commit any changes to your branch\n4. Push your changes to your remote branch\n5. Open a pull request\n\n## License\n\nDistributed under the ISC License. See `LICENSE` for more information.\n\n## Acknowledgements\n\n- [nestjs](https://nestjs.com)\n- [@sentry/node](https://github.com/getsentry/sentry-javascript)\n\nCopyright \u0026copy; 2019 Ntegral Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntegral%2Fnestjs-sentry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntegral%2Fnestjs-sentry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntegral%2Fnestjs-sentry/lists"}