@lark.js/sentry 0.0.6 → 0.0.7

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 CHANGED
@@ -24,11 +24,7 @@ npm install vue
24
24
 
25
25
  ```ts
26
26
  import { init, destroy, isInitialized, pluginEnable } from "@lark.js/sentry";
27
- import {
28
- PerformancePlugin,
29
- ScreenRecordPlugin,
30
- ExposurePlugin,
31
- } from "@lark.js/sentry/plugins";
27
+ import { PerformancePlugin, ScreenRecordPlugin, ExposurePlugin } from "@lark.js/sentry/plugins";
32
28
  import { ReactErrorBoundary } from "@lark.js/sentry/react";
33
29
  import { vuePlugin } from "@lark.js/sentry/vue";
34
30
  ```
@@ -39,11 +35,7 @@ Each public export provides ESM, CJS, and TypeScript declaration files.
39
35
 
40
36
  ```ts
41
37
  import { init, pluginEnable } from "@lark.js/sentry";
42
- import {
43
- PerformancePlugin,
44
- ScreenRecordPlugin,
45
- ExposurePlugin,
46
- } from "@lark.js/sentry/plugins";
38
+ import { PerformancePlugin, ScreenRecordPlugin, ExposurePlugin } from "@lark.js/sentry/plugins";
47
39
 
48
40
  init({
49
41
  dsn: "/api/log",
@@ -439,11 +431,7 @@ await sendLocal();
439
431
  Register hooks after initialization or provide equivalent hooks in `init` options.
440
432
 
441
433
  ```ts
442
- import {
443
- afterSendData,
444
- beforePushEventList,
445
- beforeSendData,
446
- } from "@lark.js/sentry";
434
+ import { afterSendData, beforePushEventList, beforeSendData } from "@lark.js/sentry";
447
435
 
