@ask-ell/sentry 0.0.1

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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # sentry
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build sentry` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test sentry` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@ask-ell/sentry",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
8
+ "peerDependencies": {
9
+ "@sentry/core": "^10.39.0"
10
+ },
11
+ "module": "./src/index.js"
12
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './sentry.configuration.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/sentry/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './sentry.configuration.js';
@@ -0,0 +1,20 @@
1
+ import type { ILogger, MaybeUndefined } from "@ask-ell/core";
2
+ import type { Client, Options } from "@sentry/core";
3
+ type SentryClientFactory = (options: Options) => MaybeUndefined<Client>;
4
+ export type SentryConfigurationProps = {
5
+ publicKey: string;
6
+ host: string;
7
+ projectId: string;
8
+ environment?: MaybeUndefined<string>;
9
+ logger: ILogger;
10
+ init: SentryClientFactory;
11
+ };
12
+ export declare class SentryConfiguration {
13
+ private props;
14
+ private inited;
15
+ private logger;
16
+ constructor(props: SentryConfigurationProps);
17
+ init(): void;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=sentry.configuration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.configuration.d.ts","sourceRoot":"","sources":["../../../../packages/sentry/src/sentry.configuration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGnD,KAAK,mBAAmB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,cAAc,CAAC,MAAM,CAAC,CAAC;AAExE,MAAM,MAAM,wBAAwB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF,qBAAa,mBAAmB;IAIhB,OAAO,CAAC,KAAK;IAHzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAU;gBAEJ,KAAK,EAAE,wBAAwB;IAInD,IAAI,IAAI,IAAI;CAiBf"}
@@ -0,0 +1,23 @@
1
+ export class SentryConfiguration {
2
+ props;
3
+ inited = false;
4
+ logger;
5
+ constructor(props) {
6
+ this.props = props;
7
+ this.logger = this.props.logger;
8
+ }
9
+ init() {
10
+ if (this.inited) {
11
+ return this.logger.info("Sentry already inited. Step skipped");
12
+ }
13
+ const { publicKey, host, projectId, environment, init } = this.props;
14
+ const dsn = `${publicKey}@${host}/${projectId}`;
15
+ init({
16
+ dsn,
17
+ sendDefaultPii: true,
18
+ environment: environment ?? "production"
19
+ });
20
+ this.logger.info(`Sentry inited for environment "${environment}"`);
21
+ this.inited = true;
22
+ }
23
+ }