@elysiumjs/plugin-sentry 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @elysiumjs/plugin-sentry
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`8ac91ab`](https://github.com/na2axl/elysiumjs/commit/8ac91ab676b1119b4eecf0ddb3fd0a3e84017cac) Thanks [@na2axl](https://github.com/na2axl)! - Upgrade dependencies to their latest major versions: wampy 8, zod 4, commander 15, @casl/ability 7, OpenTelemetry SDK 2 (sdk-node 0.300, resources 3), @sentry/bun 11. Generated projects now use TypeScript 7.
8
+
9
+ Breaking in `@elysiumjs/mnemosyne-drizzle`: it now requires drizzle-orm 1.0 (release candidate) and generated projects use drizzle-kit 1.0. `ColumnsWithTable` is no longer re-exported. `migration:generate` writes 1.0 migration folders (`<timestamp>_<name>/migration.sql`), and `migration:run` tracks those by folder name while still running flat `*.sql` files. Existing projects can upgrade their migrations folder with `drizzle-kit up`: `migration:run` recognises the moved migrations as already applied and renames their records. The `make:model` stub now generates a `pgTable` and a `DrizzleModel` built from it.
10
+
11
+ Breaking in `@elysiumjs/core`: the deprecated `@elysiajs/swagger` plugin is replaced by `@elysiajs/openapi`, and the app option `swagger` is renamed `openapi` (typed `ElysiaOpenAPIConfig | false`). Without a `path`, the docs now live at `/openapi` instead of `/swagger`. The UI options `scalarConfig` and `swaggerOptions` are now `scalar` and `swagger`. Elysia stays on 1.4 (now `^1.4.30`) until Elysia 2 and its OpenAPI plugin are stable.
12
+
13
+ Also in `@elysiumjs/core`: the WAMP `onChallenge` callback must return a string (or a promise of one); `null` is no longer accepted. `onError` now receives the error and `onReconnectSuccess` receives wampy's details object. `WampClient` is now wampy's own `Wampy` type. `onOpen` is called by Elysium once the connection is established, since wampy 8 no longer has that callback.
14
+
15
+ - [`07236b3`](https://github.com/na2axl/elysiumjs/commit/07236b386c2506590d74e8753ce847c1e184b3ee) Thanks [@na2axl](https://github.com/na2axl)! - Introduce the module system. Modules are now the only way to register anything in an Elysium.js app. This is a breaking change with no compatibility layer.
16
+
17
+ Breaking changes:
18
+
19
+ - `@Module.register()` takes `imports`, `services`, `exports`, `controllers`, `commands`, `jobs`, `prefix` and `env`. Services are private to their module unless exported (or global). The `beforeRegister` and `afterRegister` hooks are replaced by `onInit`, `onServe` and `onDestroy`.
20
+ - Configurable modules are bound with `with()`, for example `HermesModule.with({ level: 'debug' })`. `with()` accepts an object or a function.
21
+ - Decorators only record metadata. Importing a file no longer registers commands, services or event wiring, and the side-effect imports of the packages are removed. List commands, jobs and services in the module that owns them.
22
+ - `@Application.register()` no longer takes `database`, `redis`, `wamp` or `'elysium:hermes'`/`'elysium:cerberus'` keys. Use `DrizzleModule`, `RedisModule`, `WampModule`, `HermesModule` and `CerberusModule`. Package plugins are replaced by modules: add `SentryModule` instead of the `plugin()` function. `plugins` still accepts plain Elysia plugin factories.
23
+ - Constructing an `Application` no longer runs it. Use `await App.start()`; `Application.testing()` boots a module graph for tests. The `styx` binary loads `src/app.ts` (or `index.ts`) and starts the exported application, so a project entry no longer needs to import commands.
24
+ - The job system of core (`Job`, `Worker`, `WorkerPool`, `commandWork`) is removed. `@elysiumjs/heracles` is the only job system: extend its `Job`, list jobs in a module's `jobs`, declare queues with `HeraclesModule.with({ queues })`, and dispatch with `Heracles.dispatch()`.
25
+ - `@elysiumjs/styx` ships `StyxModule`, active in development only. The `migration:generate` and `migration:run` commands move to `DrizzleModule` and are available in production.
26
+ - `@elysiumjs/mnemosyne` ships `MnemosyneModule` for its caches (`redis: false` or `memory: false` opts out). `DrizzleModule` imports it.
27
+ - New modules: `HephaestusModule`, `ArgusModule` (`serviceName` is required), `SentryModule` (needs a `dsn` or `SENTRY_DSN`) and `CerberusModule` (`getSubject` is required).
28
+ - Module and service code throws typed errors (for example `InvalidModuleConfigError`) instead of exiting the process. `Application.run()` prints them and exits; command `run()` methods may still exit, and package plugin factories are unchanged.
29
+ - `Application.register` merges subclass props over the parent's (own props, then own metadata, then parent, then defaults), and concatenates `modules` parent first. Previously defaults and parent values won, so `openapi` could not be enabled.
30
+ - `Heracles.dispatch` starts a stopped queue on first use, so producers no longer start queues. `Queue.start()` is idempotent.
31
+ - `create-elysium` generates apps that use modules, and adds Sentry and Hephaestus to the `modules` list.
32
+ - `@Event.on`/`@Event.once` method listeners on classes in a loaded module's `services` or `controllers` are wired by the kernel and run in their module's context. Jobs, commands and middlewares are not wired, and an instance listener on a class that is not a service throws `EventListenerNotSupportedError`. Listeners on classes not listed in a loaded module no longer fire.
33
+ - New typed errors: `CircularDependencyError` (services that depend on each other, in sync and async resolution), `DuplicateModuleNameError` (two different module classes sharing a name; module scopes and config tokens are name based) and `EventListenerNotSupportedError`.
34
+ - Lazy boot contract: a CLI command initialises only its own module and that module's imports. Sync helpers such as `Database.getConnection()` work when the owning module's `onInit` is synchronous; otherwise they throw `ServiceNotReadyError` naming the module. Use `await Service.resolve()` or set `static boot = true` on the command.
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [[`8ac91ab`](https://github.com/na2axl/elysiumjs/commit/8ac91ab676b1119b4eecf0ddb3fd0a3e84017cac), [`3625883`](https://github.com/na2axl/elysiumjs/commit/3625883dba92f1596e7444ee52f9399d8e9b049f), [`07236b3`](https://github.com/na2axl/elysiumjs/commit/07236b386c2506590d74e8753ce847c1e184b3ee)]:
39
+ - @elysiumjs/core@0.8.0
40
+
3
41
  ## 0.1.1
4
42
 
5
43
  ### Patch Changes
package/README.md CHANGED
@@ -10,26 +10,29 @@ bun add @elysiumjs/plugin-sentry
10
10
 
11
11
  ## Usage
12
12
 
13
+ Add `SentryModule` to your application:
14
+
13
15
  ```ts
14
16
  import { Application } from '@elysiumjs/core';
15
- import { plugin as sentry } from '@elysiumjs/plugin-sentry';
17
+ import { SentryModule } from '@elysiumjs/plugin-sentry';
16
18
 
17
19
  @Application.register({
18
- // Your other app options
19
- plugins: [
20
- sentry({
20
+ modules: [
21
+ SentryModule.with({
21
22
  serverName: 'my-app',
22
23
  dsn: 'https://<key>@sentry.io/<project>'
23
24
  })
24
- // Your other plugins
25
+ // Your other modules
25
26
  ]
26
27
  })
27
28
  class MyApp extends Application {}
28
29
  ```
29
30
 
31
+ The `dsn` can also come from the `SENTRY_DSN` environment variable. Boot fails when neither is set.
32
+
30
33
  ## Configuration
31
34
 
32
- This plugin forwards all options to the Sentry initialization method. You can find the full list of options [here](https://docs.sentry.io/platforms/javascript/guides/bun/configuration/options/).
35
+ The module forwards all options to the Sentry initialization method. You can find the full list of options [here](https://docs.sentry.io/platforms/javascript/guides/bun/configuration/options/).
33
36
 
34
37
  ## License
35
38
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,2 @@
1
- import type { ElysiumPlugin } from '@elysiumjs/core';
2
- import * as Sentry from '@sentry/bun';
3
- /**
4
- * Elysium plugin for Sentry integration.
5
- * @author Axel Nana <axel.nana@workbud.com>
6
- * @param options Plugin options.
7
- */
8
- export declare const plugin: (options?: Sentry.BunOptions) => ElysiumPlugin;
1
+ export { plugin } from './plugin';
2
+ export { SentryModule } from './sentry.module';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{opentelemetry as A}from"@elysiajs/opentelemetry";import{Env as w}from"@elysiumjs/core";import*as f from"@sentry/bun";import{Elysia as B}from"elysia";var R=(g)=>{return async(C)=>{let h=g?.dsn??w.get("SENTRY_DSN");if(!h)throw Error("Must provide a DSN");let z=g?.environment??w.get("SENTRY_ENVIRONMENT");return f.init({dsn:h,environment:z,tracesSampleRate:1,integrations:[f.bunServerIntegration(),f.onUnhandledRejectionIntegration({mode:"warn"}),f.onUncaughtExceptionIntegration()],...g}),new B({name:"@elysiumjs/plugin-sentry"}).decorate("Sentry",f).use(A({serviceName:g?.serverName})).onError({as:"global"},({error:k,Sentry:q})=>{q.captureException(k)}).onAfterResponse({as:"global"},function({body:q,cookie:D,params:F,request:G,response:H,route:I,server:J,store:K,headers:L,path:M,query:N}){})}};export{R as plugin};
2
+ var __legacyDecorateClassTS=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};import{opentelemetry}from"@elysiajs/opentelemetry";import{Env}from"@elysiumjs/core";import*as Sentry from"@sentry/bun";import{Elysia}from"elysia";var plugin=(options)=>async(_app)=>{let dsn=options?.dsn??Env.get("SENTRY_DSN");if(!dsn)throw Error("Must provide a DSN");let environment=options?.environment??Env.get("SENTRY_ENVIRONMENT");return Sentry.init({dsn,environment,tracesSampleRate:1,integrations:[Sentry.bunServerIntegration(),Sentry.onUnhandledRejectionIntegration({mode:"warn"}),Sentry.onUncaughtExceptionIntegration()],...options}),new Elysia({name:"@elysiumjs/plugin-sentry"}).decorate("Sentry",Sentry).use(opentelemetry({serviceName:options?.serverName})).onError({as:"global"},({error,Sentry})=>{Sentry.captureException(error)}).onAfterResponse({as:"global"},function({body,cookie,params,request,response,route,server,store,headers,path,query}){})};import{Application,Env as Env2,MissingModuleConfigError,Module}from"@elysiumjs/core";class SentryModule extends Module.configurable(){onInit(){if(!this.config.dsn&&!Env2.get("SENTRY_DSN"))throw new MissingModuleConfigError(SentryModule.name,["dsn (or SENTRY_DSN)"])}async onServe(app){app.use(await plugin(this.config)(Application.instance))}}SentryModule=__legacyDecorateClassTS([Module.register({})],SentryModule);export{SentryModule,plugin};
@@ -0,0 +1,8 @@
1
+ import type { ElysiumPlugin } from '@elysiumjs/core';
2
+ import * as Sentry from '@sentry/bun';
3
+ /**
4
+ * Elysium plugin for Sentry integration.
5
+ * @author Axel Nana <axel.nana@workbud.com>
6
+ * @param options Plugin options.
7
+ */
8
+ export declare const plugin: (options?: Sentry.BunOptions) => ElysiumPlugin;
@@ -0,0 +1,27 @@
1
+ import type * as Sentry from '@sentry/bun';
2
+ import { Module } from '@elysiumjs/core';
3
+ declare const SentryModule_base: (abstract new () => {
4
+ readonly config: Sentry.BunOptions;
5
+ onInit(): Promise<void> | void;
6
+ onDestroy(): Promise<void> | void;
7
+ onServe(_app: import("elysia").default<any>): Promise<void> | void;
8
+ }) & {
9
+ readonly config: string;
10
+ with(config: Partial<Sentry.BunOptions> | (() => Partial<Sentry.BunOptions> | Promise<Partial<Sentry.BunOptions>>)): import("@elysiumjs/core").ConfiguredModule<Sentry.BunOptions>;
11
+ resolveConfig(input?: Partial<Sentry.BunOptions> | undefined): Sentry.BunOptions;
12
+ register<TConfig_1 = any>(props?: import("@elysiumjs/core").ModuleProps<TConfig_1>): (target: import("@elysiumjs/core").ModuleClass) => void;
13
+ configurable<TConfig extends object>(options?: {
14
+ defaults?: Partial<TConfig>;
15
+ required?: (keyof TConfig)[];
16
+ }): any;
17
+ };
18
+ /**
19
+ * Configurable module that installs the Sentry plugin on the root app when serving.
20
+ * `dsn` may come from the config or from `SENTRY_DSN`; boot fails when neither is set.
21
+ * @author Axel Nana <axel.nana@workbud.com>
22
+ */
23
+ export declare class SentryModule extends SentryModule_base {
24
+ onInit(): void;
25
+ onServe(app: Parameters<Module['onServe']>[0]): Promise<void>;
26
+ }
27
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elysiumjs/plugin-sentry",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Sentry error reporting plugin for the Elysium.js framework.",
6
6
  "private": false,
@@ -16,7 +16,7 @@
16
16
  "scripts": {
17
17
  "format": "prettier --write \"./src/**/*.ts\"",
18
18
  "clean": "rimraf dist",
19
- "build:js": "bun build ./src/index.ts --outdir ./dist --target bun --packages external --root ./src --minify",
19
+ "build:js": "bun build ./src/index.ts --outdir ./dist --target bun --packages external --root ./src --minify-syntax --minify-whitespace",
20
20
  "build:ts": "tsc",
21
21
  "build": "bun run clean && bun run build:js && bun run build:ts",
22
22
  "typecheck": "tsc --noEmit",
@@ -36,13 +36,13 @@
36
36
  "module": "dist/index.js",
37
37
  "types": "dist/index.d.ts",
38
38
  "devDependencies": {
39
- "@elysiumjs/core": "0.6.1"
39
+ "@elysiumjs/core": "0.8.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@elysiumjs/core": "^0.6.1"
42
+ "@elysiumjs/core": "^0.8.0"
43
43
  },
44
44
  "dependencies": {
45
- "@elysiajs/opentelemetry": "^1.4.0",
46
- "@sentry/bun": "^10.17.0"
45
+ "@elysiajs/opentelemetry": "^1.4.11",
46
+ "@sentry/bun": "^11.9.0"
47
47
  }
48
48
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2025-present Workbud Technologies Inc. All rights reserved.
1
+ // Copyright (c) 2026-present Workbud Technologies Inc. All rights reserved.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -12,74 +12,5 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- import type { Application, ElysiumPlugin } from '@elysiumjs/core';
16
-
17
- import { opentelemetry } from '@elysiajs/opentelemetry';
18
- import { Env } from '@elysiumjs/core';
19
- import * as Sentry from '@sentry/bun';
20
- import { Elysia } from 'elysia';
21
-
22
- /**
23
- * Elysium plugin for Sentry integration.
24
- * @author Axel Nana <axel.nana@workbud.com>
25
- * @param options Plugin options.
26
- */
27
- export const plugin = (options?: Sentry.BunOptions): ElysiumPlugin => {
28
- return async (_app: Application) => {
29
- const dsn = options?.dsn ?? Env.get('SENTRY_DSN');
30
- if (!dsn) {
31
- throw new Error('Must provide a DSN');
32
- }
33
-
34
- const environment = options?.environment ?? Env.get('SENTRY_ENVIRONMENT');
35
-
36
- Sentry.init({
37
- dsn,
38
- environment,
39
- tracesSampleRate: 1.0,
40
- integrations: [
41
- Sentry.bunServerIntegration(),
42
- Sentry.onUnhandledRejectionIntegration({
43
- mode: 'warn'
44
- }),
45
- Sentry.onUncaughtExceptionIntegration()
46
- ],
47
- ...options
48
- });
49
-
50
- return (
51
- new Elysia({
52
- name: '@elysiumjs/plugin-sentry'
53
- })
54
- .decorate('Sentry', Sentry)
55
- .use(
56
- opentelemetry({
57
- serviceName: options?.serverName
58
- })
59
- )
60
- // Capture exceptions
61
- .onError({ as: 'global' }, ({ error, Sentry }) => {
62
- Sentry.captureException(error);
63
- })
64
- // Need this to inject attributes into the span
65
- // https://github.com/elysiajs/opentelemetry/issues/40
66
- .onAfterResponse(
67
- { as: 'global' },
68
- // @ts-expect-error Unused parameters
69
- function injectAttributes({
70
- body,
71
- cookie,
72
- params,
73
- request,
74
- response,
75
- route,
76
- server,
77
- store,
78
- headers,
79
- path,
80
- query
81
- }) {}
82
- )
83
- );
84
- };
85
- };
15
+ export { plugin } from './plugin';
16
+ export { SentryModule } from './sentry.module';
package/src/plugin.ts ADDED
@@ -0,0 +1,85 @@
1
+ // Copyright (c) 2025-present Workbud Technologies Inc. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import type { Application, ElysiumPlugin } from '@elysiumjs/core';
16
+
17
+ import { opentelemetry } from '@elysiajs/opentelemetry';
18
+ import { Env } from '@elysiumjs/core';
19
+ import * as Sentry from '@sentry/bun';
20
+ import { Elysia } from 'elysia';
21
+
22
+ /**
23
+ * Elysium plugin for Sentry integration.
24
+ * @author Axel Nana <axel.nana@workbud.com>
25
+ * @param options Plugin options.
26
+ */
27
+ export const plugin = (options?: Sentry.BunOptions): ElysiumPlugin => {
28
+ return async (_app: Application) => {
29
+ const dsn = options?.dsn ?? Env.get('SENTRY_DSN');
30
+ if (!dsn) {
31
+ throw new Error('Must provide a DSN');
32
+ }
33
+
34
+ const environment = options?.environment ?? Env.get('SENTRY_ENVIRONMENT');
35
+
36
+ Sentry.init({
37
+ dsn,
38
+ environment,
39
+ tracesSampleRate: 1.0,
40
+ integrations: [
41
+ Sentry.bunServerIntegration(),
42
+ Sentry.onUnhandledRejectionIntegration({
43
+ mode: 'warn'
44
+ }),
45
+ Sentry.onUncaughtExceptionIntegration()
46
+ ],
47
+ ...options
48
+ });
49
+
50
+ return (
51
+ new Elysia({
52
+ name: '@elysiumjs/plugin-sentry'
53
+ })
54
+ .decorate('Sentry', Sentry)
55
+ .use(
56
+ opentelemetry({
57
+ serviceName: options?.serverName
58
+ })
59
+ )
60
+ // Capture exceptions
61
+ .onError({ as: 'global' }, ({ error, Sentry }) => {
62
+ Sentry.captureException(error);
63
+ })
64
+ // Need this to inject attributes into the span
65
+ // https://github.com/elysiajs/opentelemetry/issues/40
66
+ .onAfterResponse(
67
+ { as: 'global' },
68
+ // @ts-expect-error Unused parameters
69
+ function injectAttributes({
70
+ body,
71
+ cookie,
72
+ params,
73
+ request,
74
+ response,
75
+ route,
76
+ server,
77
+ store,
78
+ headers,
79
+ path,
80
+ query
81
+ }) {}
82
+ )
83
+ );
84
+ };
85
+ };
@@ -0,0 +1,37 @@
1
+ // Copyright (c) 2026-present Workbud Technologies Inc. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import type * as Sentry from '@sentry/bun';
16
+
17
+ import { Application, Env, MissingModuleConfigError, Module } from '@elysiumjs/core';
18
+
19
+ import { plugin } from './plugin';
20
+
21
+ /**
22
+ * Configurable module that installs the Sentry plugin on the root app when serving.
23
+ * `dsn` may come from the config or from `SENTRY_DSN`; boot fails when neither is set.
24
+ * @author Axel Nana <axel.nana@workbud.com>
25
+ */
26
+ @Module.register({})
27
+ export class SentryModule extends Module.configurable<Sentry.BunOptions>() {
28
+ public override onInit(): void {
29
+ if (!this.config.dsn && !Env.get('SENTRY_DSN')) {
30
+ throw new MissingModuleConfigError(SentryModule.name, ['dsn (or SENTRY_DSN)']);
31
+ }
32
+ }
33
+
34
+ public override async onServe(app: Parameters<Module['onServe']>[0]): Promise<void> {
35
+ app.use(await plugin(this.config)(Application.instance));
36
+ }
37
+ }