{"id":16935876,"url":"https://github.com/romainlanz/sentry","last_synced_at":"2025-03-22T12:31:51.012Z","repository":{"id":242285958,"uuid":"809162751","full_name":"RomainLanz/sentry","owner":"RomainLanz","description":"A wrapper around the Sentry SDK to make it easier to use in a AdonisJS application","archived":false,"fork":false,"pushed_at":"2025-03-13T08:05:21.000Z","size":384,"stargazers_count":36,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"0.3","last_synced_at":"2025-03-13T08:40:04.141Z","etag":null,"topics":["adonisjs","sentry","sentry-sdk"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/RomainLanz.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":"2024-06-01T22:01:44.000Z","updated_at":"2025-03-13T08:05:25.000Z","dependencies_parsed_at":"2024-06-01T23:46:33.147Z","dependency_job_id":"be51e219-aa04-4400-84f1-d52edb6a18ad","html_url":"https://github.com/RomainLanz/sentry","commit_stats":null,"previous_names":["romainlanz/sentry"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomainLanz%2Fsentry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomainLanz%2Fsentry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomainLanz%2Fsentry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomainLanz%2Fsentry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RomainLanz","download_url":"https://codeload.github.com/RomainLanz/sentry/tar.gz/refs/heads/0.3","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959444,"owners_count":20538625,"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":["adonisjs","sentry","sentry-sdk"],"created_at":"2024-10-13T20:55:33.243Z","updated_at":"2025-03-22T12:31:51.000Z","avatar_url":"https://github.com/RomainLanz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/RomainLanz/sentry/assets/2793951/229f22b4-6340-482d-8244-9dce18ca395f\" alt=\"@rlanz/sentry\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![typescript-image]][typescript-url]\n[![gh-workflow-image]][gh-workflow-url]\n[![npm-image]][npm-url]\n[![npm-download-image]][npm-download-url]\n[![license-image]][license-url]\n\n\u003c/div\u003e\n\n\u003chr /\u003e\n\n`@rlanz/sentry` is a simple wrapper around the Sentry SDK to make it easier to use in a AdonisJS application.\n\n## Installation\n\n```sh\nnode ace add @rlanz/sentry\n```\n\n## Usage\n\nThe package will automatically register a middleware and configure the Sentry SDK.\n\n```ts\nimport type { HttpContext } from '@adonisjs/core/http'\nimport { Sentry } from '@rlanz/sentry'\n\nexport default class HelloController {\n  greet({ params, response}: HttpContext) {\n    Sentry.captureMessage(`Hello, ${params.name}!`)\n\n    return response.ok({ message: `Hello, ${params.name}!` })\n  }\n}\n```\n\nThe SDK is automatically scoped to the current request.\n\n```ts\nimport { inject } from '@adonisjs/core'\nimport { Sentry } from '@rlanz/sentry'\n\n@inject()\nexport class GreetingService {  \n  greet(name: string) {\n    Sentry.captureMessage(`Hello, ${name}!`)\n    \n    return `Hello, ${name}!`\n  }\n}\n```\n\n### Capturing Errors\n\nYou can capture errors by calling the `captureException` method on the SDK inside your exception handler.\n\n```ts\nimport { Sentry } from '@rlanz/sentry'\n\nexport default class HttpExceptionHandler extends ExceptionHandler {\n  // ...\n\n  async report(error: unknown, ctx: HttpContext) {\n    if (this.shouldReport(error as any)) {\n      Sentry.captureException(error)\n    }\n\n    return super.report(error, ctx)\n  }\n}\n```\n\n### Assigning User Context\n\nYou can assign user context to the Sentry SDK by calling the `setUser` method on the SDK once you are logged in.\n\n```ts\nimport { Sentry } from '@rlanz/sentry'\n\nexport default class SilentAuthMiddleware {\n  async handle(ctx: HttpContext, next: NextFn) {\n    // We are authenticating the user\n    await ctx.auth.check()\n\n    // If the user is authenticated, we assign the user context to Sentry\n    if (ctx.auth.isAuthenticated) {\n      const user = ctx.auth.getUserOrFail()\n      \n      Sentry.setUser({\n        id: user.id, \n        email: user.email, \n        username: user.username,\n      });\n    }\n    \n    return await next();\n  }\n}\n```\n\n### Adding Integrations\n\nSentry provides multiple integrations to enhance the data captured by the SDK. You can add integrations by changing the `integrations` array inside the configuration `config/sentry.ts`.\n\nFor example, if you want to add profiling to your application, you can add the `Profiler` integration.\n\n```sh\nnpm install @sentry/profiling-node\n```\n\n```ts\n// config/sentry.ts\n\nimport { nodeProfilingIntegration } from '@sentry/profiling-node';\n\nexport default defineConfig({\n  // ...\n  integrations: [nodeProfilingIntegration()],\n  profilesSampleRate: 0.2,\n})\n```\n\n[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/RomainLanz/sentry/checks.yml?branch=0.3\u0026style=for-the-badge\n[gh-workflow-url]: https://github.com/RomainLanz/sentry/actions/workflows/checks.yml\n[npm-image]: https://img.shields.io/npm/v/@rlanz/sentry.svg?style=for-the-badge\u0026logo=npm\n[npm-url]: https://www.npmjs.com/package/@rlanz/sentry\n[npm-download-image]: https://img.shields.io/npm/dm/@rlanz/sentry?style=for-the-badge\n[npm-download-url]: https://www.npmjs.com/package/@rlanz/sentry\n[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge\u0026logo=typescript\n[typescript-url]: https://www.typescriptlang.org\n[license-image]: https://img.shields.io/npm/l/@rlanz/sentry?color=blueviolet\u0026style=for-the-badge\n[license-url]: LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromainlanz%2Fsentry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromainlanz%2Fsentry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromainlanz%2Fsentry/lists"}