@elysiumjs/plugin-sentry 0.2.0 → 0.3.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,41 @@
1
1
  # @elysiumjs/plugin-sentry
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#7](https://github.com/na2axl/elysiumjs/pull/7) [`e9c3d98`](https://github.com/na2axl/elysiumjs/commit/e9c3d98dd2714b69100215f7c8a80046da463148) Thanks [@na2axl](https://github.com/na2axl)! - Elysium runs on Elysia 2 (`elysia@^2.0.0-rc.1`), with TypeBox 1 (`typebox`), `@elysia/openapi` and `@elysia/opentelemetry`.
8
+
9
+ Breaking:
10
+
11
+ - `TSchema` and `Static` are re-exported from `typebox` instead of `@sinclair/typebox`; `Value` comes from `typebox/value` and `Value.Errors()` returns an array.
12
+ - `Application.onError()` receives a `ServerError` (exported from core). Elysia now names its errors in kebab case; the default error response keeps the upper snake case names (`VALIDATION`, `NOT_FOUND`, `UNKNOWN` for other errors).
13
+ - `AppHttpContext` is a plain interface with `decorator`, `store` and `derive` records (Elysia 2 renamed `resolve` to `derive`).
14
+ - Websocket controllers install Elysia's `websocket()` capability themselves.
15
+
16
+ A module or controller `onRequest` middleware that answers now stops the request: Elysia 2 ignores values returned from a transform hook, so the response is thrown as a status and sent as is, without going through `onError`.
17
+
18
+ `mnemosyne` builds date columns with `t.Codec` (TypeBox 1 dropped `Transform`). `argus` traces every route of the app it is installed on and ends each span once, keeping the error status when the request failed.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`6bc48fe`](https://github.com/na2axl/elysiumjs/commit/6bc48febd51f7090c582e73f349eaeff7261241c), [`e9c3d98`](https://github.com/na2axl/elysiumjs/commit/e9c3d98dd2714b69100215f7c8a80046da463148), [`557a3ca`](https://github.com/na2axl/elysiumjs/commit/557a3cab7af8053a8bab9944e492e5022d91aa82), [`ccc3f5b`](https://github.com/na2axl/elysiumjs/commit/ccc3f5bb904d1bf52d8c72ebf7ea8d10f617a8c4), [`6789879`](https://github.com/na2axl/elysiumjs/commit/678987976ecfd46b534b65276e0de3f448977562), [`87299fd`](https://github.com/na2axl/elysiumjs/commit/87299fd9da82d1a408ced1891c0c3d42991444e5), [`bee66bd`](https://github.com/na2axl/elysiumjs/commit/bee66bdc874b8f23fea356f7d3adf7555a48ca64), [`0057b67`](https://github.com/na2axl/elysiumjs/commit/0057b67df0e3abecab8a9accff6b55a6a64c21df), [`632d77b`](https://github.com/na2axl/elysiumjs/commit/632d77b561fc43ade605fb69b06ac1b9b9a2ffc4), [`1ea417e`](https://github.com/na2axl/elysiumjs/commit/1ea417e3583250bc2f975d795f398b7ff736115d), [`0956186`](https://github.com/na2axl/elysiumjs/commit/0956186db0ca5a83c0a6636aeb2a4c81a0033de4), [`fbcc7da`](https://github.com/na2axl/elysiumjs/commit/fbcc7dad127db29da42e7a4a5c2124966731cd88), [`ac96e55`](https://github.com/na2axl/elysiumjs/commit/ac96e55874b0ffe350b287c4278cd85afecb7576), [`98a16aa`](https://github.com/na2axl/elysiumjs/commit/98a16aae889d46f7a9fb5573188f4cbe3629dd3b)]:
23
+ - @elysiumjs/core@0.11.0
24
+
25
+ ## 0.2.2
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [[`68a0cdd`](https://github.com/na2axl/elysiumjs/commit/68a0cdd8b2e4a003d6e0af2d78985623cae40428), [`2c49acd`](https://github.com/na2axl/elysiumjs/commit/2c49acd3b552aa43765d70339fa216961499e1b5), [`76ba0ff`](https://github.com/na2axl/elysiumjs/commit/76ba0ff18f3c196cebc2189426328f67cb699f46), [`4ebf029`](https://github.com/na2axl/elysiumjs/commit/4ebf029611e6d753a4f1bfdbe247a75d954d9ded), [`bacce71`](https://github.com/na2axl/elysiumjs/commit/bacce7146f667a1a46bf474dc0344fb0111ae12a)]:
30
+ - @elysiumjs/core@0.10.0
31
+
32
+ ## 0.2.1
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [[`5fef4a7`](https://github.com/na2axl/elysiumjs/commit/5fef4a7199f502fc4fe035299e7670739459a108)]:
37
+ - @elysiumjs/core@0.9.0
38
+
3
39
  ## 0.2.0
4
40
 
5
41
  ### Minor Changes
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
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};
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"@elysia/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("global",({error,Sentry})=>{Sentry.captureException(error)}).onAfterResponse("global",function({body,cookie,params,request,responseValue,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};
@@ -4,7 +4,7 @@ declare const SentryModule_base: (abstract new () => {
4
4
  readonly config: Sentry.BunOptions;
5
5
  onInit(): Promise<void> | void;
6
6
  onDestroy(): Promise<void> | void;
7
- onServe(_app: import("elysia").default<any>): Promise<void> | void;
7
+ onServe(_app: import("elysia").Elysia<any>): Promise<void> | void;
8
8
  }) & {
9
9
  readonly config: string;
10
10
  with(config: Partial<Sentry.BunOptions> | (() => Partial<Sentry.BunOptions> | Promise<Partial<Sentry.BunOptions>>)): import("@elysiumjs/core").ConfiguredModule<Sentry.BunOptions>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elysiumjs/plugin-sentry",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Sentry error reporting plugin for the Elysium.js framework.",
6
6
  "private": false,
@@ -10,9 +10,13 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/workbud/elysium"
13
+ "url": "git+https://github.com/na2axl/elysiumjs.git",
14
+ "directory": "@elysiumjs/plugin-sentry"
15
+ },
16
+ "homepage": "https://github.com/na2axl/elysiumjs/tree/main/@elysiumjs/plugin-sentry#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/na2axl/elysiumjs/issues"
14
19
  },
15
- "homepage": "https://github.com/workbud/elysium",
16
20
  "scripts": {
17
21
  "format": "prettier --write \"./src/**/*.ts\"",
18
22
  "clean": "rimraf dist",
@@ -20,7 +24,9 @@
20
24
  "build:ts": "tsc",
21
25
  "build": "bun run clean && bun run build:js && bun run build:ts",
22
26
  "typecheck": "tsc --noEmit",
23
- "prepublishOnly": "bun run build"
27
+ "prepublishOnly": "bun run build",
28
+ "test": "bun test",
29
+ "test:coverage": "bun test --coverage"
24
30
  },
25
31
  "keywords": [
26
32
  "elysium",
@@ -35,14 +41,18 @@
35
41
  "type": "module",
36
42
  "module": "dist/index.js",
37
43
  "types": "dist/index.d.ts",
44
+ "files": [
45
+ "dist",
46
+ "CHANGELOG.md"
47
+ ],
38
48
  "devDependencies": {
39
- "@elysiumjs/core": "0.8.0"
49
+ "@elysiumjs/core": "0.11.0"
40
50
  },
41
51
  "peerDependencies": {
42
- "@elysiumjs/core": "^0.8.0"
52
+ "@elysiumjs/core": "^0.11.0"
43
53
  },
44
54
  "dependencies": {
45
- "@elysiajs/opentelemetry": "^1.4.11",
55
+ "@elysia/opentelemetry": "^2.0.0-rc.0",
46
56
  "@sentry/bun": "^11.9.0"
47
57
  }
48
58
  }
package/src/index.ts DELETED
@@ -1,16 +0,0 @@
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
- export { plugin } from './plugin';
16
- export { SentryModule } from './sentry.module';
package/src/plugin.ts DELETED
@@ -1,85 +0,0 @@
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
- };
@@ -1,37 +0,0 @@
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
- }
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "declaration": true,
6
- "emitDeclarationOnly": true,
7
- "declarationMap": false,
8
- "declarationDir": "dist",
9
- "rootDir": "src"
10
- },
11
- "include": ["src"]
12
- }