@picked/sentry 0.0.1-dev.1764619864065 → 0.0.1-dev.1765390703636

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,25 @@
1
+ # Sentry Plugin
2
+
3
+ This plugin is responsible for listening for the Picked Client `eventBus` and interacting with a Sentry instance by adding tags and triggering `captureMessage` and `captureException`.
4
+
5
+ This are the events listened by the Plugin:
6
+
7
+ - `exception`: When an `exception` event is added to the `eventBus` the plugin will automatically check the `level` and based on that call `captureException` when the `level` is `error` and `captureMessage` when the `level` is `info`.
8
+ - `session`: When the `session` event happens, the Plugin will add the tag `pickedId` to the Sentry global scope with the session id as value. Example: `pickedId: 000000000`
9
+ - `feature_decide`: When the `feature_decide` event happens, the Plugin will add the tag `picked.feature.[EVENT_NAME]` to the Sentry global scope with the bucket as value. Example: `picked.feature.my_feature: true`
10
+ - `user_decide`: When the `user_decide` event happens, the Plugin will add the tag `picked.is_user` with the `user_decide` value. Example: `picked.is_user: true`
11
+
12
+ ## 🚀 Quick Start
13
+
14
+ Here's a basic example of how to use the `Sentry` Plugin:
15
+
16
+ ```typescript
17
+ // app.ts file
18
+ import { getClient } from '@sentry/svelte'
19
+ import { sentryPlugin } from '@picked/sentry'
20
+
21
+ const client = createClient({
22
+ // ... values
23
+ plugin: [sentryPlugin(getClient())], // Usually the array of plugins are defined earlier, so you can add the sentry plugin there, the only requirement is to pass the getClient()
24
+ })
25
+ ```
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@sentry/core"),c=require("@picked/client"),u=({client:r,globalScope:i})=>({name:"sentry-plugin",setup:s=>{if(c.supportsWindow())try{s.eventBus.watch(e=>{if(e.type==="exception"){const t=new a.Scope;t.setTag("picked",!0),e.level==="info"&&r.captureMessage(typeof e.data=="string"?e.data:JSON.stringify(e.data),"info",void 0,t),r.captureException(e.data,void 0,t)}if(e.type==="session"&&i.setTag("picked.id",e.id),e.type==="feature_decide"){const t=`picked.feature.${e.feature.id}`;i.setTag(t,e.feature.bucket)}e.type==="user_decide"&&i.setTag("picked.is_user",e.value)})}catch{}}});exports.sentryPlugin=u;
@@ -0,0 +1,33 @@
1
+ import { Scope as s } from "@sentry/core";
2
+ import { supportsWindow as p } from "@picked/client";
3
+ const c = ({
4
+ client: a,
5
+ globalScope: e
6
+ }) => ({
7
+ name: "sentry-plugin",
8
+ setup: (r) => {
9
+ if (p())
10
+ try {
11
+ r.eventBus.watch((i) => {
12
+ if (i.type === "exception") {
13
+ const t = new s();
14
+ t.setTag("picked", !0), i.level === "info" && a.captureMessage(
15
+ typeof i.data == "string" ? i.data : JSON.stringify(i.data),
16
+ "info",
17
+ void 0,
18
+ t
19
+ ), a.captureException(i.data, void 0, t);
20
+ }
21
+ if (i.type === "session" && e.setTag("picked.id", i.id), i.type === "feature_decide") {
22
+ const t = `picked.feature.${i.feature.id}`;
23
+ e.setTag(t, i.feature.bucket);
24
+ }
25
+ i.type === "user_decide" && e.setTag("picked.is_user", i.value);
26
+ });
27
+ } catch {
28
+ }
29
+ }
30
+ });
31
+ export {
32
+ c as sentryPlugin
33
+ };
@@ -0,0 +1,7 @@
1
+ import { Client, Scope } from '@sentry/core';
2
+ import { Plugin } from '@picked/client';
3
+ export declare const sentryPlugin: ({ client, globalScope, }: {
4
+ client: Client;
5
+ globalScope: Scope;
6
+ }) => Plugin;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5D,eAAO,MAAM,YAAY,GAAI,0BAG1B;IACD,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,KAAK,CAAA;CACnB,KAAG,MA+DH,CAAA"}
package/package.json CHANGED
@@ -1,42 +1,30 @@
1
1
  {
2
2
  "name": "@picked/sentry",
3
- "description": "Sentry Plugin",
4
- "version": "0.0.1-dev.1764619864065",
5
- "dependencies": {
6
- "@sentry/svelte": "^10.27.0",
7
- "@sentry/vercel-edge": "^10.27.0",
8
- "@sentry/vite-plugin": "^2.23.0"
9
- },
3
+ "description": "Sentry plugin",
4
+ "version": "0.0.1-dev.1765390703636",
5
+ "dependencies": {},
10
6
  "devDependencies": {
7
+ "@picked/client": "workspace:*",
8
+ "@picked/svelte": "workspace:*",
11
9
  "@repo/eslint-config": "workspace:*",
12
10
  "@repo/typescript-config": "workspace:*",
13
11
  "@rollup/plugin-replace": "^6.0.2",
12
+ "@sentry/core": "^10.5.0",
14
13
  "@types/jsdom": "^21.1.7",
15
14
  "@types/node": "^22",
16
15
  "@vitest/coverage-v8": "^3.2.4",
17
16
  "tsup": "^8.5.0",
17
+ "tsx": "^4.20.3",
18
18
  "vite": "^6.4.1",
19
19
  "vite-plugin-dts": "^4.5.4",
20
20
  "vitest": "^3.2.4"
21
21
  },
22
22
  "exports": {
23
- "./edge": {
24
- "types": "./dist/types/edge/index.d.ts",
25
- "import": "./dist/esm/edge/index.js",
26
- "require": "./dist/cjs/edge/index.js",
27
- "default": "./dist/esm/edge/index.js"
28
- },
29
- "./svelte": {
30
- "types": "./dist/types/svelte/index.d.ts",
31
- "import": "./dist/esm/svelte/index.js",
32
- "require": "./dist/cjs/svelte/index.js",
33
- "default": "./dist/esm/svelte/index.js"
34
- },
35
- "./vite": {
36
- "types": "./dist/types/vite/index.d.ts",
37
- "import": "./dist/esm/vite/index.js",
38
- "require": "./dist/cjs/vite/index.js",
39
- "default": "./dist/esm/vite/index.js"
23
+ ".": {
24
+ "types": "./dist/types/index.d.ts",
25
+ "import": "./dist/esm/index.js",
26
+ "require": "./dist/cjs/index.js",
27
+ "default": "./dist/esm/index.js"
40
28
  }
41
29
  },
42
30
  "files": [
@@ -44,7 +32,9 @@
44
32
  ],
45
33
  "main": "./dist/cjs/index.js",
46
34
  "module": "./dist/esm/index.js",
47
- "peerDependencies": {},
35
+ "peerDependencies": {
36
+ "@picked/client": "0.0.1-dev.1765390703636"
37
+ },
48
38
  "private": false,
49
39
  "scripts": {
50
40
  "build": "vite build",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@sentry/vercel-edge");function o(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const c=o(i);function u({dsn:t,environment:e,release:r}){!t||!e||!r||c.init({dsn:t,environment:e,release:r,tracesSampleRate:e==="production"?.1:1})}exports.Sentry=c;exports.initSentry=u;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@sentry/svelte");let f=!1;function k({dsn:r,environment:a,release:i,assetsOrigin:t,filterKeys:S=[]}){f||!r||!a||!i||!t||(s.init({dsn:r,environment:a,release:i,debug:a==="development",tracesSampleRate:.1,sendDefaultPii:!1,allowUrls:[t],attachStacktrace:!0,tracePropagationTargets:[t],integrations:[s.thirdPartyErrorFilterIntegration({filterKeys:[...S],behaviour:"drop-error-if-contains-third-party-frames"})],tracesSampler:e=>{var u,l;const n=(u=e.location)==null?void 0:u.href;if(n&&n.startsWith(t))return 1;const p=(l=e.transactionContext)==null?void 0:l.name;return typeof p=="string"&&p.startsWith(t)?1:0},beforeSend(e){var u,l,d,h,y;const n=((u=e.exception)==null?void 0:u.values)??[],p=((d=(l=n==null?void 0:n[0])==null?void 0:l.stacktrace)==null?void 0:d.frames)??[];if(p.length>0){if(!p.some(o=>{const g=o.filename||"",b=o.abs_path||"";return o.in_app===!0||g.startsWith(t)||b.startsWith(t)}))return null}else{const c=(h=e.request)==null?void 0:h.url,o=e.transaction;if(!(typeof c=="string"&&c.startsWith(t)||typeof o=="string"&&o.startsWith(t)))return null}try{const c=(y=globalThis.window.Picked.session)==null?void 0:y.id;c&&(e.tags={...e.tags,pickedId:c})}catch{}return e}}),f=!0)}function m(r){!f||!r||s.withScope(a=>{var i;try{const t=(i=globalThis.window.Picked.session)==null?void 0:i.id;t&&a.setTag("pickedId",t)}catch{}s.captureException(r)})}function w(r){!f||!r||s.withScope(a=>{var i;try{const t=(i=globalThis.window.Picked.session)==null?void 0:i.id;t&&a.setTag("pickedId",t)}catch{}s.captureMessage(r)})}exports.captureException=m;exports.captureMessage=w;exports.initSentry=k;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@sentry/vite-plugin");Object.defineProperty(exports,"sentryVitePlugin",{enumerable:!0,get:()=>e.sentryVitePlugin});
@@ -1,17 +0,0 @@
1
- import * as o from "@sentry/vercel-edge";
2
- function p({
3
- dsn: r,
4
- environment: t,
5
- release: i
6
- }) {
7
- !r || !t || !i || o.init({
8
- dsn: r,
9
- environment: t,
10
- release: i,
11
- tracesSampleRate: t === "production" ? 0.1 : 1
12
- });
13
- }
14
- export {
15
- o as Sentry,
16
- p as initSentry
17
- };
@@ -1,86 +0,0 @@
1
- import { init as b, thirdPartyErrorFilterIntegration as w, withScope as m, captureException as I, captureMessage as P } from "@sentry/svelte";
2
- let u = !1;
3
- function W({
4
- dsn: e,
5
- environment: a,
6
- release: i,
7
- assetsOrigin: t,
8
- filterKeys: y = []
9
- }) {
10
- u || !e || !a || !i || !t || (b({
11
- dsn: e,
12
- environment: a,
13
- release: i,
14
- debug: a === "development",
15
- tracesSampleRate: 0.1,
16
- sendDefaultPii: !1,
17
- allowUrls: [t],
18
- attachStacktrace: !0,
19
- tracePropagationTargets: [t],
20
- integrations: [
21
- w({
22
- filterKeys: [...y],
23
- behaviour: "drop-error-if-contains-third-party-frames"
24
- })
25
- ],
26
- tracesSampler: (r) => {
27
- var p, f;
28
- const n = (p = r.location) == null ? void 0 : p.href;
29
- if (n && n.startsWith(t))
30
- return 1;
31
- const s = (f = r.transactionContext) == null ? void 0 : f.name;
32
- return typeof s == "string" && s.startsWith(t) ? 1 : 0;
33
- },
34
- beforeSend(r) {
35
- var p, f, l, d, h;
36
- const n = ((p = r.exception) == null ? void 0 : p.values) ?? [], s = ((l = (f = n == null ? void 0 : n[0]) == null ? void 0 : f.stacktrace) == null ? void 0 : l.frames) ?? [];
37
- if (s.length > 0) {
38
- if (!s.some((o) => {
39
- const g = o.filename || "", k = o.abs_path || "";
40
- return o.in_app === !0 || g.startsWith(t) || k.startsWith(t);
41
- }))
42
- return null;
43
- } else {
44
- const c = (d = r.request) == null ? void 0 : d.url, o = r.transaction;
45
- if (!(typeof c == "string" && c.startsWith(t) || typeof o == "string" && o.startsWith(t)))
46
- return null;
47
- }
48
- try {
49
- const c = (h = globalThis.window.Picked.session) == null ? void 0 : h.id;
50
- c && (r.tags = {
51
- ...r.tags,
52
- pickedId: c
53
- });
54
- } catch {
55
- }
56
- return r;
57
- }
58
- }), u = !0);
59
- }
60
- function F(e) {
61
- !u || !e || m((a) => {
62
- var i;
63
- try {
64
- const t = (i = globalThis.window.Picked.session) == null ? void 0 : i.id;
65
- t && a.setTag("pickedId", t);
66
- } catch {
67
- }
68
- I(e);
69
- });
70
- }
71
- function x(e) {
72
- !u || !e || m((a) => {
73
- var i;
74
- try {
75
- const t = (i = globalThis.window.Picked.session) == null ? void 0 : i.id;
76
- t && a.setTag("pickedId", t);
77
- } catch {
78
- }
79
- P(e);
80
- });
81
- }
82
- export {
83
- F as captureException,
84
- x as captureMessage,
85
- W as initSentry
86
- };
@@ -1,4 +0,0 @@
1
- import { sentryVitePlugin as t } from "@sentry/vite-plugin";
2
- export {
3
- t as sentryVitePlugin
4
- };
@@ -1,7 +0,0 @@
1
- export declare function initSentry({ dsn, environment, release, }: {
2
- dsn?: string;
3
- environment?: string;
4
- release?: string;
5
- }): void;
6
- export * as Sentry from '@sentry/vercel-edge';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/edge/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,WAAW,EACX,OAAO,GACR,EAAE;IACD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,IAAI,CAWP;AAED,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAA"}
@@ -1,19 +0,0 @@
1
- declare global {
2
- interface Window {
3
- Picked: {
4
- session?: {
5
- id: string;
6
- };
7
- };
8
- }
9
- }
10
- export declare function initSentry({ dsn, environment, release, assetsOrigin, filterKeys, }: {
11
- dsn?: string;
12
- environment?: string;
13
- release?: string;
14
- assetsOrigin?: string;
15
- filterKeys?: string[];
16
- }): void;
17
- export declare function captureException(error: unknown): void;
18
- export declare function captureMessage(message: string): void;
19
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/svelte/index.ts"],"names":[],"mappings":"AASA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE;YACN,OAAO,CAAC,EAAE;gBACR,EAAE,EAAE,MAAM,CAAA;aACX,CAAA;SACF,CAAA;KACF;CACF;AAID,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,WAAW,EACX,OAAO,EACP,YAAY,EACZ,UAAe,GAChB,EAAE;IACD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB,GAAG,IAAI,CAmFP;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAiBrD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAiBpD"}
@@ -1,2 +0,0 @@
1
- export { sentryVitePlugin } from '@sentry/vite-plugin';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA"}