@swifty.js/sentry 0.0.2 → 0.0.3

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.
Files changed (107) hide show
  1. package/README.md +23 -23
  2. package/dist/core/api.cjs +1 -1
  3. package/dist/core/api.js +1 -1
  4. package/dist/core/breadcrumb.cjs +1 -1
  5. package/dist/core/breadcrumb.js +1 -1
  6. package/dist/core/bus.cjs +1 -1
  7. package/dist/core/bus.js +1 -1
  8. package/dist/core/decorate-http.cjs +1 -1
  9. package/dist/core/decorate-http.js +1 -1
  10. package/dist/core/decorate-route.cjs +1 -1
  11. package/dist/core/decorate-route.js +1 -1
  12. package/dist/core/decorates.cjs +1 -1
  13. package/dist/core/decorates.js +1 -1
  14. package/dist/core/framework-error.cjs +1 -1
  15. package/dist/core/framework-error.d.ts +32 -0
  16. package/dist/core/framework-error.js +1 -1
  17. package/dist/core/handle-code-error.cjs +1 -1
  18. package/dist/core/handle-code-error.js +1 -1
  19. package/dist/core/handle-error.cjs +1 -1
  20. package/dist/core/handle-error.js +1 -1
  21. package/dist/core/handle-events.cjs +1 -1
  22. package/dist/core/handle-events.js +1 -1
  23. package/dist/core/handle-http.cjs +1 -1
  24. package/dist/core/handle-http.js +1 -1
  25. package/dist/core/handle-route.cjs +1 -1
  26. package/dist/core/handle-route.js +1 -1
  27. package/dist/core/identity.cjs +1 -1
  28. package/dist/core/identity.js +1 -1
  29. package/dist/core/ip.d.ts +21 -0
  30. package/dist/core/pv-lifecycle.cjs +1 -1
  31. package/dist/core/pv-lifecycle.js +1 -1
  32. package/dist/core/sdk-lifecycle.cjs +1 -1
  33. package/dist/core/sdk-lifecycle.d.ts +22 -0
  34. package/dist/core/sdk-lifecycle.js +1 -1
  35. package/dist/core/setup.cjs +1 -1
  36. package/dist/core/setup.js +1 -1
  37. package/dist/core/white-screen.cjs +1 -1
  38. package/dist/core/white-screen.js +1 -1
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +1 -1
  42. package/dist/package.json.cjs +1 -1
  43. package/dist/package.json.js +1 -1
  44. package/dist/plugins/exposure/index.cjs +1 -1
  45. package/dist/plugins/exposure/index.d.ts +22 -0
  46. package/dist/plugins/exposure/index.js +1 -1
  47. package/dist/plugins/performance/index.cjs +1 -1
  48. package/dist/plugins/performance/index.d.ts +22 -0
  49. package/dist/plugins/performance/index.js +1 -1
  50. package/dist/plugins/performance/navigation-timing.cjs +1 -1
  51. package/dist/plugins/performance/navigation-timing.js +1 -1
  52. package/dist/plugins/performance/perf.cjs +1 -1
  53. package/dist/plugins/performance/perf.js +1 -1
  54. package/dist/plugins/performance/resource-element-fallback.cjs +1 -1
  55. package/dist/plugins/performance/resource-element-fallback.js +1 -1
  56. package/dist/plugins/performance/resource-timing.cjs +1 -1
  57. package/dist/plugins/performance/resource-timing.js +1 -1
  58. package/dist/plugins/screen-record/index.cjs +1 -1
  59. package/dist/plugins/screen-record/index.d.ts +22 -0
  60. package/dist/plugins/screen-record/index.js +1 -1
  61. package/dist/plugins/screen-record/recorder.cjs +1 -1
  62. package/dist/plugins/screen-record/recorder.d.ts +22 -0
  63. package/dist/plugins/screen-record/recorder.js +1 -1
  64. package/dist/preact.d.ts +22 -0
  65. package/dist/react.d.ts +22 -0
  66. package/dist/reporter/batch.cjs +1 -1
  67. package/dist/reporter/batch.js +1 -1
  68. package/dist/reporter/index.cjs +1 -1
  69. package/dist/reporter/index.js +1 -1
  70. package/dist/reporter/network-listener.cjs +1 -1
  71. package/dist/reporter/network-listener.js +1 -1
  72. package/dist/reporter/offline-cache.cjs +1 -1
  73. package/dist/reporter/offline-cache.js +1 -1
  74. package/dist/reporter/report-data.cjs +1 -1
  75. package/dist/reporter/report-data.js +1 -1
  76. package/dist/reporter/send-preflight.cjs +1 -1
  77. package/dist/reporter/send-preflight.js +1 -1
  78. package/dist/reporter/server-recovery.cjs +1 -1
  79. package/dist/reporter/server-recovery.js +1 -1
  80. package/dist/reporter/transports.cjs +1 -1
  81. package/dist/reporter/transports.js +1 -1
  82. package/dist/sourcemap/sourcemap.cjs +1 -0
  83. package/dist/sourcemap/sourcemap.js +1 -0
  84. package/dist/sourcemap/vite.cjs +1 -0
  85. package/dist/sourcemap/vite.js +1 -0
  86. package/dist/sourcemap/webpack.cjs +1 -0
  87. package/dist/sourcemap/webpack.js +1 -0
  88. package/dist/types/common.d.ts +31 -3
  89. package/dist/types/enums.cjs +1 -1
  90. package/dist/types/enums.d.ts +22 -1
  91. package/dist/types/enums.js +1 -1
  92. package/dist/types/handlers.d.ts +22 -0
  93. package/dist/types/options.d.ts +22 -0
  94. package/dist/types/plugin.d.ts +22 -0
  95. package/dist/utils/click-data.cjs +1 -1
  96. package/dist/utils/click-data.js +1 -1
  97. package/dist/utils/decorate-prop.d.ts +21 -0
  98. package/dist/utils/is-type.cjs +1 -1
  99. package/dist/utils/is-type.js +1 -1
  100. package/dist/vite.cjs +1 -1
  101. package/dist/vite.d.ts +22 -0
  102. package/dist/vite.js +1 -1
  103. package/dist/vue.d.ts +22 -0
  104. package/dist/webpack.cjs +1 -1
  105. package/dist/webpack.d.ts +22 -0
  106. package/dist/webpack.js +1 -1
  107. package/package.json +6 -4
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2026 hangtiancheng
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
1
22
  declare enum HttpStatus {
2
23
  OK = "OK",// 200
3
24
  BadRequest = "Bad Request",// 400
@@ -36,7 +57,7 @@ declare enum EventType {
36
57
  Error = "Error",
37
58
  Vue = "Vue",
38
59
  React = "React",
39
- Swifty = "Swifty",
60
+ OtherFrameworks = "OtherFrameworks",
40
61
  Performance = "Performance",
41
62
  ScreenRecord = "ScreenRecord",
42
63
  Exposure = "Exposure",
@@ -1 +1 @@
1
- var e,o,r,t,n,a,u;!function(e){e.OK="OK",e.BadRequest="Bad Request",e.Unauthorized="Unauthorized",e.Forbidden="Forbidden",e.NotFound="NotFound",e.Conflict="Conflict",e.PayloadTooLarge="Payload Too Large",e.TooManyRequests="Too Many Requests",e.InternalServerError="Internal Server Error",e.NotImplemented="Not Implemented",e.ServiceUnavailable="Service Unavailable",e.GatewayTimeout="Gateway Timeout",e.UnknownError="Unknown Error"}(e||(e={})),function(e){e.Http="Http",e.Click="Click",e.Route="Route",e.Resource="Resource",e.CodeError="Code Error",e.Custom="Custom"}(o||(o={})),function(e){e.Error="Error",e.OK="OK"}(r||(r={})),function(e){e.Xhr="XMLHttpRequest",e.Fetch="fetch",e.Click="Click",e.HashChange="Event hashchange",e.History="History",e.Resource="Resource",e.UnhandledRejection="Event unhandledrejection",e.Error="Error",e.Vue="Vue",e.React="React",e.Swifty="Swifty",e.Performance="Performance",e.ScreenRecord="ScreenRecord",e.Exposure="Exposure",e.WhiteScreen="WhiteScreen",e.Custom="Custom",e.PV="PV"}(t||(t={})),function(e){e.Xhr="XMLHttpRequest",e.Fetch="fetch"}(n||(n={})),function(e){e[e.OK=200]="OK",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.Conflict=409]="Conflict",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"}(a||(a={})),function(e){e.Get="GET",e.Head="HEAD",e.Post="POST",e.Put="PUT",e.Delete="DELETE",e.Connect="CONNECT",e.Options="OPTIONS",e.Trace="TRACE",e.Patch="PATCH"}(u||(u={}));export{o as BreadcrumbType,t as EventType,u as HttpMethod,e as HttpStatus,a as HttpStatusCode,n as HttpType,r as Status};
1
+ var e,o,r,t,n,a,u;!function(e){e.OK="OK",e.BadRequest="Bad Request",e.Unauthorized="Unauthorized",e.Forbidden="Forbidden",e.NotFound="NotFound",e.Conflict="Conflict",e.PayloadTooLarge="Payload Too Large",e.TooManyRequests="Too Many Requests",e.InternalServerError="Internal Server Error",e.NotImplemented="Not Implemented",e.ServiceUnavailable="Service Unavailable",e.GatewayTimeout="Gateway Timeout",e.UnknownError="Unknown Error"}(e||(e={})),function(e){e.Http="Http",e.Click="Click",e.Route="Route",e.Resource="Resource",e.CodeError="Code Error",e.Custom="Custom"}(o||(o={})),function(e){e.Error="Error",e.OK="OK"}(r||(r={})),function(e){e.Xhr="XMLHttpRequest",e.Fetch="fetch",e.Click="Click",e.HashChange="Event hashchange",e.History="History",e.Resource="Resource",e.UnhandledRejection="Event unhandledrejection",e.Error="Error",e.Vue="Vue",e.React="React",e.OtherFrameworks="OtherFrameworks",e.Performance="Performance",e.ScreenRecord="ScreenRecord",e.Exposure="Exposure",e.WhiteScreen="WhiteScreen",e.Custom="Custom",e.PV="PV"}(t||(t={})),function(e){e.Xhr="XMLHttpRequest",e.Fetch="fetch"}(n||(n={})),function(e){e[e.OK=200]="OK",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.Conflict=409]="Conflict",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"}(a||(a={})),function(e){e.Get="GET",e.Head="HEAD",e.Post="POST",e.Put="PUT",e.Delete="DELETE",e.Connect="CONNECT",e.Options="OPTIONS",e.Trace="TRACE",e.Patch="PATCH"}(u||(u={}));export{o as BreadcrumbType,t as EventType,u as HttpMethod,e as HttpStatus,a as HttpStatusCode,n as HttpType,r as Status};
@@ -2,6 +2,28 @@ import { TReportPayload } from './common.js';
2
2
  import { EventType } from './enums.js';
3
3
  import { Cleanup } from '../utils/decorate-prop.js';
4
4
 
5
+ /**
6
+ * Copyright (c) 2026 hangtiancheng
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
5
27
  type TEventHandler<T extends TReportPayload = TReportPayload> = {
6
28
  handle(data: T): void;
7
29
  }["handle"];
@@ -1,6 +1,28 @@
1
1
  import { IReportData, IBreadcrumbItem } from './common.js';
2
2
  import { EventType } from './enums.js';
3
3
 
4
+ /**
5
+ * Copyright (c) 2026 hangtiancheng
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
4
26
  type ReportDataHook = (data: IReportData) => Promise<IReportData | false> | IReportData | false;
5
27
  type ReportBatchHook = (data: readonly IReportData[]) => Promise<readonly IReportData[] | false> | readonly IReportData[] | false;
6
28
  type AfterSendDataHook = (data: readonly IReportData[]) => Promise<void> | void;
@@ -1,6 +1,28 @@
1
1
  import { EventType } from './enums.js';
2
2
  import { IReportPayload } from './common.js';
3
3
 
4
+ /**
5
+ * Copyright (c) 2026 hangtiancheng
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
4
26
  type WithSentry<T, S extends IReportPayload = IReportPayload> = T & {
5
27
  __sentry__: S;
6
28
  };
@@ -1 +1 @@
1
- "use strict";const t="s-swifty-",e=new Set(["view","msg","ev"]);function n(t){return t.hasAttribute("s-swifty-view")||t.hasAttribute("s-swifty-ev")||t.hasAttribute("s-swifty-msg")}function r(t){const e=(n=t)?n.getAttribute("s-swifty-msg")??n.title:"";var n;if(e)return e;const r=t.textContent?.trim();return r||t.getAttribute("aria-label")||t.tagName.toLowerCase()}function s(t,e){for(const n of t){const t=n.getAttribute(e);if(t)return t}return null}function i(t){const e=s(t,"s-swifty-ev");if(e)return e;const n=s(t,"title");if(n)return n;const r=s(t,"s-swifty-view");return r||(t[0]?.tagName.toLowerCase()??"unknown")}function o(n){const r=n.find(e=>Array.from(e.attributes).some(e=>e.name.startsWith(t)));return r?Array.from(r.attributes).reduce((n,r)=>{if(!r.name.startsWith(t))return n;const s=r.name.replace(t,"");return e.has(s)||(n[s]=r.value||null),n},{}):{}}function a(t){const e=[];let n=t;for(;n&&n!==document.body;)e.unshift(n.tagName.toLowerCase()),n=n.parentElement;return e.join(">")}exports.getDeclarativeClickData=function(t){const e=function(t){return t.composedPath().filter(t=>t instanceof HTMLElement)}(t),s=e.length>0?e:function(t){if(!(t instanceof HTMLElement))return[];const e=[];let n=t;for(;n;)e.push(n),n=n.parentElement;return e}(t.target),u=s.find(n);if(!u)return null;const c=t.target instanceof HTMLElement?t.target:u,{top:f,left:l}=c.getBoundingClientRect(),{scrollTop:m,scrollLeft:g}=document.documentElement;return{ev:i(s),msg:r(u),triggerPageUrl:location.href,x:l+g,y:f+m,params:o(s),elementPath:a(u).slice(-128),triggerTime:Date.now()}};
1
+ "use strict";const t="swifty-sentry-",e=new Set(["view","msg","ev"]);function n(t){return t.hasAttribute("swifty-sentry-el")||t.hasAttribute("swifty-sentry-ev")||t.hasAttribute("swifty-sentry-msg")}function r(t){const e=(n=t)?n.getAttribute("swifty-sentry-msg")??n.title:"";var n;if(e)return e;const r=t.textContent?.trim();return r||t.getAttribute("aria-label")||t.tagName.toLowerCase()}function s(t,e){for(const n of t){const t=n.getAttribute(e);if(t)return t}return null}function o(t){const e=s(t,"swifty-sentry-ev");if(e)return e;const n=s(t,"title");if(n)return n;const r=s(t,"swifty-sentry-el");return r||(t[0]?.tagName.toLowerCase()??"unknown")}function i(n){const r=n.find(e=>Array.from(e.attributes).some(e=>e.name.startsWith(t)));return r?Array.from(r.attributes).reduce((n,r)=>{if(!r.name.startsWith(t))return n;const s=r.name.replace(t,"");return e.has(s)||(n[s]=r.value||null),n},{}):{}}function a(t){const e=[];let n=t;for(;n&&n!==document.body;)e.unshift(n.tagName.toLowerCase()),n=n.parentElement;return e.join(">")}exports.getDeclarativeClickData=function(t){const e=function(t){return t.composedPath().filter(t=>t instanceof HTMLElement)}(t),s=e.length>0?e:function(t){if(!(t instanceof HTMLElement))return[];const e=[];let n=t;for(;n;)e.push(n),n=n.parentElement;return e}(t.target),u=s.find(n);if(!u)return null;const c=t.target instanceof HTMLElement?t.target:u,{top:f,left:l}=c.getBoundingClientRect(),{scrollTop:m,scrollLeft:g}=document.documentElement;return{ev:o(s),msg:r(u),triggerPageUrl:location.href,x:l+g,y:f+m,params:i(s),elementPath:a(u).slice(-128),triggerTime:Date.now()}};
@@ -1 +1 @@
1
- const t="s-swifty-",e=new Set(["view","msg","ev"]);function n(t){return t.hasAttribute("s-swifty-view")||t.hasAttribute("s-swifty-ev")||t.hasAttribute("s-swifty-msg")}function r(t){const e=(n=t)?n.getAttribute("s-swifty-msg")??n.title:"";var n;if(e)return e;const r=t.textContent?.trim();return r||t.getAttribute("aria-label")||t.tagName.toLowerCase()}function o(t,e){for(const n of t){const t=n.getAttribute(e);if(t)return t}return null}function s(t){const e=o(t,"s-swifty-ev");if(e)return e;const n=o(t,"title");if(n)return n;const r=o(t,"s-swifty-view");return r||(t[0]?.tagName.toLowerCase()??"unknown")}function i(n){const r=n.find(e=>Array.from(e.attributes).some(e=>e.name.startsWith(t)));return r?Array.from(r.attributes).reduce((n,r)=>{if(!r.name.startsWith(t))return n;const o=r.name.replace(t,"");return e.has(o)||(n[o]=r.value||null),n},{}):{}}function u(t){const e=[];let n=t;for(;n&&n!==document.body;)e.unshift(n.tagName.toLowerCase()),n=n.parentElement;return e.join(">")}function a(t){const e=function(t){return t.composedPath().filter(t=>t instanceof HTMLElement)}(t),o=e.length>0?e:function(t){if(!(t instanceof HTMLElement))return[];const e=[];let n=t;for(;n;)e.push(n),n=n.parentElement;return e}(t.target),a=o.find(n);if(!a)return null;const f=t.target instanceof HTMLElement?t.target:a,{top:c,left:l}=f.getBoundingClientRect(),{scrollTop:m,scrollLeft:g}=document.documentElement;return{ev:s(o),msg:r(a),triggerPageUrl:location.href,x:l+g,y:c+m,params:i(o),elementPath:u(a).slice(-128),triggerTime:Date.now()}}export{a as getDeclarativeClickData};
1
+ const t="swifty-sentry-",e=new Set(["view","msg","ev"]);function n(t){return t.hasAttribute("swifty-sentry-el")||t.hasAttribute("swifty-sentry-ev")||t.hasAttribute("swifty-sentry-msg")}function r(t){const e=(n=t)?n.getAttribute("swifty-sentry-msg")??n.title:"";var n;if(e)return e;const r=t.textContent?.trim();return r||t.getAttribute("aria-label")||t.tagName.toLowerCase()}function o(t,e){for(const n of t){const t=n.getAttribute(e);if(t)return t}return null}function s(t){const e=o(t,"swifty-sentry-ev");if(e)return e;const n=o(t,"title");if(n)return n;const r=o(t,"swifty-sentry-el");return r||(t[0]?.tagName.toLowerCase()??"unknown")}function i(n){const r=n.find(e=>Array.from(e.attributes).some(e=>e.name.startsWith(t)));return r?Array.from(r.attributes).reduce((n,r)=>{if(!r.name.startsWith(t))return n;const o=r.name.replace(t,"");return e.has(o)||(n[o]=r.value||null),n},{}):{}}function u(t){const e=[];let n=t;for(;n&&n!==document.body;)e.unshift(n.tagName.toLowerCase()),n=n.parentElement;return e.join(">")}function a(t){const e=function(t){return t.composedPath().filter(t=>t instanceof HTMLElement)}(t),o=e.length>0?e:function(t){if(!(t instanceof HTMLElement))return[];const e=[];let n=t;for(;n;)e.push(n),n=n.parentElement;return e}(t.target),a=o.find(n);if(!a)return null;const f=t.target instanceof HTMLElement?t.target:a,{top:c,left:l}=f.getBoundingClientRect(),{scrollTop:m,scrollLeft:g}=document.documentElement;return{ev:s(o),msg:r(a),triggerPageUrl:location.href,x:l+g,y:c+m,params:i(o),elementPath:u(a).slice(-128),triggerTime:Date.now()}}export{a as getDeclarativeClickData};
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2026 hangtiancheng
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
1
22
  type Cleanup = () => void;
2
23
 
3
24
  export type { Cleanup };
@@ -1 +1 @@
1
- "use strict";exports.isError=function(r){return r instanceof Error},exports.isErrorEvent=function(r){return r instanceof ErrorEvent},exports.isHTMLElement=function(r){return r.nodeType===Node.ELEMENT_NODE},exports.isIExtendedErrorEvent=function(r){return r instanceof ErrorEvent&&null!==r.target&&"src"in r.target&&"string"==typeof r.target.src&&"href"in r.target&&"string"==typeof r.target.href&&"localName"in r.target&&"string"==typeof r.target.localName};
1
+ "use strict";var r=require("zod");const e=r.z.union([r.z.looseObject({localName:r.z.string(),src:r.z.string().min(1)}),r.z.looseObject({localName:r.z.string(),href:r.z.string().min(1)})]);exports.isError=function(r){return r instanceof Error},exports.isErrorEvent=function(r){return r instanceof ErrorEvent},exports.isHTMLElement=function(r){return r.nodeType===Node.ELEMENT_NODE},exports.isIExtendedErrorEvent=function(r){return r instanceof Event&&"error"===r.type&&e.safeParse(r.target).success};
@@ -1 +1 @@
1
- function t(t){return t.nodeType===Node.ELEMENT_NODE}function r(t){return t instanceof Error}function n(t){return t instanceof ErrorEvent}function e(t){return t instanceof ErrorEvent&&null!==t.target&&"src"in t.target&&"string"==typeof t.target.src&&"href"in t.target&&"string"==typeof t.target.href&&"localName"in t.target&&"string"==typeof t.target.localName}export{r as isError,n as isErrorEvent,t as isHTMLElement,e as isIExtendedErrorEvent};
1
+ import{z as n}from"zod";function r(n){return n.nodeType===Node.ELEMENT_NODE}function e(n){return n instanceof Error}function t(n){return n instanceof ErrorEvent}const o=n.union([n.looseObject({localName:n.string(),src:n.string().min(1)}),n.looseObject({localName:n.string(),href:n.string().min(1)})]);function s(n){return n instanceof Event&&"error"===n.type&&o.safeParse(n.target).success}export{e as isError,t as isErrorEvent,r as isHTMLElement,s as isIExtendedErrorEvent};
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");function i(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 o(e){return JSON.parse(e)}const l=(e,t)=>n=>{n.middlewares.use((n,r,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=i(e,t)}),n.on("end",()=>{if(e)try{const n=o(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()})},u=(e,t)=>n=>{n.middlewares.use((n,r,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=i(e,t)}),n.on("end",()=>{if(e)try{const n=o(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 c(){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}.jsonl`);return{fileStream:n.createWriteStream(s,{flags:"a"}),logFile:s}}function a({dsn:e}){const{fileStream:t,logFile:n}=c();return s.sentryLogger.info(`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()}}}exports.default=a,exports.sentryPlugin=a,exports.sentryPlugin7=function({dsn:e}={}){const{fileStream:t,logFile:n}=c();return s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:l(e||r.default.options.dsn||"/sentry",t),closeBundle(){t&&t.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");require("./utils/is-type.cjs");var s=require("./utils/logger.cjs"),i=require("./sourcemap/vite.cjs");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 JSON.parse(e)}const u=(e,t)=>n=>{n.middlewares.use((r,s,u)=>{if(r.url===e&&"POST"===r.method){let e="";r.on("data",t=>{e=o(e,t)}),r.on("end",async()=>{if(e)try{const r=c(e),s=await i.enrichReportData(n,r);t.write(JSON.stringify(s)+"\n")}catch{t.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else u()})},a=(e,t)=>n=>{n.middlewares.use((r,s,u)=>{if(r.url===e&&"POST"===r.method){let e="";r.on("data",t=>{e=o(e,t)}),r.on("end",async()=>{if(e)try{const r=c(e),s=await i.enrichReportData(n,r);t.write(JSON.stringify(s)+"\n")}catch{t.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else u()})};function l(){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}.jsonl`);return{fileStream:n.createWriteStream(s,{flags:"a"}),logFile:s}}function f({dsn:e}){const{fileStream:t,logFile:n}=l();return s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:a(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}=l();return s.sentryLogger.info(`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.d.ts CHANGED
@@ -1,6 +1,28 @@
1
1
  import { Plugin as Plugin$1 } from 'vite7';
2
2
  import { Plugin } from 'vite';
3
3
 
4
+ /**
5
+ * Copyright (c) 2026 hangtiancheng
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
4
26
  interface ISentryPluginOptions {
5
27
  dsn?: string;
6
28
  }
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 i,createWriteStream as o}from"node:fs";import"./constants/index.js";import"./types/enums.js";import s from"./utils/sentry.js";import{sentryLogger as r}from"./utils/logger.js";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 c(e){return JSON.parse(e)}const f=(e,t)=>n=>{n.middlewares.use((n,i,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=c(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}i.setHeader("Content-Type","application/json"),i.statusCode=200,i.end(JSON.stringify({code:0,message:"success"}))})}else o()})},a=(e,t)=>n=>{n.middlewares.use((n,i,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=c(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\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(process.cwd(),"logs");n(e)||i(e,{recursive:!0});const s=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),r=t(e,`sentry_${s}.jsonl`);return{fileStream:o(r,{flags:"a"}),logFile:r}}function d({dsn:e}={}){const{fileStream:t,logFile:n}=u();return r.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:f(e||s.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}function m({dsn:e}){const{fileStream:t,logFile:n}=u();return r.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:a(e||s.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}export{m as default,m as sentryPlugin,d as sentryPlugin7};
1
+ import{Buffer as e}from"node:buffer";import{join as t}from"node:path";import{existsSync as n,mkdirSync as i,createWriteStream as s}from"node:fs";import"./constants/index.js";import"./types/enums.js";import o from"./utils/sentry.js";import"./utils/is-type.js";import{sentryLogger as r}from"./utils/logger.js";import{enrichReportData as l}from"./sourcemap/vite.js";function a(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 c(e){return JSON.parse(e)}const f=(e,t)=>n=>{n.middlewares.use((i,s,o)=>{if(i.url===e&&"POST"===i.method){let e="";i.on("data",t=>{e=a(e,t)}),i.on("end",async()=>{if(e)try{const i=c(e),s=await l(n,i);t.write(JSON.stringify(s)+"\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()})},u=(e,t)=>n=>{n.middlewares.use((i,s,o)=>{if(i.url===e&&"POST"===i.method){let e="";i.on("data",t=>{e=a(e,t)}),i.on("end",async()=>{if(e)try{const i=c(e),s=await l(n,i);t.write(JSON.stringify(s)+"\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 d(){const e=t(process.cwd(),"logs");n(e)||i(e,{recursive:!0});const o=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),r=t(e,`sentry_${o}.jsonl`);return{fileStream:s(r,{flags:"a"}),logFile:r}}function m({dsn:e}={}){const{fileStream:t,logFile:n}=d();return r.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:f(e||o.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}function p({dsn:e}){const{fileStream:t,logFile:n}=d();return r.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:u(e||o.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}export{p as default,p as sentryPlugin,m as sentryPlugin7};
package/dist/vue.d.ts CHANGED
@@ -1,5 +1,27 @@
1
1
  import { Plugin } from 'vue';
2
2
 
3
+ /**
4
+ * Copyright (c) 2026 hangtiancheng
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
3
25
  declare const vuePlugin: Plugin;
4
26
 
5
27
  export { vuePlugin };
package/dist/webpack.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");function i(t,n){return(r,s,i)=>{if(r.url===t&&"POST"===r.method){let t="";r.on("data",n=>{t=function(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}(t,n)}),r.on("end",()=>{if(t)try{const e=function(e){return JSON.parse(e)}(t);n.write(JSON.stringify(e)+"\n")}catch{n.write(t+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else i()}}function o(){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}.jsonl`);return{fileStream:n.createWriteStream(s,{flags:"a"}),logFile:s}}class u{dsn;constructor(e={}){this.dsn=e.dsn}apply(e){const t=e.options.devServer;if(!1===(n=t)||null==n||"object"!=typeof n)return void s.sentryLogger.info("devServer is not configured, skipping SentryWebpackPlugin (production builds remain untouched)");var n;const{fileStream:u,logFile:c}=o(),l=i(this.dsn||r.default.options.dsn||"/sentry",u);s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${c}`);const d=t.setupMiddlewares;t.setupMiddlewares=(e,t)=>{const n=d?d(e,t):e,r={name:"sentry-mock",middleware:l};return n.unshift(r),n},e.hooks.shutdown.tap("SentryWebpackPlugin",()=>{u&&!u.destroyed&&u.close()})}}function c(e={}){return new u(e)}exports.SentryWebpackPlugin=u,exports.default=c,exports.sentryMiddleware=function(e={}){const{fileStream:t,logFile:n}=o();return s.sentryLogger.info(`Sentry mock middleware initialized, logs will be written to ${n}`),i(e.dsn||r.default.options.dsn||"/sentry",t)},exports.sentryPlugin=c;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node:buffer"),t=require("node:path"),r=require("node:fs");require("./constants/index.cjs"),require("./types/enums.cjs");var n=require("./utils/sentry.cjs");require("./utils/is-type.cjs");var s=require("./utils/logger.cjs"),i=require("./sourcemap/webpack.cjs"),o=require("./sourcemap/sourcemap.cjs");function u(t,r,n){return(s,i,u)=>{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",async()=>{if(t)try{const e=function(e){return JSON.parse(e)}(t),s=n?await o.enrichReportData(n,e):e;r.write(JSON.stringify(s)+"\n")}catch{r.write(t+"\n")}i.setHeader("Content-Type","application/json"),i.statusCode=200,i.end(JSON.stringify({code:0,message:"success"}))})}else u()}}function a(){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}.jsonl`);return{fileStream:r.createWriteStream(s,{flags:"a"}),logFile:s}}class c{dsn;constructor(e={}){this.dsn=e.dsn}apply(e){const t=e.options.devServer;if(!1===(r=t)||null==r||"object"!=typeof r)return void s.sentryLogger.info("devServer is not configured, skipping SentryWebpackPlugin (production builds remain untouched)");var r;const{fileStream:o,logFile:c}=a(),l=this.dsn||n.default.options.dsn||"/sentry",d=i.createAssetMapStore(),p=u(l,o,d.loadMap);e.hooks.assetEmitted.tap("SentryWebpackPlugin",(e,{content:t})=>{e.endsWith(".map")&&d.put(e,t.toString("utf8"))}),s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${c}`);const f=t.setupMiddlewares;t.setupMiddlewares=(e,t)=>{const r=f?f(e,t):e,n={name:"sentry-mock",middleware:p};return r.unshift(n),r},e.hooks.shutdown.tap("SentryWebpackPlugin",()=>{o&&!o.destroyed&&o.close()})}}function l(e={}){return new c(e)}exports.SentryWebpackPlugin=c,exports.default=l,exports.sentryMiddleware=function(e={}){const{fileStream:t,logFile:r}=a();return s.sentryLogger.info(`Sentry mock middleware initialized, logs will be written to ${r}`),u(e.dsn||n.default.options.dsn||"/sentry",t)},exports.sentryPlugin=l;
package/dist/webpack.d.ts CHANGED
@@ -2,6 +2,28 @@ import { IncomingMessage, ServerResponse } from 'node:http';
2
2
  import { WebpackPluginInstance, Compiler } from 'webpack';
3
3
  import DevServer from 'webpack-dev-server';
4
4
 
5
+ /**
6
+ * Copyright (c) 2026 hangtiancheng
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
5
27
  type SentryDevMiddleware = (req: IncomingMessage, res: ServerResponse, next: DevServer.NextFunction) => void;
6
28
  interface ISentryWebpackPluginOptions {
7
29
  dsn?: string;
package/dist/webpack.js CHANGED
@@ -1 +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"./constants/index.js";import"./types/enums.js";import i from"./utils/sentry.js";import{sentryLogger as s}from"./utils/logger.js";function l(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 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 c(){const t=e(process.cwd(),"logs");n(t)||o(t,{recursive:!0});const i=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),s=e(t,`sentry_${i}.jsonl`);return{fileStream:r(s,{flags:"a"}),logFile:s}}function d(t={}){const{fileStream:e,logFile:n}=c();s.info(`Sentry mock middleware initialized, logs will be written to ${n}`);return l(t.dsn||i.options.dsn||"/sentry",e)}class u{dsn;constructor(t={}){this.dsn=t.dsn}apply(t){const e=t.options.devServer;if(!1===(n=e)||null==n||"object"!=typeof n)return void s.info("devServer is not configured, skipping SentryWebpackPlugin (production builds remain untouched)");var n;const{fileStream:o,logFile:r}=c(),d=l(this.dsn||i.options.dsn||"/sentry",o);s.info(`Sentry mock plugin initialized, logs will be written to ${r}`);const u=e.setupMiddlewares;e.setupMiddlewares=(t,e)=>{const n=u?u(t,e):t,o={name:"sentry-mock",middleware:d};return n.unshift(o),n},t.hooks.shutdown.tap("SentryWebpackPlugin",()=>{o&&!o.destroyed&&o.close()})}}function f(t={}){return new u(t)}export{u as SentryWebpackPlugin,f as default,d as sentryMiddleware,f as sentryPlugin};
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"./constants/index.js";import"./types/enums.js";import s from"./utils/sentry.js";import"./utils/is-type.js";import{sentryLogger as i}from"./utils/logger.js";import{createAssetMapStore as a}from"./sourcemap/webpack.js";import{enrichReportData as c}from"./sourcemap/sourcemap.js";function u(e,n,o){return(r,s,i)=>{if(r.url===e&&"POST"===r.method){let e="";r.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)}),r.on("end",async()=>{if(e)try{const t=function(t){return JSON.parse(t)}(e),r=o?await c(o,t):t;n.write(JSON.stringify(r)+"\n")}catch{n.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else i()}}function l(){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}.jsonl`);return{fileStream:r(i,{flags:"a"}),logFile:i}}function p(t={}){const{fileStream:e,logFile:n}=l();i.info(`Sentry mock middleware initialized, logs will be written to ${n}`);return u(t.dsn||s.options.dsn||"/sentry",e)}class d{dsn;constructor(t={}){this.dsn=t.dsn}apply(t){const e=t.options.devServer;if(!1===(n=e)||null==n||"object"!=typeof n)return void i.info("devServer is not configured, skipping SentryWebpackPlugin (production builds remain untouched)");var n;const{fileStream:o,logFile:r}=l(),c=this.dsn||s.options.dsn||"/sentry",p=a(),d=u(c,o,p.loadMap);t.hooks.assetEmitted.tap("SentryWebpackPlugin",(t,{content:e})=>{t.endsWith(".map")&&p.put(t,e.toString("utf8"))}),i.info(`Sentry mock plugin initialized, logs will be written to ${r}`);const f=e.setupMiddlewares;e.setupMiddlewares=(t,e)=>{const n=f?f(t,e):t,o={name:"sentry-mock",middleware:d};return n.unshift(o),n},t.hooks.shutdown.tap("SentryWebpackPlugin",()=>{o&&!o.destroyed&&o.close()})}}function f(t={}){return new d(t)}export{d as SentryWebpackPlugin,f as default,p as sentryMiddleware,f as sentryPlugin};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@swifty.js/sentry",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Framework-agnostic sentry sdk with first-class support for react, vue3+, and preact",
5
5
  "keywords": [
6
+ "preact",
7
+ "react",
6
8
  "sdk",
7
9
  "sentry",
8
- "react",
9
- "vue",
10
- "preact"
10
+ "vue"
11
11
  ],
12
12
  "homepage": "https://github.com/hangtiancheng/swifty-sentry/tree/main/sentry#readme",
13
13
  "bugs": {
@@ -74,12 +74,14 @@
74
74
  "format": "oxfmt --write ./",
75
75
  "prepublishOnly": "pnpm build",
76
76
  "build": "rollup -c ./rollup.config.ts",
77
+ "build:watch": "rollup -c ./rollup.config.ts -w",
77
78
  "build:tsup": "tsup --config ./tsup.config.ts"
78
79
  },
79
80
  "dependencies": {
80
81
  "@fingerprintjs/fingerprintjs": "^5.2.0",
81
82
  "@rrweb/record": "2.1.0",
82
83
  "pako": "^2.2.0",
84
+ "source-map": "^0.8.0",
83
85
  "ua-parser-js": "^2.0.10",
84
86
  "web-vitals": "^5.3.0",
85
87
  "zod": "^4.4.3"