448
436
  beforeSendData((data) => {
449
437
  if (data.type === "Click") {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="0.0.6",r={version:e};exports.default=r,exports.version=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="0.0.7",r={version:e};exports.default=r,exports.version=e;
@@ -1 +1 @@
1
- var a="0.0.6",e={version:a};export{e as default,a as version};
1
+ var a="0.0.7",e={version:a};export{e as default,a as version};
package/dist/vite.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node:buffer"),t=require("node:path"),n=require("node:fs");require("./constants/index.cjs"),require("./types/enums.cjs");var r=require("./utils/sentry.cjs"),s=require("./utils/logger.cjs"),i=require("zod");function o(t,n){return"string"==typeof n?t+n:e.Buffer.isBuffer(n)?t+n.toString("utf8"):n instanceof Uint8Array?t+e.Buffer.from(n).toString("utf8"):t}function c(e){return i.z.json().parse(e)}const u=(e,t)=>n=>{n.middlewares.use((n,r,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=o(e,t)}),n.on("end",()=>{if(e)try{const n=c(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}r.setHeader("Content-Type","application/json"),r.statusCode=200,r.end(JSON.stringify({code:0,message:"success"}))})}else s()})},a=(e,t)=>n=>{n.middlewares.use((n,r,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=o(e,t)}),n.on("end",()=>{if(e)try{const n=c(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}r.setHeader("Content-Type","application/json"),r.statusCode=200,r.end(JSON.stringify({code:0,message:"success"}))})}else s()})};function l({dsn:e}){const s=t.join(process.cwd(),"logs");n.existsSync(s)||n.mkdirSync(s,{recursive:!0});const i=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),o=t.join(s,`sentry_${i}.log`),c=n.createWriteStream(o,{flags:"a"});return{name:"vite-plugin-sentry",configureServer:a(e||r.default.options.dsn||"/sentry",c),closeBundle(){c&&c.close()}}}exports.default=l,exports.sentryPlugin=l,exports.sentryPlugin7=function({dsn:e}={}){const i=t.join(process.cwd(),"logs");n.existsSync(i)||n.mkdirSync(i,{recursive:!0});const o=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),c=t.join(i,`sentry_${o}.log`),a=n.createWriteStream(c,{flags:"a"});return s.sentryLogger.info("@lark.js/sentry",`Sentry mock plugin initialized, logs will be written to ${c}`),{name:"vite-plugin-sentry",configureServer:u(e||r.default.options.dsn||"/sentry",a),closeBundle(){a&&a.close()}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node:buffer"),t=require("node:path"),n=require("node:fs");require("./constants/index.cjs"),require("./types/enums.cjs");var r=require("./utils/sentry.cjs"),s=require("./utils/logger.cjs"),i=require("zod");function o(t,n){return"string"==typeof n?t+n:e.Buffer.isBuffer(n)?t+n.toString("utf8"):n instanceof Uint8Array?t+e.Buffer.from(n).toString("utf8"):t}function l(e){return i.z.json().parse(e)}const u=(e,t)=>n=>{n.middlewares.use((n,r,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=o(e,t)}),n.on("end",()=>{if(e)try{const n=l(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}r.setHeader("Content-Type","application/json"),r.statusCode=200,r.end(JSON.stringify({code:0,message:"success"}))})}else s()})},c=(e,t)=>n=>{n.middlewares.use((n,r,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=o(e,t)}),n.on("end",()=>{if(e)try{const n=l(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}r.setHeader("Content-Type","application/json"),r.statusCode=200,r.end(JSON.stringify({code:0,message:"success"}))})}else s()})};function a(){const e=t.join(process.cwd(),"logs");n.existsSync(e)||n.mkdirSync(e,{recursive:!0});const r=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),s=t.join(e,`sentry_${r}.log`);return{fileStream:n.createWriteStream(s,{flags:"a"}),logFile:s}}function f({dsn:e}){const{fileStream:t,logFile:n}=a();return s.sentryLogger.info("@lark.js/sentry",`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:c(e||r.default.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}exports.default=f,exports.sentryPlugin=f,exports.sentryPlugin7=function({dsn:e}={}){const{fileStream:t,logFile:n}=a();return s.sentryLogger.info("@lark.js/sentry",`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:u(e||r.default.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}};
package/dist/vite.js CHANGED
@@ -1 +1 @@
1
- import{Buffer as e}from"node:buffer";import{join as t}from"node:path";import{existsSync as n,mkdirSync as s,createWriteStream as o}from"node:fs";import"./constants/index.js";import"./types/enums.js";import r from"./utils/sentry.js";import{sentryLogger as i}from"./utils/logger.js";import{z as c}from"zod";function l(t,n){return"string"==typeof n?t+n:e.isBuffer(n)?t+n.toString("utf8"):n instanceof Uint8Array?t+e.from(n).toString("utf8"):t}function a(e){return c.json().parse(e)}const f=(e,t)=>n=>{n.middlewares.use((n,s,o)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=l(e,t)}),n.on("end",()=>{if(e)try{const n=a(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else o()})},d=(e,t)=>n=>{n.middlewares.use((n,s,o)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=l(e,t)}),n.on("end",()=>{if(e)try{const n=a(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else o()})};function u({dsn:e}={}){const c=t(process.cwd(),"logs");n(c)||s(c,{recursive:!0});const l=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),a=t(c,`sentry_${l}.log`),d=o(a,{flags:"a"});return i.info("@lark.js/sentry",`Sentry mock plugin initialized, logs will be written to ${a}`),{name:"vite-plugin-sentry",configureServer:f(e||r.options.dsn||"/sentry",d),closeBundle(){d&&d.close()}}}function p({dsn:e}){const i=t(process.cwd(),"logs");n(i)||s(i,{recursive:!0});const c=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),l=t(i,`sentry_${c}.log`),a=o(l,{flags:"a"});return{name:"vite-plugin-sentry",configureServer:d(e||r.options.dsn||"/sentry",a),closeBundle(){a&&a.close()}}}export{p as default,p as sentryPlugin,u as sentryPlugin7};
1
+ import{Buffer as e}from"node:buffer";import{join as t}from"node:path";import{existsSync as n,mkdirSync as o,createWriteStream as s}from"node:fs";import"./constants/index.js";import"./types/enums.js";import r from"./utils/sentry.js";import{sentryLogger as i}from"./utils/logger.js";import{z as l}from"zod";function c(t,n){return"string"==typeof n?t+n:e.isBuffer(n)?t+n.toString("utf8"):n instanceof Uint8Array?t+e.from(n).toString("utf8"):t}function a(e){return l.json().parse(e)}const f=(e,t)=>n=>{n.middlewares.use((n,o,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=c(e,t)}),n.on("end",()=>{if(e)try{const n=a(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}o.setHeader("Content-Type","application/json"),o.statusCode=200,o.end(JSON.stringify({code:0,message:"success"}))})}else s()})},u=(e,t)=>n=>{n.middlewares.use((n,o,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=c(e,t)}),n.on("end",()=>{if(e)try{const n=a(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}o.setHeader("Content-Type","application/json"),o.statusCode=200,o.end(JSON.stringify({code:0,message:"success"}))})}else s()})};function d(){const e=t(process.cwd(),"logs");n(e)||o(e,{recursive:!0});const r=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),i=t(e,`sentry_${r}.log`);return{fileStream:s(i,{flags:"a"}),logFile:i}}function m({dsn:e}={}){const{fileStream:t,logFile:n}=d();return i.info("@lark.js/sentry",`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:f(e||r.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}function g({dsn:e}){const{fileStream:t,logFile:n}=d();return i.info("@lark.js/sentry",`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:u(e||r.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}export{g as default,g as sentryPlugin,m as sentryPlugin7};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node:buffer"),t=require("node:path"),r=require("node:fs"),n=require("zod");require("./constants/index.cjs"),require("./types/enums.cjs");var s=require("./utils/sentry.cjs"),i=require("./utils/logger.cjs");function o(t,r){return(s,i,o)=>{if(s.url===t&&"POST"===s.method){let t="";s.on("data",r=>{t=function(t,r){return"string"==typeof r?t+r:e.Buffer.isBuffer(r)?t+r.toString("utf8"):r instanceof Uint8Array?t+e.Buffer.from(r).toString("utf8"):t}(t,r)}),s.on("end",()=>{if(t)try{const e=function(e){return n.z.json().parse(e)}(t);r.write(JSON.stringify(e)+"\n")}catch{r.write(t+"\n")}i.setHeader("Content-Type","application/json"),i.statusCode=200,i.end(JSON.stringify({code:0,message:"success"}))})}else o()}}function u(){const e=t.join(process.cwd(),"logs");r.existsSync(e)||r.mkdirSync(e,{recursive:!0});const n=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),s=t.join(e,`sentry_${n}.log`);return{fileStream:r.createWriteStream(s,{flags:"a"}),logFile:s}}class l{dsn;constructor(e={}){this.dsn=e.dsn}apply(e){const t=e.options.devServer,{fileStream:r,logFile:n}=u(),l=o(this.dsn||s.default.options.dsn||"/sentry",r);i.sentryLogger.info("@lark.js/sentry",`Sentry mock plugin initialized, logs will be written to ${n}`);const c=t.setupMiddlewares;t.setupMiddlewares=(e,t)=>{const r=c?c(e,t):e,n={name:"sentry-mock",middleware:l};return r.unshift(n),r},e.hooks.shutdown.tap("SentryWebpackPlugin",()=>{r&&!r.destroyed&&r.close()})}}function c(e={}){return new l(e)}exports.SentryWebpackPlugin=l,exports.default=c,exports.sentryMiddleware=function(e={}){const{fileStream:t,logFile:r}=u();return i.sentryLogger.info("@lark.js/sentry",`Sentry mock middleware initialized, logs will be written to ${r}`),o(e.dsn||s.default.options.dsn||"/sentry",t)},exports.sentryPlugin=c;
@@ -0,0 +1,55 @@
1
+ import { IncomingMessage, ServerResponse } from 'node:http';
2
+ import { WebpackPluginInstance, Compiler } from 'webpack';
3
+ import DevServer from 'webpack-dev-server';
4
+
5
+ type SentryDevMiddleware = (req: IncomingMessage, res: ServerResponse, next: DevServer.NextFunction) => void;
6
+ interface ISentryWebpackPluginOptions {
7
+ dsn?: string;
8
+ }
9
+ /**
10
+ * Connect/express-style middleware that mocks the sentry report endpoint
11
+ * during webpack-dev-server development. Mount it manually inside the
12
+ * `setupMiddlewares` option of webpack-dev-server.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { sentryMiddleware } from "@lark.js/sentry/webpack";
17
+ *
18
+ * export default {
19
+ * devServer: {
20
+ * setupMiddlewares(middlewares) {
21
+ * middlewares.unshift({
22
+ * name: "sentry-mock",
23
+ * middleware: sentryMiddleware({ dsn: "/api/log" }),
24
+ * });
25
+ * return middlewares;
26
+ * },
27
+ * },
28
+ * };
29
+ * ```
30
+ */
31
+ declare function sentryMiddleware(options?: ISentryWebpackPluginOptions): SentryDevMiddleware;
32
+ /**
33
+ * Webpack plugin that automatically wires the sentry log-collection middleware
34
+ * into webpack-dev-server. It only takes effect when
35
+ * `compiler.options.devServer` exists, so production builds remain untouched.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { sentryPlugin } from "@lark.js/sentry/webpack";
40
+ *
41
+ * export default {
42
+ * plugins: [sentryPlugin({ dsn: "/api/log" })],
43
+ * devServer: { ... },
44
+ * };
45
+ * ```
46
+ */
47
+ declare class SentryWebpackPlugin implements WebpackPluginInstance {
48
+ private readonly dsn;
49
+ constructor(options?: ISentryWebpackPluginOptions);
50
+ apply(compiler: Compiler): void;
51
+ }
52
+ declare function sentryPlugin(options?: ISentryWebpackPluginOptions): SentryWebpackPlugin;
53
+
54
+ export { SentryWebpackPlugin, sentryPlugin as default, sentryMiddleware, sentryPlugin };
55
+ export type { ISentryWebpackPluginOptions, SentryDevMiddleware };
@@ -0,0 +1 @@
1
+ import{Buffer as t}from"node:buffer";import{join as e}from"node:path";import{existsSync as n,mkdirSync as o,createWriteStream as r}from"node:fs";import{z as s}from"zod";import"./constants/index.js";import"./types/enums.js";import i from"./utils/sentry.js";import{sentryLogger as l}from"./utils/logger.js";function a(e,n){return(o,r,i)=>{if(o.url===e&&"POST"===o.method){let e="";o.on("data",n=>{e=function(e,n){return"string"==typeof n?e+n:t.isBuffer(n)?e+n.toString("utf8"):n instanceof Uint8Array?e+t.from(n).toString("utf8"):e}(e,n)}),o.on("end",()=>{if(e)try{const t=function(t){return s.json().parse(t)}(e);n.write(JSON.stringify(t)+"\n")}catch{n.write(e+"\n")}r.setHeader("Content-Type","application/json"),r.statusCode=200,r.end(JSON.stringify({code:0,message:"success"}))})}else i()}}function d(){const t=e(process.cwd(),"logs");n(t)||o(t,{recursive:!0});const s=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),i=e(t,`sentry_${s}.log`);return{fileStream:r(i,{flags:"a"}),logFile:i}}function c(t={}){const{fileStream:e,logFile:n}=d();l.info("@lark.js/sentry",`Sentry mock middleware initialized, logs will be written to ${n}`);return a(t.dsn||i.options.dsn||"/sentry",e)}class f{dsn;constructor(t={}){this.dsn=t.dsn}apply(t){const e=t.options.devServer,{fileStream:n,logFile:o}=d(),r=a(this.dsn||i.options.dsn||"/sentry",n);l.info("@lark.js/sentry",`Sentry mock plugin initialized, logs will be written to ${o}`);const s=e.setupMiddlewares;e.setupMiddlewares=(t,e)=>{const n=s?s(t,e):t,o={name:"sentry-mock",middleware:r};return n.unshift(o),n},t.hooks.shutdown.tap("SentryWebpackPlugin",()=>{n&&!n.destroyed&&n.close()})}}function u(t={}){return new f(t)}export{f as SentryWebpackPlugin,u as default,c as sentryMiddleware,u as sentryPlugin};
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@lark.js/sentry",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "sentry sdk",
5
- "type": "module",
6
5
  "keywords": [
7
- "sentry",
8
- "sdk"
6
+ "sdk",
7
+ "sentry"
9
8
  ],
10
- "author": "github.com/hangtiancheng",
11
9
  "license": "MIT",
12
- "main": "./dist/index.cjs",
13
- "module": "./dist/index.js",
14
- "types": "./dist/index.d.ts",
10
+ "author": "github.com/hangtiancheng",
15
11
  "files": [
16
12
  "dist",
17
- "./README.md"
13
+ "README.md"
18
14
  ],
15
+ "type": "module",
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
19
  "exports": {
20
20
  ".": {
21
21
  "types": "./dist/index.d.ts",
@@ -41,6 +41,11 @@
41
41
  "types": "./dist/vite.d.ts",
42
42
  "import": "./dist/vite.js",
43
43
  "require": "./dist/vite.cjs"
44
+ },
45
+ "./webpack": {
46
+ "types": "./dist/webpack.d.ts",
47
+ "import": "./dist/webpack.js",
48
+ "require": "./dist/webpack.cjs"
44
49
  }
45
50
  },
46
51
  "scripts": {
@@ -48,7 +53,8 @@
48
53
  "test:watch": "vitest --config ./vitest.config.ts",
49
54
  "test:coverage": "vitest run --config ./vitest.config.ts --coverage",
50
55
  "typecheck": "tsc --noEmit",
51
- "vite7": "pnpm add -D vite7@npm:vite@7.3.3"
56
+ "vite7": "pnpm add -D vite7@npm:vite@7.3.3",
57
+ "format": "oxfmt --write ./"
52
58
  },
53
59
  "dependencies": {
54
60
  "@fingerprintjs/fingerprintjs": "^5.2.0",
@@ -63,24 +69,28 @@
63
69
  "@rollup/plugin-node-resolve": "^16.0.3",
64
70
  "@rollup/plugin-typescript": "^12.3.0",
65
71
  "@rrweb/record": "2.0.0-alpha.20",
66
- "@types/node": "^25.9.1",
72
+ "@types/node": "^25.9.2",
67
73
  "@types/pako": "^2.0.4",
68
- "@types/react": "^19.2.15",
74
+ "@types/react": "^19.2.17",
69
75
  "@types/react-dom": "^19.2.3",
70
76
  "@vitest/coverage-v8": "^1.6.1",
71
77
  "jsdom": "^24.1.3",
72
- "react": "^19.2.6",
73
- "rollup": "^4.61.0",
78
+ "oxfmt": "^0.54.0",
79
+ "react": "^19.2.7",
80
+ "rollup": "^4.61.1",
74
81
  "typescript": "^6.0.3",
75
82
  "vite": "^8.0.16",
76
83
  "vite7": "npm:vite@7.3.3",
77
84
  "vitest": "^1.6.1",
78
- "vue": "^3.5.35"
85
+ "vue": "^3.5.35",
86
+ "webpack": "^5.107.2",
87
+ "webpack-dev-server": "^5.2.4"
79
88
  },
80
89
  "peerDependencies": {
81
90
  "react": "^19.0.0",
82
91
  "vite": "^7.0.0 || ^8.0.0",
83
- "vue": "^3.0.0"
92
+ "vue": "^3.0.0",
93
+ "webpack": "^4.0.0 || ^5.0.0"
84
94
  },
85
95
  "peerDependenciesMeta": {
86
96
  "react": {
@@ -91,6 +101,12 @@
91
101
  },
92
102
  "vue": {
93
103
  "optional": true
104
+ },
105
+ "webpack": {
106
+ "optional": true
107
+ },
108
+ "webpack-dev-server": {
109
+ "optional": true
94
110
  }
95
111
  }
96
112
  }