@ohbug/browser 1.0.19 → 2.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.
Files changed (60) hide show
  1. package/README.md +2 -3
  2. package/dist/index.d.ts +70 -5
  3. package/dist/index.js +1 -0
  4. package/dist/index.mjs +1 -0
  5. package/package.json +17 -20
  6. package/dist/capture/action/captureClick.d.ts +0 -3
  7. package/dist/capture/action/captureClick.d.ts.map +0 -1
  8. package/dist/capture/action/captureUrlChange.d.ts +0 -3
  9. package/dist/capture/action/captureUrlChange.d.ts.map +0 -1
  10. package/dist/capture/console/captureConsole.d.ts +0 -3
  11. package/dist/capture/console/captureConsole.d.ts.map +0 -1
  12. package/dist/capture/index.d.ts +0 -10
  13. package/dist/capture/index.d.ts.map +0 -1
  14. package/dist/capture/network/captureAjaxError.d.ts +0 -6
  15. package/dist/capture/network/captureAjaxError.d.ts.map +0 -1
  16. package/dist/capture/network/captureFetchError.d.ts +0 -6
  17. package/dist/capture/network/captureFetchError.d.ts.map +0 -1
  18. package/dist/capture/network/captureWebSocketError.d.ts +0 -5
  19. package/dist/capture/network/captureWebSocketError.d.ts.map +0 -1
  20. package/dist/capture/script/captureUncaughtError.d.ts +0 -6
  21. package/dist/capture/script/captureUncaughtError.d.ts.map +0 -1
  22. package/dist/capture/script/captureUnhandledrejectionError.d.ts +0 -6
  23. package/dist/capture/script/captureUnhandledrejectionError.d.ts.map +0 -1
  24. package/dist/client.d.ts +0 -8
  25. package/dist/client.d.ts.map +0 -1
  26. package/dist/destroy.d.ts +0 -2
  27. package/dist/destroy.d.ts.map +0 -1
  28. package/dist/device.d.ts +0 -3
  29. package/dist/device.d.ts.map +0 -1
  30. package/dist/dispatch/index.d.ts +0 -3
  31. package/dist/dispatch/index.d.ts.map +0 -1
  32. package/dist/dispatch/networkDispatcher.d.ts +0 -2
  33. package/dist/dispatch/networkDispatcher.d.ts.map +0 -1
  34. package/dist/dispatch/scriptDispatcher.d.ts +0 -2
  35. package/dist/dispatch/scriptDispatcher.d.ts.map +0 -1
  36. package/dist/extension.d.ts +0 -2
  37. package/dist/extension.d.ts.map +0 -1
  38. package/dist/handle/ajaxErrorHandler.d.ts +0 -15
  39. package/dist/handle/ajaxErrorHandler.d.ts.map +0 -1
  40. package/dist/handle/fetchErrorHandler.d.ts +0 -14
  41. package/dist/handle/fetchErrorHandler.d.ts.map +0 -1
  42. package/dist/handle/index.d.ts +0 -15
  43. package/dist/handle/index.d.ts.map +0 -1
  44. package/dist/handle/resourceErrorHandler.d.ts +0 -13
  45. package/dist/handle/resourceErrorHandler.d.ts.map +0 -1
  46. package/dist/handle/uncaughtErrorHandler.d.ts +0 -10
  47. package/dist/handle/uncaughtErrorHandler.d.ts.map +0 -1
  48. package/dist/handle/unhandledrejectionErrorHandler.d.ts +0 -6
  49. package/dist/handle/unhandledrejectionErrorHandler.d.ts.map +0 -1
  50. package/dist/handle/unknownErrorHandler.d.ts +0 -5
  51. package/dist/handle/unknownErrorHandler.d.ts.map +0 -1
  52. package/dist/handle/websocketErrorHandler.d.ts +0 -12
  53. package/dist/handle/websocketErrorHandler.d.ts.map +0 -1
  54. package/dist/index.d.ts.map +0 -1
  55. package/dist/notifier.d.ts +0 -3
  56. package/dist/notifier.d.ts.map +0 -1
  57. package/dist/ohbug-browser.es.js +0 -59
  58. package/dist/ohbug-browser.umd.js +0 -59
  59. package/dist/version.d.ts +0 -2
  60. package/dist/version.d.ts.map +0 -1
package/README.md CHANGED
@@ -2,14 +2,13 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@ohbug/browser.svg?style=flat-square)](https://www.npmjs.com/package/@ohbug/browser)
4
4
  [![npm bundle size](https://img.shields.io/bundlephobia/min/@ohbug/browser?style=flat-square)](https://bundlephobia.com/result?p=@ohbug/browser)
5
- [![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
5
 
7
6
  English | [简体中文](./README-zh_CN.md)
8
7
 
9
8
  ## Installation
10
9
 
11
10
  ```
12
- yarn add @ohbug/browser
11
+ pnpm instal @ohbug/browser
13
12
  ```
14
13
 
15
14
  ## Usage
@@ -17,5 +16,5 @@ yarn add @ohbug/browser
17
16
  ```javascript
18
17
  import Ohbug from '@ohbug/browser'
19
18
 
20
- Ohbug.init({ apiKey: 'YOUR_API_KEY' })
19
+ Ohbug.setup({ apiKey: 'YOUR_API_KEY' })
21
20
  ```
package/dist/index.d.ts CHANGED
@@ -1,5 +1,70 @@
1
- import { BrowserClient } from './client';
2
- export type { UncaughtErrorDetail, ResourceErrorDetail, UnhandledrejectionErrorDetail, UnknownErrorDetail, AjaxErrorDetail, FetchErrorDetail, WebsocketErrorDetail, } from './handle';
3
- export { BrowserClient as Client };
4
- export default BrowserClient;
5
- //# sourceMappingURL=index.d.ts.map
1
+ import { OhbugClient, OhbugConfig, OhbugBaseDetail } from '@ohbug/types';
2
+
3
+ interface OhbugBrowserClient {
4
+ __client: OhbugClient | null;
5
+ setup: (config: OhbugConfig) => OhbugClient;
6
+ }
7
+ declare const BrowserClient: OhbugBrowserClient;
8
+
9
+ interface UncaughtErrorDetail extends OhbugBaseDetail {
10
+ name: string;
11
+ filename: string;
12
+ lineno: number;
13
+ colno: number;
14
+ stack: string;
15
+ }
16
+
17
+ interface ResourceErrorDetail extends OhbugBaseDetail {
18
+ outerHTML: string;
19
+ src: string;
20
+ tagName: string;
21
+ id: string;
22
+ className: string;
23
+ name: string;
24
+ nodeType: number;
25
+ selector: string;
26
+ }
27
+
28
+ interface UnhandledrejectionErrorDetail extends OhbugBaseDetail {
29
+ stack: string;
30
+ }
31
+
32
+ interface UnknownErrorDetail extends OhbugBaseDetail {
33
+ }
34
+
35
+ interface AjaxErrorDetail extends OhbugBaseDetail {
36
+ req: {
37
+ url: string;
38
+ method: string;
39
+ data: string | {};
40
+ };
41
+ res: {
42
+ response: string;
43
+ status: number;
44
+ statusText: string;
45
+ };
46
+ }
47
+
48
+ interface FetchErrorDetail extends OhbugBaseDetail {
49
+ req: {
50
+ url: string;
51
+ method: string;
52
+ data: string;
53
+ };
54
+ res: {
55
+ status: number;
56
+ statusText: string;
57
+ };
58
+ }
59
+
60
+ interface WebsocketErrorDetail extends OhbugBaseDetail {
61
+ url: string;
62
+ timeStamp: number;
63
+ readyState: number;
64
+ protocol: string;
65
+ extensions: string;
66
+ binaryType: string;
67
+ bufferedAmount: number;
68
+ }
69
+
70
+ export { AjaxErrorDetail, FetchErrorDetail, ResourceErrorDetail, UncaughtErrorDetail, UnhandledrejectionErrorDetail, UnknownErrorDetail, WebsocketErrorDetail, BrowserClient as default };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var R=Object.defineProperty,rt=Object.defineProperties,ot=Object.getOwnPropertyDescriptor,nt=Object.getOwnPropertyDescriptors,it=Object.getOwnPropertyNames,J=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var $=(e,t,r)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,z=(e,t)=>{for(var r in t||(t={}))I.call(t,r)&&$(e,r,t[r]);if(J)for(var r of J(t))at.call(t,r)&&$(e,r,t[r]);return e},Q=(e,t)=>rt(e,nt(t));var st=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},ct=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of it(t))!I.call(e,o)&&o!==r&&R(e,o,{get:()=>t[o],enumerable:!(n=ot(t,o))||n.enumerable});return e};var pt=e=>ct(R({},"__esModule",{value:!0}),e);var xt={};st(xt,{default:()=>yt});module.exports=pt(xt);var ze=require("@ohbug/core"),Qe=require("@ohbug/utils");var V=()=>{let e={};if(navigator){let{language:t,userAgent:r}=navigator;e.language=t,e.userAgent=r}if(document){let{title:t}=document;e.title=t}if(window.location){let{href:t}=window.location;e.url=t}return e};var W="2.0.1";var Ke=require("@ohbug/core");var Be=require("@ohbug/utils");var u=require("@ohbug/utils"),a=(0,u.getGlobal)(),_;function U(e,t){var f;let{client:r}=(0,u.getOhbugObject)(),n=(0,u.parseUrl)((f=a==null?void 0:a.location)==null?void 0:f.href),o=(0,u.parseUrl)(e),s=(0,u.parseUrl)(t);o.path||(o=n),_=t;let i=e,p=t;n.protocol===s.protocol&&n.host===s.host&&(p=s.relative),n.protocol===o.protocol&&n.host===o.host&&(i=o.relative),i!==p&&r.addAction(`navigation to ${t}`,{from:e,to:t},"navigation")}function Y(e){return function(r,n,o){return o&&U(_,String(o)),e.apply(this,[r,n,o])}}var Z,ee,g={pushState:(Z=a==null?void 0:a.history)==null?void 0:Z.pushState,replaceState:(ee=a==null?void 0:a.history)==null?void 0:ee.replaceState,onpopstate:a==null?void 0:a.onpopstate};function ut(){g.pushState=(0,u.replace)(a==null?void 0:a.history,"pushState",Y),g.replaceState=(0,u.replace)(a==null?void 0:a.history,"replaceState",Y),g.onpopstate=(0,u.replace)(a,"onpopstate",e=>function(...r){var o;let n=(o=a==null?void 0:a.location)==null?void 0:o.href;return U(_,n),e==null?void 0:e.apply(this,r)})}function te(e){let{oldURL:t,newURL:r}=e;U(t,r)}function re(){var e;ut(),(e=a==null?void 0:a.addEventListener)==null||e.call(a,"hashchange",te,!0)}function oe(){var e;a.history.pushState=g.pushState,a.history.replaceState=g.replaceState,a.onpopstate=g.onpopstate,(e=a==null?void 0:a.removeEventListener)==null||e.call(a,"hashchange",te,!0)}var x=require("@ohbug/utils"),y=(0,x.getGlobal)();function ne(e){if(e.target){let{client:t}=(0,x.getOhbugObject)(),{tagName:r,id:n,className:o,name:s,src:i,outerHTML:p,nodeType:f}=e.target,D=(0,x.getSelector)(e);t.addAction("click node",{tagName:r,id:n,className:o,name:s,src:i,outerHTML:p,nodeType:f,selector:D},"click")}}function ie(){var e,t;(t=(e=y==null?void 0:y.document)==null?void 0:e.addEventListener)==null||t.call(e,"click",ne)}function ae(){var e,t;(t=(e=y==null?void 0:y.document)==null?void 0:e.removeEventListener)==null||t.call(e,"click",ne)}var C=require("@ohbug/utils"),S=["log","info","warn","error"],se=Object.keys(S).reduce((e,t)=>Q(z({},e),{[t]:console[t]}),{log:null,info:null,warn:null,error:null});function ce(){let{client:e}=(0,C.getOhbugObject)();S.forEach(t=>{se[t]=(0,C.replace)(console,t,r=>function(...o){return o.some(i=>typeof i=="string"&&i.includes("Ohbug"))||e.addAction(`console.${t}`,o,"console"),r.apply(this,o)})})}function A(){console&&S.forEach(e=>{console[e]=se[e]})}var h=require("@ohbug/utils"),ve=require("@ohbug/core");var pe=require("@ohbug/utils"),ue=require("@ohbug/core");function L(e){let{message:t,filename:r,lineno:n,colno:o,error:{stack:s,name:i}}=e,p={name:i,message:t,filename:r,lineno:n,colno:o,stack:s},{client:f}=(0,pe.getOhbugObject)(),D=f.createEvent({category:"error",type:ue.EventTypes.UNCAUGHT_ERROR,detail:p});f.notify(D)}var j=require("@ohbug/utils"),le=require("@ohbug/core");function F(e){let t=e.target||e.srcElement,{outerHTML:r}=t,n=(0,j.getSelector)(e),o={outerHTML:r,src:t&&t.src,tagName:t&&t.tagName,id:t&&t.id,className:t&&t.className,name:t&&t.name,nodeType:t&&t.nodeType,selector:n},{client:s}=(0,j.getOhbugObject)(),i=s.createEvent({category:"error",type:le.EventTypes.RESOURCE_ERROR,detail:o});s.notify(i)}var me=require("@ohbug/utils"),fe=require("@ohbug/core");function B(e){let t={message:e.reason.message||e.reason,stack:e.reason.stack},{client:r}=(0,me.getOhbugObject)(),n=r.createEvent({category:"error",type:fe.EventTypes.UNHANDLEDREJECTION_ERROR,detail:t});r.notify(n)}var de=require("@ohbug/utils"),he=require("@ohbug/core");function O(e){let t=e.message?e:{message:e},{client:r}=(0,de.getOhbugObject)(),n=r.createEvent({category:"error",type:he.EventTypes.UNKNOWN_ERROR,detail:t});r.notify(n)}var Ee=require("@ohbug/utils"),ge=require("@ohbug/core");function N(e){let{client:t}=(0,Ee.getOhbugObject)(),r=t.createEvent({category:"error",type:ge.EventTypes.AJAX_ERROR,detail:e});t.notify(r)}var ye=require("@ohbug/utils"),xe=require("@ohbug/core");function G(e){let{client:t}=(0,ye.getOhbugObject)(),r=t.createEvent({category:"error",type:xe.EventTypes.FETCH_ERROR,detail:e});t.notify(r)}var Oe=require("@ohbug/utils"),be=require("@ohbug/core");function q(e){let{client:t}=(0,Oe.getOhbugObject)(),r=t.createEvent({category:"error",type:be.EventTypes.WEBSOCKET_ERROR,detail:e});t.notify(r)}function k(e){try{let{type:t}=e;if(t==="error"){let r=e,{message:n,error:o}=r,s=e.target||e.srcElement;n&&o?L(r):s&&F(r)}else t==="unhandledrejection"?B(e):O(e)}catch(t){O(t)}}var H=require("@ohbug/core");function d(e,t){try{switch(e){case H.EventTypes.AJAX_ERROR:N(t);break;case H.EventTypes.FETCH_ERROR:G(t);break;case H.EventTypes.WEBSOCKET_ERROR:q(t);break;default:break}}catch(r){O(r)}}var lt=(0,h.getGlobal)(),M="XMLHttpRequest"in lt,b=M?{open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send}:{};function De(){if(!M)return;let{client:e}=(0,h.getOhbugObject)(),t={method:"",url:""},r=XMLHttpRequest==null?void 0:XMLHttpRequest.prototype;b.open=(0,h.replace)(r,"open",n=>function(...s){let[i,p]=s;return t.method=i,t.url=p,n.apply(this,s)}),b.send=(0,h.replace)(r,"send",n=>function(...s){return this.addEventListener("readystatechange",function(){if(this.readyState===4&&t.url!==e.__config.endpoint){let p={req:{url:t.url,method:t.method,data:s[0]||{}},res:{status:this.status,statusText:this.statusText,response:this.response}};e.addAction("ajax",p,"ajax"),(!this.status||this.status>=400)&&d(ve.EventTypes.AJAX_ERROR,p)}}),n.apply(this,s)})}function we(){if(M&&b.open&&b.send){let e=XMLHttpRequest==null?void 0:XMLHttpRequest.prototype;e.open=b.open,e.send=b.send}}var v=require("@ohbug/utils"),P=require("@ohbug/core");var T=(0,v.getGlobal)(),K="fetch"in T,X=K?T.fetch:null;function Re(){if(!K)return;let{client:e}=(0,v.getOhbugObject)();X=(0,v.replace)(T,"fetch",t=>function(...n){return t.apply(this,n).then(o=>{let[s,i]=n,p={req:{url:s,method:i&&i.method,data:i&&i.body||{}},res:{status:o.status,statusText:o.statusText}};return e.addAction("fetch",p,"fetch"),(!o.status||o.status>=400)&&d(P.EventTypes.FETCH_ERROR,p),o},o=>{let[s,i]=n,p={req:{url:s,method:i&&i.method,data:i&&i.body||{}},res:{status:400,statusText:"unknownError"}};throw d(P.EventTypes.FETCH_ERROR,p),o})})}function Ce(){K&&X&&(T.fetch=X)}var je=require("@ohbug/utils"),ke=require("@ohbug/core");var mt=(0,je.getGlobal)();function He(){if(!("WebSocket"in mt))return;let e=WebSocket==null?void 0:WebSocket.prototype,t=Object.getOwnPropertyDescriptor(e,"onerror");Object.defineProperty(e,"onerror",{set(){var o;let r=arguments,n=r[0];(o=t==null?void 0:t.set)==null||o.call(this,function(i){let{target:{url:p,readyState:f,protocol:D,extensions:Ve,binaryType:Ye,bufferedAmount:Ze},timeStamp:et}=i,tt={url:p,timeStamp:et,readyState:f,protocol:D,extensions:Ve,binaryType:Ye,bufferedAmount:Ze};d(ke.EventTypes.WEBSOCKET_ERROR,tt),n.apply(this,r)})}})}var Te=require("@ohbug/utils");var l=(0,Te.getGlobal)();function We(e){k(e)}function _e(){var e;(e=l==null?void 0:l.addEventListener)==null||e.call(l,"error",We,!0)}function Ue(){var e;(e=l==null?void 0:l.removeEventListener)==null||e.call(l,"error",We,!0)}var Se=require("@ohbug/utils");var m=(0,Se.getGlobal)();function Ae(e){k(e)}function Le(){var e;(e=m==null?void 0:m.addEventListener)==null||e.call(m,"unhandledrejection",Ae,!0)}function Fe(){var e;(e=m==null?void 0:m.removeEventListener)==null||e.call(m,"unhandledrejection",Ae,!0)}function ft(){re(),ie()}function Ne(){oe(),ae()}function dt(){De(),Re(),He()}function Ge(){we(),Ce()}function ht(){!(0,Be.getGlobal)().addEventListener||(_e(),Le())}function qe(){Ue(),Fe()}function Me(){ht(),dt(),ft(),ce()}var Pe=require("@ohbug/utils");var w=(0,Pe.getGlobal)();function Xe(){var e;(e=w==null?void 0:w.addEventListener)==null||e.call(w,"unload",()=>{qe(),Ge(),Ne(),A()},!0)}var Je=(0,Ke.defineExtension)({name:"OhbugBrowser",setup:()=>{Me(),Xe()}});var $e=require("@ohbug/utils"),Et=()=>{let e=new WeakSet;return(t,r)=>{if(typeof r=="object"&&r!==null){if(e.has(r))return;e.add(r)}return r}};function Ie(e){let{client:t}=(0,$e.getOhbugObject)(),r=t.__config.endpoint;return new Promise((n,o)=>{let s=JSON.stringify(e,Et());if(navigator.sendBeacon){let i=navigator.sendBeacon(r,s);n(i)}else{let i=new XMLHttpRequest;i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status>=200&&i.status<300)return n(i.response);o(i)}},i.open("POST",r),i.setRequestHeader("Content-Type","application/json;charset=UTF-8"),i.send(s)}})}function gt(e){let t=(0,Qe.getGlobal)(),r={platform:"ohbug-browser",version:W},n=new ze.Client({sdk:r,config:e,device:V,notifier:Ie});return t.__OHBUG__={client:n},n.use(Je),n.__logger.info(`%c @ohbug/browser %c Detected Ohbug v${W} %c`,"background:#333; padding: 2px 1px; color: #FFF","background:#FF6F61; padding: 2px 1px; color: #FFF","background:transparent"),n}var E={__client:null,setup(e){var t;return E.__client?((t=E.__client.__logger)==null||t.warn("init() has been called. Ignored."),E.__client):(E.__client=gt(e),E.__client)}};var yt=E;0&&(module.exports={});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var ke=Object.defineProperty,He=Object.defineProperties;var Te=Object.getOwnPropertyDescriptors;var q=Object.getOwnPropertySymbols;var We=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var M=(e,t,r)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))We.call(t,r)&&M(e,r,t[r]);if(q)for(var r of q(t))_e.call(t,r)&&M(e,r,t[r]);return e},X=(e,t)=>He(e,Te(t));import{Client as vt}from"@ohbug/core";import{getGlobal as Dt}from"@ohbug/utils";var K=()=>{let e={};if(navigator){let{language:t,userAgent:r}=navigator;e.language=t,e.userAgent=r}if(document){let{title:t}=document;e.title=t}if(window.location){let{href:t}=window.location;e.url=t}return e};var w="2.0.1";import{defineExtension as xt}from"@ohbug/core";import{getGlobal as dt}from"@ohbug/utils";import{getGlobal as Ue,getOhbugObject as Se,parseUrl as R,replace as C}from"@ohbug/utils";var a=Ue(),j;function k(e,t){var f;let{client:r}=Se(),o=R((f=a==null?void 0:a.location)==null?void 0:f.href),n=R(e),s=R(t);n.path||(n=o),j=t;let i=e,u=t;o.protocol===s.protocol&&o.host===s.host&&(u=s.relative),o.protocol===n.protocol&&o.host===n.host&&(i=n.relative),i!==u&&r.addAction(`navigation to ${t}`,{from:e,to:t},"navigation")}function J(e){return function(r,o,n){return n&&k(j,String(n)),e.apply(this,[r,o,n])}}var $,I,E={pushState:($=a==null?void 0:a.history)==null?void 0:$.pushState,replaceState:(I=a==null?void 0:a.history)==null?void 0:I.replaceState,onpopstate:a==null?void 0:a.onpopstate};function Ae(){E.pushState=C(a==null?void 0:a.history,"pushState",J),E.replaceState=C(a==null?void 0:a.history,"replaceState",J),E.onpopstate=C(a,"onpopstate",e=>function(...r){var n;let o=(n=a==null?void 0:a.location)==null?void 0:n.href;return k(j,o),e==null?void 0:e.apply(this,r)})}function z(e){let{oldURL:t,newURL:r}=e;k(t,r)}function Q(){var e;Ae(),(e=a==null?void 0:a.addEventListener)==null||e.call(a,"hashchange",z,!0)}function V(){var e;a.history.pushState=E.pushState,a.history.replaceState=E.replaceState,a.onpopstate=E.onpopstate,(e=a==null?void 0:a.removeEventListener)==null||e.call(a,"hashchange",z,!0)}import{getGlobal as Le,getOhbugObject as Fe,getSelector as Be}from"@ohbug/utils";var g=Le();function Y(e){if(e.target){let{client:t}=Fe(),{tagName:r,id:o,className:n,name:s,src:i,outerHTML:u,nodeType:f}=e.target,O=Be(e);t.addAction("click node",{tagName:r,id:o,className:n,name:s,src:i,outerHTML:u,nodeType:f,selector:O},"click")}}function Z(){var e,t;(t=(e=g==null?void 0:g.document)==null?void 0:e.addEventListener)==null||t.call(e,"click",Y)}function ee(){var e,t;(t=(e=g==null?void 0:g.document)==null?void 0:e.removeEventListener)==null||t.call(e,"click",Y)}import{getOhbugObject as Ne,replace as Ge}from"@ohbug/utils";var H=["log","info","warn","error"],te=Object.keys(H).reduce((e,t)=>X(P({},e),{[t]:console[t]}),{log:null,info:null,warn:null,error:null});function re(){let{client:e}=Ne();H.forEach(t=>{te[t]=Ge(console,t,r=>function(...n){return n.some(i=>typeof i=="string"&&i.includes("Ohbug"))||e.addAction(`console.${t}`,n,"console"),r.apply(this,n)})})}function T(){console&&H.forEach(e=>{console[e]=te[e]})}import{getGlobal as rt,getOhbugObject as ot,replace as oe}from"@ohbug/utils";import{EventTypes as nt}from"@ohbug/core";import{getOhbugObject as qe}from"@ohbug/utils";import{EventTypes as Me}from"@ohbug/core";function W(e){let{message:t,filename:r,lineno:o,colno:n,error:{stack:s,name:i}}=e,u={name:i,message:t,filename:r,lineno:o,colno:n,stack:s},{client:f}=qe(),O=f.createEvent({category:"error",type:Me.UNCAUGHT_ERROR,detail:u});f.notify(O)}import{getOhbugObject as Pe,getSelector as Xe}from"@ohbug/utils";import{EventTypes as Ke}from"@ohbug/core";function _(e){let t=e.target||e.srcElement,{outerHTML:r}=t,o=Xe(e),n={outerHTML:r,src:t&&t.src,tagName:t&&t.tagName,id:t&&t.id,className:t&&t.className,name:t&&t.name,nodeType:t&&t.nodeType,selector:o},{client:s}=Pe(),i=s.createEvent({category:"error",type:Ke.RESOURCE_ERROR,detail:n});s.notify(i)}import{getOhbugObject as Je}from"@ohbug/utils";import{EventTypes as $e}from"@ohbug/core";function U(e){let t={message:e.reason.message||e.reason,stack:e.reason.stack},{client:r}=Je(),o=r.createEvent({category:"error",type:$e.UNHANDLEDREJECTION_ERROR,detail:t});r.notify(o)}import{getOhbugObject as Ie}from"@ohbug/utils";import{EventTypes as ze}from"@ohbug/core";function y(e){let t=e.message?e:{message:e},{client:r}=Ie(),o=r.createEvent({category:"error",type:ze.UNKNOWN_ERROR,detail:t});r.notify(o)}import{getOhbugObject as Qe}from"@ohbug/utils";import{EventTypes as Ve}from"@ohbug/core";function S(e){let{client:t}=Qe(),r=t.createEvent({category:"error",type:Ve.AJAX_ERROR,detail:e});t.notify(r)}import{getOhbugObject as Ye}from"@ohbug/utils";import{EventTypes as Ze}from"@ohbug/core";function A(e){let{client:t}=Ye(),r=t.createEvent({category:"error",type:Ze.FETCH_ERROR,detail:e});t.notify(r)}import{getOhbugObject as et}from"@ohbug/utils";import{EventTypes as tt}from"@ohbug/core";function L(e){let{client:t}=et(),r=t.createEvent({category:"error",type:tt.WEBSOCKET_ERROR,detail:e});t.notify(r)}function v(e){try{let{type:t}=e;if(t==="error"){let r=e,{message:o,error:n}=r,s=e.target||e.srcElement;o&&n?W(r):s&&_(r)}else t==="unhandledrejection"?U(e):y(e)}catch(t){y(t)}}import{EventTypes as F}from"@ohbug/core";function d(e,t){try{switch(e){case F.AJAX_ERROR:S(t);break;case F.FETCH_ERROR:A(t);break;case F.WEBSOCKET_ERROR:L(t);break;default:break}}catch(r){y(r)}}var it=rt(),B="XMLHttpRequest"in it,x=B?{open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send}:{};function ne(){if(!B)return;let{client:e}=ot(),t={method:"",url:""},r=XMLHttpRequest==null?void 0:XMLHttpRequest.prototype;x.open=oe(r,"open",o=>function(...s){let[i,u]=s;return t.method=i,t.url=u,o.apply(this,s)}),x.send=oe(r,"send",o=>function(...s){return this.addEventListener("readystatechange",function(){if(this.readyState===4&&t.url!==e.__config.endpoint){let u={req:{url:t.url,method:t.method,data:s[0]||{}},res:{status:this.status,statusText:this.statusText,response:this.response}};e.addAction("ajax",u,"ajax"),(!this.status||this.status>=400)&&d(nt.AJAX_ERROR,u)}}),o.apply(this,s)})}function ie(){if(B&&x.open&&x.send){let e=XMLHttpRequest==null?void 0:XMLHttpRequest.prototype;e.open=x.open,e.send=x.send}}import{getGlobal as at,getOhbugObject as st,replace as ct}from"@ohbug/utils";import{EventTypes as ae}from"@ohbug/core";var D=at(),G="fetch"in D,N=G?D.fetch:null;function se(){if(!G)return;let{client:e}=st();N=ct(D,"fetch",t=>function(...o){return t.apply(this,o).then(n=>{let[s,i]=o,u={req:{url:s,method:i&&i.method,data:i&&i.body||{}},res:{status:n.status,statusText:n.statusText}};return e.addAction("fetch",u,"fetch"),(!n.status||n.status>=400)&&d(ae.FETCH_ERROR,u),n},n=>{let[s,i]=o,u={req:{url:s,method:i&&i.method,data:i&&i.body||{}},res:{status:400,statusText:"unknownError"}};throw d(ae.FETCH_ERROR,u),n})})}function ce(){G&&N&&(D.fetch=N)}import{getGlobal as pt}from"@ohbug/utils";import{EventTypes as ut}from"@ohbug/core";var lt=pt();function pe(){if(!("WebSocket"in lt))return;let e=WebSocket==null?void 0:WebSocket.prototype,t=Object.getOwnPropertyDescriptor(e,"onerror");Object.defineProperty(e,"onerror",{set(){var n;let r=arguments,o=r[0];(n=t==null?void 0:t.set)==null||n.call(this,function(i){let{target:{url:u,readyState:f,protocol:O,extensions:De,binaryType:we,bufferedAmount:Re},timeStamp:Ce}=i,je={url:u,timeStamp:Ce,readyState:f,protocol:O,extensions:De,binaryType:we,bufferedAmount:Re};d(ut.WEBSOCKET_ERROR,je),o.apply(this,r)})}})}import{getGlobal as mt}from"@ohbug/utils";var l=mt();function ue(e){v(e)}function le(){var e;(e=l==null?void 0:l.addEventListener)==null||e.call(l,"error",ue,!0)}function me(){var e;(e=l==null?void 0:l.removeEventListener)==null||e.call(l,"error",ue,!0)}import{getGlobal as ft}from"@ohbug/utils";var m=ft();function fe(e){v(e)}function de(){var e;(e=m==null?void 0:m.addEventListener)==null||e.call(m,"unhandledrejection",fe,!0)}function he(){var e;(e=m==null?void 0:m.removeEventListener)==null||e.call(m,"unhandledrejection",fe,!0)}function ht(){Q(),Z()}function Ee(){V(),ee()}function Et(){ne(),se(),pe()}function ge(){ie(),ce()}function gt(){!dt().addEventListener||(le(),de())}function ye(){me(),he()}function xe(){gt(),Et(),ht(),re()}import{getGlobal as yt}from"@ohbug/utils";var b=yt();function Oe(){var e;(e=b==null?void 0:b.addEventListener)==null||e.call(b,"unload",()=>{ye(),ge(),Ee(),T()},!0)}var be=xt({name:"OhbugBrowser",setup:()=>{xe(),Oe()}});import{getOhbugObject as Ot}from"@ohbug/utils";var bt=()=>{let e=new WeakSet;return(t,r)=>{if(typeof r=="object"&&r!==null){if(e.has(r))return;e.add(r)}return r}};function ve(e){let{client:t}=Ot(),r=t.__config.endpoint;return new Promise((o,n)=>{let s=JSON.stringify(e,bt());if(navigator.sendBeacon){let i=navigator.sendBeacon(r,s);o(i)}else{let i=new XMLHttpRequest;i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status>=200&&i.status<300)return o(i.response);n(i)}},i.open("POST",r),i.setRequestHeader("Content-Type","application/json;charset=UTF-8"),i.send(s)}})}function wt(e){let t=Dt(),r={platform:"ohbug-browser",version:w},o=new vt({sdk:r,config:e,device:K,notifier:ve});return t.__OHBUG__={client:o},o.use(be),o.__logger.info(`%c @ohbug/browser %c Detected Ohbug v${w} %c`,"background:#333; padding: 2px 1px; color: #FFF","background:#FF6F61; padding: 2px 1px; color: #FFF","background:transparent"),o}var h={__client:null,setup(e){var t;return h.__client?((t=h.__client.__logger)==null||t.warn("init() has been called. Ignored."),h.__client):(h.__client=wt(e),h.__client)}};var io=h;export{io as default};
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@ohbug/browser",
3
- "version": "1.0.19",
3
+ "version": "2.0.1",
4
4
  "description": "Ohbug SDK for browsers",
5
+ "license": "Apache-2.0",
5
6
  "author": "chenyueban <jasonchan0527@gmail.com>",
6
7
  "homepage": "https://github.com/ohbug-org/ohbug",
7
8
  "bugs": {
@@ -11,34 +12,30 @@
11
12
  "type": "git",
12
13
  "url": "https://github.com/ohbug-org/ohbug"
13
14
  },
14
- "license": "Apache-2.0",
15
- "main": "./dist/ohbug-browser.umd.js",
16
- "module": "./dist/ohbug-browser.es.js",
17
- "unpkg": "./dist/ohbug-browser.umd.js",
18
- "jsdelivr": "./dist/ohbug-browser.umd.js",
19
- "types": "./dist/index.d.ts",
15
+ "main": "dist/index.js",
16
+ "module": "dist/index.mjs",
17
+ "types": "dist/index.d.ts",
20
18
  "exports": {
21
19
  ".": {
22
- "import": "./dist/ohbug-browser.es.js",
23
- "require": "./dist/ohbug-browser.umd.js"
20
+ "require": "./dist/index.js",
21
+ "import": "./dist/index.mjs",
22
+ "types": "./dist/index.d.ts"
24
23
  }
25
24
  },
26
25
  "files": [
27
26
  "dist"
28
27
  ],
29
- "buildOptions": {
30
- "name": "Ohbug",
31
- "formats": [
32
- "es",
33
- "umd"
34
- ],
35
- "order": 3
36
- },
28
+ "sideEffects": false,
37
29
  "publishConfig": {
38
30
  "access": "public"
39
31
  },
40
32
  "dependencies": {
41
- "@ohbug/core": "^1.1.7"
33
+ "@ohbug/core": "2.0.1",
34
+ "@ohbug/types": "2.0.1",
35
+ "@ohbug/utils": "2.0.1"
42
36
  },
43
- "gitHead": "323e4755a0da5893748c19901f3f709e903b6dd2"
44
- }
37
+ "scripts": {
38
+ "build": "tsup",
39
+ "dev": "tsup --watch"
40
+ }
41
+ }
@@ -1,3 +0,0 @@
1
- export declare function captureClick(): void;
2
- export declare function removeCaptureClick(): void;
3
- //# sourceMappingURL=captureClick.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureClick.d.ts","sourceRoot":"","sources":["../../../../../packages/ohbug-browser/src/capture/action/captureClick.ts"],"names":[],"mappings":"AA4BA,wBAAgB,YAAY,SAE3B;AAED,wBAAgB,kBAAkB,SAEjC"}
@@ -1,3 +0,0 @@
1
- export declare function captureUrlChange(): void;
2
- export declare function removeCaptureUrlChange(): void;
3
- //# sourceMappingURL=captureUrlChange.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureUrlChange.d.ts","sourceRoot":"","sources":["../../../../../packages/ohbug-browser/src/capture/action/captureUrlChange.ts"],"names":[],"mappings":"AAwFA,wBAAgB,gBAAgB,SAK/B;AAED,wBAAgB,sBAAsB,SAOrC"}
@@ -1,3 +0,0 @@
1
- export declare function captureConsole(): void;
2
- export declare function removeCaptureConsole(): void;
3
- //# sourceMappingURL=captureConsole.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureConsole.d.ts","sourceRoot":"","sources":["../../../../../packages/ohbug-browser/src/capture/console/captureConsole.ts"],"names":[],"mappings":"AAoBA,wBAAgB,cAAc,SAkB7B;AAED,wBAAgB,oBAAoB,SAMnC"}
@@ -1,10 +0,0 @@
1
- import { captureConsole, removeCaptureConsole } from './console/captureConsole';
2
- export declare function captureAction(): void;
3
- export declare function removeCaptureAction(): void;
4
- export { captureConsole, removeCaptureConsole };
5
- export declare function captureNetwork(): void;
6
- export declare function removeCaptureNetwork(): void;
7
- export declare function captureScript(): void;
8
- export declare function removeCaptureScript(): void;
9
- export declare function handleCapture(): void;
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/capture/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAmB/E,wBAAgB,aAAa,SAG5B;AACD,wBAAgB,mBAAmB,SAGlC;AAED,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAA;AAE/C,wBAAgB,cAAc,SAI7B;AACD,wBAAgB,oBAAoB,SAGnC;AAED,wBAAgB,aAAa,SAU5B;AACD,wBAAgB,mBAAmB,SAGlC;AAED,wBAAgB,aAAa,SAK5B"}
@@ -1,6 +0,0 @@
1
- /**
2
- * capture AJAX_ERROR
3
- */
4
- export declare function captureAjaxError(): void;
5
- export declare function removeCaptureAjaxError(): void;
6
- //# sourceMappingURL=captureAjaxError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureAjaxError.d.ts","sourceRoot":"","sources":["../../../../../packages/ohbug-browser/src/capture/network/captureAjaxError.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,wBAAgB,gBAAgB,SA2D/B;AAED,wBAAgB,sBAAsB,SAMrC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * capture FETCH_ERROR
3
- */
4
- export declare function captureFetchError(): void;
5
- export declare function removeCaptureFetchError(): void;
6
- //# sourceMappingURL=captureFetchError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureFetchError.d.ts","sourceRoot":"","sources":["../../../../../packages/ohbug-browser/src/capture/network/captureFetchError.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,iBAAiB,SAyChC;AAED,wBAAgB,uBAAuB,SAItC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * capture WEBSOCKET_ERROR
3
- */
4
- export declare function captureWebSocketError(): void;
5
- //# sourceMappingURL=captureWebSocketError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureWebSocketError.d.ts","sourceRoot":"","sources":["../../../../../packages/ohbug-browser/src/capture/network/captureWebSocketError.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,wBAAgB,qBAAqB,SA0CpC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * capture UNCAUGHT_ERROR RESOURCE_ERROR
3
- */
4
- export declare function captureUncaughtError(): void;
5
- export declare function removeCaptureUncaughtError(): void;
6
- //# sourceMappingURL=captureUncaughtError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureUncaughtError.d.ts","sourceRoot":"","sources":["../../../../../packages/ohbug-browser/src/capture/script/captureUncaughtError.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,oBAAoB,SAEnC;AAED,wBAAgB,0BAA0B,SAEzC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * capture UNHANDLEDREJECTION_ERROR
3
- */
4
- export declare function captureUnhandledrejectionError(): void;
5
- export declare function removeCaptureUnhandledrejectionError(): void;
6
- //# sourceMappingURL=captureUnhandledrejectionError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureUnhandledrejectionError.d.ts","sourceRoot":"","sources":["../../../../../packages/ohbug-browser/src/capture/script/captureUnhandledrejectionError.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,8BAA8B,SAE7C;AAED,wBAAgB,oCAAoC,SAEnD"}
package/dist/client.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { OhbugClient, OhbugConfig } from '@ohbug/types';
2
- interface OhbugBrowserClient {
3
- _client: OhbugClient | null;
4
- init: (config: OhbugConfig) => OhbugClient;
5
- }
6
- export declare const BrowserClient: OhbugBrowserClient;
7
- export {};
8
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY,MAAM,cAAc,CAAA;AAUtE,UAAU,kBAAkB;IAC1B,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,WAAW,CAAA;CAC3C;AAsBD,eAAO,MAAM,aAAa,EAAE,kBAW3B,CAAA"}
package/dist/destroy.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function handleDestroy(): void;
2
- //# sourceMappingURL=destroy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAUA,wBAAgB,aAAa,SAW5B"}
package/dist/device.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { OhbugGetDevice } from '@ohbug/types';
2
- export declare const getDevice: OhbugGetDevice;
3
- //# sourceMappingURL=device.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,cAAc,CAAA;AAE/D,eAAO,MAAM,SAAS,EAAE,cAgBvB,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './scriptDispatcher';
2
- export * from './networkDispatcher';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/dispatch/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare function networkDispatcher(type: string, detail: any): void;
2
- //# sourceMappingURL=networkDispatcher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"networkDispatcher.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/dispatch/networkDispatcher.ts"],"names":[],"mappings":"AASA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,QAkB1D"}
@@ -1,2 +0,0 @@
1
- export declare function scriptDispatcher(e: ErrorEvent | PromiseRejectionEvent): void;
2
- //# sourceMappingURL=scriptDispatcher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scriptDispatcher.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/dispatch/scriptDispatcher.ts"],"names":[],"mappings":"AAOA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,UAAU,GAAG,qBAAqB,QAoBrE"}
@@ -1,2 +0,0 @@
1
- export declare const extension: import("@ohbug/types").OhbugExtension<any>;
2
- //# sourceMappingURL=extension.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,4CAMpB,CAAA"}
@@ -1,15 +0,0 @@
1
- import type { OhbugBaseDetail } from '@ohbug/types';
2
- export interface AjaxErrorDetail extends OhbugBaseDetail {
3
- req: {
4
- url: string;
5
- method: string;
6
- data: string | {};
7
- };
8
- res: {
9
- response: string;
10
- status: number;
11
- statusText: string;
12
- };
13
- }
14
- export declare function ajaxErrorHandler(detail: AjaxErrorDetail): void;
15
- //# sourceMappingURL=ajaxErrorHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ajaxErrorHandler.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/handle/ajaxErrorHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,GAAG,EAAE;QACH,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,GAAG,EAAE,CAAA;KAClB,CAAA;IACD,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,QAQvD"}
@@ -1,14 +0,0 @@
1
- import type { OhbugBaseDetail } from '@ohbug/types';
2
- export interface FetchErrorDetail extends OhbugBaseDetail {
3
- req: {
4
- url: string;
5
- method: string;
6
- data: string;
7
- };
8
- res: {
9
- status: number;
10
- statusText: string;
11
- };
12
- }
13
- export declare function fetchErrorHandler(detail: FetchErrorDetail): void;
14
- //# sourceMappingURL=fetchErrorHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchErrorHandler.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/handle/fetchErrorHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,GAAG,EAAE;QACH,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,GAAG,EAAE;QACH,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,QAQzD"}
@@ -1,15 +0,0 @@
1
- export { uncaughtErrorHandler } from './uncaughtErrorHandler';
2
- export { resourceErrorHandler } from './resourceErrorHandler';
3
- export { unhandledrejectionErrorHandler } from './unhandledrejectionErrorHandler';
4
- export { unknownErrorHandler } from './unknownErrorHandler';
5
- export type { UncaughtErrorDetail } from './uncaughtErrorHandler';
6
- export type { ResourceErrorDetail } from './resourceErrorHandler';
7
- export type { UnhandledrejectionErrorDetail } from './unhandledrejectionErrorHandler';
8
- export type { UnknownErrorDetail } from './unknownErrorHandler';
9
- export { ajaxErrorHandler } from './ajaxErrorHandler';
10
- export { fetchErrorHandler } from './fetchErrorHandler';
11
- export { websocketErrorHandler } from './websocketErrorHandler';
12
- export type { AjaxErrorDetail } from './ajaxErrorHandler';
13
- export type { FetchErrorDetail } from './fetchErrorHandler';
14
- export type { WebsocketErrorDetail } from './websocketErrorHandler';
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/handle/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAA;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,YAAY,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAA;AACrF,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -1,13 +0,0 @@
1
- import type { OhbugBaseDetail } from '@ohbug/types';
2
- export interface ResourceErrorDetail extends OhbugBaseDetail {
3
- outerHTML: string;
4
- src: string;
5
- tagName: string;
6
- id: string;
7
- className: string;
8
- name: string;
9
- nodeType: number;
10
- selector: string;
11
- }
12
- export declare function resourceErrorHandler(error: ErrorEvent): void;
13
- //# sourceMappingURL=resourceErrorHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resourceErrorHandler.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/handle/resourceErrorHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IAEZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,QAwBrD"}
@@ -1,10 +0,0 @@
1
- import type { OhbugBaseDetail } from '@ohbug/types';
2
- export interface UncaughtErrorDetail extends OhbugBaseDetail {
3
- name: string;
4
- filename: string;
5
- lineno: number;
6
- colno: number;
7
- stack: string;
8
- }
9
- export declare function uncaughtErrorHandler(error: ErrorEvent): void;
10
- //# sourceMappingURL=uncaughtErrorHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uncaughtErrorHandler.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/handle/uncaughtErrorHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,QAwBrD"}
@@ -1,6 +0,0 @@
1
- import type { OhbugBaseDetail } from '@ohbug/types';
2
- export interface UnhandledrejectionErrorDetail extends OhbugBaseDetail {
3
- stack: string;
4
- }
5
- export declare function unhandledrejectionErrorHandler(error: PromiseRejectionEvent): void;
6
- //# sourceMappingURL=unhandledrejectionErrorHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unhandledrejectionErrorHandler.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/handle/unhandledrejectionErrorHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,MAAM,WAAW,6BAA8B,SAAQ,eAAe;IACpE,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,qBAAqB,QAY1E"}
@@ -1,5 +0,0 @@
1
- import type { OhbugBaseDetail } from '@ohbug/types';
2
- export interface UnknownErrorDetail extends OhbugBaseDetail {
3
- }
4
- export declare function unknownErrorHandler(error: any): void;
5
- //# sourceMappingURL=unknownErrorHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unknownErrorHandler.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/handle/unknownErrorHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,MAAM,WAAW,kBAAmB,SAAQ,eAAe;CAAG;AAE9D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,QAa7C"}
@@ -1,12 +0,0 @@
1
- import type { OhbugBaseDetail } from '@ohbug/types';
2
- export interface WebsocketErrorDetail extends OhbugBaseDetail {
3
- url: string;
4
- timeStamp: number;
5
- readyState: number;
6
- protocol: string;
7
- extensions: string;
8
- binaryType: string;
9
- bufferedAmount: number;
10
- }
11
- export declare function websocketErrorHandler(detail: WebsocketErrorDetail): void;
12
- //# sourceMappingURL=websocketErrorHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"websocketErrorHandler.d.ts","sourceRoot":"","sources":["../../../../packages/ohbug-browser/src/handle/websocketErrorHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,QAQjE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,CAAA;AAClC,eAAe,aAAa,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { OhbugEventWithMethods } from '@ohbug/types';
2
- export declare function notifier<D>(event: OhbugEventWithMethods<D>): Promise<unknown>;
3
- //# sourceMappingURL=notifier.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notifier.d.ts","sourceRoot":"","sources":["../src/notifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAIzD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,oBAuB1D"}
@@ -1,59 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- var e=function(){return(e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function t(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}
16
- /*! *****************************************************************************
17
- Copyright (c) Microsoft Corporation.
18
-
19
- Permission to use, copy, modify, and/or distribute this software for any
20
- purpose with or without fee is hereby granted.
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
23
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
25
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
- PERFORMANCE OF THIS SOFTWARE.
29
- ***************************************************************************** */function n(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}function r(e){return"string"==typeof e}function o(e){return"function"==typeof e}function i(e){return"[object Object]"===Object.prototype.toString.call(e)}var a={apiKey:{defaultValue:void 0,message:"is required",validate:function(e){return Boolean(e)&&r(e)}},appVersion:{defaultValue:void 0,message:"should be a string",validate:function(e){return void 0===e||r(e)}},appType:{defaultValue:void 0,message:"should be a string",validate:function(e){return void 0===e||r(e)}},releaseStage:{defaultValue:"production",message:"should be a string",validate:function(e){return void 0===e||r(e)}},endpoint:{defaultValue:"http://localhost:6660",message:"should be a string",validate:function(e){return void 0===e||r(e)}},maxActions:{defaultValue:30,message:"should be a number between 0 and 100",validate:function(e){return void 0===e||function(e){return"number"==typeof e&&parseInt(""+e,10)===e}(e)&&e>=1&&e<=100}},created:{defaultValue:function(e){return e},message:"should be a function",validate:function(e){return void 0===e||o(e)}},notified:{defaultValue:function(){},message:"should be a function",validate:function(e){return void 0===e||o(e)}},logger:{defaultValue:{log:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,n(["Ohbug"],e))},info:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.info.apply(console,n(["Ohbug"],e))},warn:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,n(["Ohbug"],e))},error:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,n(["Ohbug"],e))}},message:"should be null or an object with methods { log, info, warn, error }",validate:function(e){return void 0===e||e&&["log","info","warn","error"].reduce((function(t,n){return t&&"function"==typeof e[n]}),!0)}},user:{defaultValue:void 0,message:"should be an object and have up to 6 attributes",validate:function(e){return void 0===e||i(e)&&Object.keys(e).length<=6}},metaData:{defaultValue:void 0,message:"should be an object",validate:function(e){return void 0===e||i(e)}}};function u(e,n){for(var r,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];var u=null===(r=e.init)||void 0===r?void 0:r.call.apply(r,t([e,n],i));return n._extensions.push(e),n._hooks.created=function(e,n){var r,i,a=t([n._config.created],n._extensions.filter((function(e){return o(e.created)})).map((function(e){return e.created})));return 0===a.length?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e}(e,n):1===a.length?null===(r=a[0])||void 0===r?void 0:r.call(a,e,n):null===(i=a.reduce((function(e,t){return function(r){return t(e(r,n),n)}})))||void 0===i?void 0:i(e,n)},n._hooks.notified=function(e,n){return t([n._config.notified],n._extensions.filter((function(e){return o(e.notified)})).map((function(e){return e.notified}))).forEach((function(t){return null==t?void 0:t(e,n)}))},u||n}var c=function(e,t,n,r){this.type=n,this.timestamp=r||(new Date).toISOString(),this.message=e,this.data=t};function s(e,t){return new Error("Invalid data\n- "+e+", got "+JSON.stringify(t))}function l(e,t,n){t&&(e[t]=n)}function f(e,t){if(e[t])return e[t]}function d(e,t){if(e[t])return delete e[t]}var p=function(){function t(e,t){var n=e.apiKey,r=e.appVersion,o=e.appType,i=e.releaseStage,a=e.timestamp,u=e.category,c=e.type,s=e.sdk,l=e.detail,f=e.device,d=e.user,p=e.actions,v=e.metaData;this.apiKey=n,this.appVersion=r,this.appType=o,this.releaseStage=i,this.timestamp=a,this.category=u,this.type=c,this.sdk=s,this.detail=l,this.device=f,this.user=d,this.actions=p,this.metaData=v,this._client=t}return Object.defineProperty(t.prototype,"_isOhbugEvent",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.addAction=function(e,t,n,o){var i,a,u=this.actions,s=r(e)?e:"",l=t||{},f=r(n)?n:"",d=new c(s,l,f,o);u.length>=(null!==(a=null===(i=this._client)||void 0===i?void 0:i._config.maxActions)&&void 0!==a?a:30)&&u.shift(),u.push(d)},t.prototype.getUser=function(){return this.user},t.prototype.setUser=function(t){var n;if(i(t)&&Object.keys(t).length<=6)return this.user=e(e({},this.user),t),this.getUser();null===(n=this._client)||void 0===n||n._logger.warn(s("setUser should be an object and have up to 6 attributes",t))},t.prototype.addMetaData=function(e,t){return l(this.metaData,e,t)},t.prototype.getMetaData=function(e){return f(this.metaData,e)},t.prototype.deleteMetaData=function(e){return d(this.metaData,e)},t.prototype.toJSON=function(){var e=this;return{apiKey:e.apiKey,appVersion:e.appVersion,appType:e.appType,timestamp:e.timestamp,category:e.category,type:e.type,sdk:e.sdk,device:e.device,detail:e.detail,user:e.user,actions:e.actions,metaData:e.metaData,releaseStage:e.releaseStage}},t}();var v=function(){function n(e){var t=this,n=e.sdk,r=e.config,o=e.schema,u=void 0===o?a:o,c=e.device,s=e.notifier,l=function(e,t){return Object.keys(t).reduce((function(n,r){var o=e[r],i=t[r],a=i.defaultValue,u=i.message,c=i.validate;return void 0!==o?c(o)?n.config[r]=o:(n.config[r]=a,n.errors[r]=u):n.config[r]=a,n}),{config:{},errors:{}})}(r,u),f=l.config,d=l.errors;this._sdk=n,this._config=f,this._logger=f.logger,this._device=c,this._notifier=s,this._extensions=[],this._hooks={created:f.created,notified:f.notified},this._actions=[],this._user=f.user,this._metaData={},i(f.metaData)&&Object.keys(f.metaData).forEach((function(e){t.addMetaData(e,f.metaData[e])})),Object.keys(d).length&&this._logger.warn(function(e,t){return new Error("Invalid configuration\n"+Object.keys(e).map((function(n){return"- "+n+" "+e[n]+", got "+JSON.stringify(t[n])})).join("\n")+"\n ")}(d,r))}return n.prototype.use=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return u.apply(void 0,t([e,this],n))},n.prototype.createEvent=function(e){var t,n,r,a,u,c,s,l,f,d,v,h,g=(t=e,s=(c=(n=this)._config).apiKey,l=c.appVersion,f=c.appType,d=c.releaseStage,v=(new Date).toISOString(),h=n._device(n),i(t)&&Object.prototype.hasOwnProperty.call(t,"type")&&Object.prototype.hasOwnProperty.call(t,"detail")?(r=t.category||"error",a=t.type,u=t.detail):(r="error",a="unknownError",u=t),new p({apiKey:s,appVersion:l,appType:f,timestamp:v,category:r,type:a,sdk:n._sdk,device:h,user:n._user,detail:u,actions:n._actions,metaData:n._metaData,releaseStage:d},n));return o(this._hooks.created)?this._hooks.created(g,this):g},n.prototype.notify=function(e,t){var n;return n=Boolean(e)&&!function(e){return Boolean(null==e?void 0:e._isOhbugEvent)}(e)?this.createEvent(e):e,t&&(n=t(n)),function(e,t){return function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function(){var n,r;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),n=null,e?[4,t._notifier(e)]:[3,2];case 1:n=i.sent(),i.label=2;case 2:return o(t._hooks.notified)&&t._hooks.notified(e,t),[2,n];case 3:return r=i.sent(),t._logger.error(r),[3,4];case 4:return[2]}}))}))}(n,this)},n.prototype.addAction=function(e,t,n,o){var i=this._actions,a=r(e)?e:"",u=t||{},s=r(n)?n:"",l=new c(a,u,s,o);i.length>=this._config.maxActions&&i.shift(),i.push(l)},n.prototype.getUser=function(){return this._user},n.prototype.setUser=function(t){if(i(t)&&Object.keys(t).length<=6)return this._user=e(e({},this._user),t),this.getUser();this._logger.warn(s("setUser should be an object and have up to 6 attributes",t))},n.prototype.addMetaData=function(e,t){return l(this._metaData,e,t)},n.prototype.getMetaData=function(e){return f(this._metaData,e)},n.prototype.deleteMetaData=function(e){return d(this._metaData,e)},n}(),h="ajaxError",g="fetchError",y="websocketError";
30
- /*! *****************************************************************************
31
- Copyright (c) Microsoft Corporation.
32
-
33
- Permission to use, copy, modify, and/or distribute this software for any
34
- purpose with or without fee is hereby granted.
35
-
36
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
37
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
38
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
39
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
40
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
41
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
42
- PERFORMANCE OF THIS SOFTWARE.
43
- ***************************************************************************** */
44
- function m(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}Object.freeze({__proto__:null,UNCAUGHT_ERROR:"uncaughtError",RESOURCE_ERROR:"resourceError",UNHANDLEDREJECTION_ERROR:"unhandledrejectionError",AJAX_ERROR:"ajaxError",FETCH_ERROR:"fetchError",WEBSOCKET_ERROR:"websocketError",UNKNOWN_ERROR:"unknownError",MESSAGE:"message",FEEDBACK:"feedback",VIEW:"view",REACT:"react",VUE:"vue",ANGULAR:"angular",MINIAPP_ERROR:"miniappError",MINIAPP_UNHANDLEDREJECTION_ERROR:"miniappUnhandledrejectionError",MINIAPP_PAGENOTFOUND_ERROR:"miniappPagenotfoundError",MINIAPP_MEMORYWARNING_ERROR:"miniappMemorywarningError"});var b=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,m(["Ohbug"],e))};function E(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];try{if("production"!==process.env.NODE_ENV){if(void 0===t)throw new Error("`Ohbug warning(condition, format, ...args)` requires a warning message argument");if(!e){var o=0,i=t.replace(/%s/g,(function(){return n[o++]}));b(i)}}}catch(e){}}var _={};function O(){return"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:_}function w(){var e=O();return function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(void 0===t)throw new Error("`Ohbug warning(condition, format, ...args)` requires a warning message argument");if(!e){var o=0,i=t.replace(/%s/g,(function(){return n[o++]}));throw new Error("Ohbug "+i)}}(Boolean(e.__OHBUG__),"Failed to get `OhbugObject`, please confirm if `Ohbug.init`"),e.__OHBUG__}function R(e,t,n){if(t in e){var r=e[t],o=n(r);return e[t]=o,r}}function k(e){if("string"!=typeof e)return{};var t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};var n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],relative:t[5]+n+r}}function S(e,t){e.parentNode&&(t.push(e.parentNode),S(e.parentNode,t))}function N(e){var t=[];return t.push(e),S(e,t),t}var j,D,T,L=function(e){for(var t=e.target||e.srcElement,n=e.target||e.srcElement,r=[],o=0;n&&n.nodeType===Node.ELEMENT_NODE&&n.nodeType!==Node.DOCUMENT_TYPE_NODE;n=n.previousSibling)o&&r.push(n),o+=1;var i=void 0===e.path?N(e.target):e.path,a=t.outerHTML;return i.reverse().map((function(e){return(e.localName||"")+(e.id?"#"+e.id:"")+(e.className?"."+e.className:"")+(e.outerHTML===a?":nth-child("+r.length+")":"")})).filter((function(e){return Boolean(e)})).join(" > ")},M=function(){var e={};if(navigator){var t=navigator.language,n=navigator.userAgent;e.language=t,e.userAgent=n}if(document){var r=document.title;e.title=r}if(window.location){var o=window.location.href;e.url=o}return e},A=O();function x(e,t){var n,r=w().client,o=k(null===(n=null==A?void 0:A.location)||void 0===n?void 0:n.href),i=k(e),a=k(t);i.path||(i=o),T=t;var u=e,c=t;o.protocol===a.protocol&&o.host===a.host&&(c=a.relative),o.protocol===i.protocol&&o.host===i.host&&(u=i.relative),u!==c&&r.addAction("navigation to "+t,{from:e,to:t},"navigation")}function H(e){return function(t,n,r){return r&&x(T,String(r)),e.apply(this,[t,n,r])}}var U={pushState:null===(j=null==A?void 0:A.history)||void 0===j?void 0:j.pushState,replaceState:null===(D=null==A?void 0:A.history)||void 0===D?void 0:D.replaceState,onpopstate:null==A?void 0:A.onpopstate};function V(e){var t=e;x(t.oldURL,t.newURL)}function P(){var e;U.pushState=R(null==A?void 0:A.history,"pushState",H),U.replaceState=R(null==A?void 0:A.history,"replaceState",H),U.onpopstate=R(A,"onpopstate",(function(e){return function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=null===(t=null==A?void 0:A.location)||void 0===t?void 0:t.href;return x(T,o),e.apply(this,n)}})),null===(e=null==A?void 0:A.addEventListener)||void 0===e||e.call(A,"hashchange",V,!0)}var q=O();function B(e){if(e.target){var t=w().client,n=e.target,r=n.tagName,o=n.id,i=n.className,a=n.name,u=n.src,c=n.outerHTML,s=n.nodeType,l=L(e);t.addAction("click node",{tagName:r,id:o,className:i,name:a,src:u,outerHTML:c,nodeType:s,selector:l},"click")}}
45
- /*! *****************************************************************************
46
- Copyright (c) Microsoft Corporation.
47
-
48
- Permission to use, copy, modify, and/or distribute this software for any
49
- purpose with or without fee is hereby granted.
50
-
51
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
52
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
53
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
54
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
55
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
56
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
57
- PERFORMANCE OF THIS SOFTWARE.
58
- ***************************************************************************** */
59
- var I=function(){return(I=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},F=["log","info","warn","error"],X=Object.keys(F).reduce((function(e,t){var n;return I(I({},e),((n={})[t]=console[t],n))}),{log:null,info:null,warn:null,error:null});function C(e){var t=e.message?e:{message:e},n=w().client,r=n.createEvent({category:"error",type:"unknownError",detail:t});n.notify(r)}function W(e){try{var t=e.type;if("error"===t){var n=e,r=n.message,o=n.error,i=e.target||e.srcElement;r&&o?function(e){var t=e.message,n=e.filename,r=e.lineno,o=e.colno,i=e.error,a=i.stack,u={name:i.name,message:t,filename:n,lineno:r,colno:o,stack:a},c=w().client,s=c.createEvent({category:"error",type:"uncaughtError",detail:u});c.notify(s)}(n):i&&function(e){var t=e.target||e.srcElement,n=t.outerHTML,r=L(e),o={outerHTML:n,src:t&&t.src,tagName:t&&t.tagName,id:t&&t.id,className:t&&t.className,name:t&&t.name,nodeType:t&&t.nodeType,selector:r},i=w().client,a=i.createEvent({category:"error",type:"resourceError",detail:o});i.notify(a)}(n)}else"unhandledrejection"===t?function(e){var t={message:e.reason.message||e.reason,stack:e.reason.stack},n=w().client,r=n.createEvent({category:"error",type:"unhandledrejectionError",detail:t});n.notify(r)}(e):C(e)}catch(o){C(o)}}function K(e,t){try{switch(e){case h:!function(e){var t=w().client,n=t.createEvent({category:"error",type:h,detail:e});t.notify(n)}(t);break;case g:!function(e){var t=w().client,n=t.createEvent({category:"error",type:g,detail:e});t.notify(n)}(t);break;case y:!function(e){var t=w().client,n=t.createEvent({category:"error",type:y,detail:e});t.notify(n)}(t)}}catch(e){C(e)}}var G="XMLHttpRequest"in O(),J=G?{open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send}:{};var Y=O(),z="fetch"in Y,$=z?Y.fetch:null;var Q=O();var Z=O();function ee(e){W(e)}var te=O();function ne(e){W(e)}function re(){P(),function(){var e,t;null===(t=null===(e=null==q?void 0:q.document)||void 0===e?void 0:e.addEventListener)||void 0===t||t.call(e,"click",B)}()}function oe(){!function(){var e;A.history.pushState=U.pushState,A.history.replaceState=U.replaceState,A.onpopstate=U.onpopstate,null===(e=null==A?void 0:A.removeEventListener)||void 0===e||e.call(A,"hashchange",V,!0)}(),function(){var e,t;null===(t=null===(e=null==q?void 0:q.document)||void 0===e?void 0:e.removeEventListener)||void 0===t||t.call(e,"click",B)}()}function ie(){!function(){if(E(G,"Binding `AJAX` monitoring failed, the current environment did not find the object `XMLHttpRequest`"),G){var e=w().client,t={method:"",url:""},n=null===XMLHttpRequest||void 0===XMLHttpRequest?void 0:XMLHttpRequest.prototype;J.open=R(n,"open",(function(e){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=n[0],i=n[1];return t.method=o,t.url=i,e.apply(this,n)}})),J.send=R(n,"send",(function(n){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return this.addEventListener("readystatechange",(function(){if(4===this.readyState&&t.url!==e._config.endpoint){var n={req:{url:t.url,method:t.method,data:r[0]||{}},res:{status:this.status,statusText:this.statusText,response:this.response}};e.addAction("ajax",n,"ajax"),(!this.status||this.status>=400)&&K(h,n)}})),n.apply(this,r)}}))}}(),function(){if(E(z,"Binding `fetch` monitoring failed, the current environment did not find the object `fetch`"),z){var e=w().client;$=R(Y,"fetch",(function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t.apply(this,n).then((function(t){var r=n[0],o=n[1],i={req:{url:r,method:o&&o.method,data:o&&o.body||{}},res:{status:t.status,statusText:t.statusText}};return e.addAction("fetch",i,"fetch"),(!t.status||t.status>=400)&&K(g,i),t})).catch((function(e){K(g,e)}))}}))}}(),function(){if(E("WebSocket"in Q,"Binding `WebSocket` monitoring failed, the current environment did not find the object `WebSocket`"),"WebSocket"in Q){var e=null===WebSocket||void 0===WebSocket?void 0:WebSocket.prototype,t=Object.getOwnPropertyDescriptor(e,"onerror");Object.defineProperty(e,"onerror",{set:function(){var e,n=arguments[0];null===(e=null==t?void 0:t.set)||void 0===e||e.call(this,(function(e){var t=e.target,r=t.url,o=t.readyState,i=t.protocol,a=t.extensions,u=t.binaryType,c=t.bufferedAmount,s=e.timeStamp;K(y,{url:r,timeStamp:s,readyState:o,protocol:i,extensions:a,binaryType:u,bufferedAmount:c}),n.apply(this,arguments)}))}})}}()}function ae(){!function(){if(G&&J.open&&J.send){var e=null===XMLHttpRequest||void 0===XMLHttpRequest?void 0:XMLHttpRequest.prototype;e.open=J.open,e.send=J.send}}(),z&&$&&(Y.fetch=$)}function ue(){var e=O();E(Boolean(e.addEventListener),"Binding script monitoring failed, the current environment did not find the object `addEventListener`"),e.addEventListener&&(function(){var e;null===(e=null==Z?void 0:Z.addEventListener)||void 0===e||e.call(Z,"error",ee,!0)}(),function(){var e;null===(e=null==te?void 0:te.addEventListener)||void 0===e||e.call(te,"unhandledrejection",ne,!0)}())}function ce(){!function(){var e;null===(e=null==Z?void 0:Z.removeEventListener)||void 0===e||e.call(Z,"error",ee,!0)}(),function(){var e;null===(e=null==te?void 0:te.removeEventListener)||void 0===e||e.call(te,"unhandledrejection",ne,!0)}()}function se(){var e;ue(),ie(),re(),e=w().client,F.forEach((function(t){X[t]=R(console,t,(function(n){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return r.some((function(e){return"string"==typeof e&&e.includes("Ohbug")}))||e.addAction("console."+t,r,"console"),n.apply(this,r)}}))}))}var le=O();function fe(){var e;null===(e=null==le?void 0:le.addEventListener)||void 0===e||e.call(le,"unload",(function(){ce(),ae(),oe(),console&&F.forEach((function(e){console[e]=X[e]}))}),!0)}var de={name:"OhbugBrowser",init:function(){se(),fe()}};function pe(e){var t=w().client._config.endpoint;return new Promise((function(n,r){var o=JSON.stringify(e);if(navigator.sendBeacon){var i=navigator.sendBeacon(t,o);n(i)}else{var a=new XMLHttpRequest;a.onreadystatechange=function(){if(a.readyState===XMLHttpRequest.DONE){if(a.status>=200&&a.status<300)return n(a.response);r(a)}},a.open("POST",t),a.setRequestHeader("Content-Type","application/json;charset=UTF-8"),a.send(o)}}))}var ve={_client:null,init:function(e){var t;return ve._client?(null===(t=ve._client._logger)||void 0===t||t.log("init() has been called. Ignored."),ve._client):(ve._client=function(e){var t=O(),n=new v({sdk:{platform:"ohbug-browser",version:"1.0.19"},config:e,device:M,notifier:pe});return t.__OHBUG__={client:n},n.use(de),console.log("%c @ohbug/browser %c Detected Ohbug v1.0.19 %c","background:#333; padding: 2px 1px; color: #FFF","background:#FF6F61; padding: 2px 1px; color: #FFF","background:transparent"),n}(e),ve._client)}};export{ve as Client,ve as default};
@@ -1,59 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ohbug={})}(this,(function(e){"use strict";
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function n(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}
16
- /*! *****************************************************************************
17
- Copyright (c) Microsoft Corporation.
18
-
19
- Permission to use, copy, modify, and/or distribute this software for any
20
- purpose with or without fee is hereby granted.
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
23
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
25
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
- PERFORMANCE OF THIS SOFTWARE.
29
- ***************************************************************************** */function r(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}function o(e){return"string"==typeof e}function i(e){return"function"==typeof e}function a(e){return"[object Object]"===Object.prototype.toString.call(e)}var u={apiKey:{defaultValue:void 0,message:"is required",validate:function(e){return Boolean(e)&&o(e)}},appVersion:{defaultValue:void 0,message:"should be a string",validate:function(e){return void 0===e||o(e)}},appType:{defaultValue:void 0,message:"should be a string",validate:function(e){return void 0===e||o(e)}},releaseStage:{defaultValue:"production",message:"should be a string",validate:function(e){return void 0===e||o(e)}},endpoint:{defaultValue:"http://localhost:6660",message:"should be a string",validate:function(e){return void 0===e||o(e)}},maxActions:{defaultValue:30,message:"should be a number between 0 and 100",validate:function(e){return void 0===e||function(e){return"number"==typeof e&&parseInt(""+e,10)===e}(e)&&e>=1&&e<=100}},created:{defaultValue:function(e){return e},message:"should be a function",validate:function(e){return void 0===e||i(e)}},notified:{defaultValue:function(){},message:"should be a function",validate:function(e){return void 0===e||i(e)}},logger:{defaultValue:{log:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,r(["Ohbug"],e))},info:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.info.apply(console,r(["Ohbug"],e))},warn:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,r(["Ohbug"],e))},error:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,r(["Ohbug"],e))}},message:"should be null or an object with methods { log, info, warn, error }",validate:function(e){return void 0===e||e&&["log","info","warn","error"].reduce((function(t,n){return t&&"function"==typeof e[n]}),!0)}},user:{defaultValue:void 0,message:"should be an object and have up to 6 attributes",validate:function(e){return void 0===e||a(e)&&Object.keys(e).length<=6}},metaData:{defaultValue:void 0,message:"should be an object",validate:function(e){return void 0===e||a(e)}}};function c(e,t){for(var r,o=[],a=2;a<arguments.length;a++)o[a-2]=arguments[a];var u=null===(r=e.init)||void 0===r?void 0:r.call.apply(r,n([e,t],o));return t._extensions.push(e),t._hooks.created=function(e,t){var r,o,a=n([t._config.created],t._extensions.filter((function(e){return i(e.created)})).map((function(e){return e.created})));return 0===a.length?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e}(e,t):1===a.length?null===(r=a[0])||void 0===r?void 0:r.call(a,e,t):null===(o=a.reduce((function(e,n){return function(r){return n(e(r,t),t)}})))||void 0===o?void 0:o(e,t)},t._hooks.notified=function(e,t){return n([t._config.notified],t._extensions.filter((function(e){return i(e.notified)})).map((function(e){return e.notified}))).forEach((function(n){return null==n?void 0:n(e,t)}))},u||t}var s=function(e,t,n,r){this.type=n,this.timestamp=r||(new Date).toISOString(),this.message=e,this.data=t};function l(e,t){return new Error("Invalid data\n- "+e+", got "+JSON.stringify(t))}function f(e,t,n){t&&(e[t]=n)}function d(e,t){if(e[t])return e[t]}function p(e,t){if(e[t])return delete e[t]}var v=function(){function e(e,t){var n=e.apiKey,r=e.appVersion,o=e.appType,i=e.releaseStage,a=e.timestamp,u=e.category,c=e.type,s=e.sdk,l=e.detail,f=e.device,d=e.user,p=e.actions,v=e.metaData;this.apiKey=n,this.appVersion=r,this.appType=o,this.releaseStage=i,this.timestamp=a,this.category=u,this.type=c,this.sdk=s,this.detail=l,this.device=f,this.user=d,this.actions=p,this.metaData=v,this._client=t}return Object.defineProperty(e.prototype,"_isOhbugEvent",{get:function(){return!0},enumerable:!1,configurable:!0}),e.prototype.addAction=function(e,t,n,r){var i,a,u=this.actions,c=o(e)?e:"",l=t||{},f=o(n)?n:"",d=new s(c,l,f,r);u.length>=(null!==(a=null===(i=this._client)||void 0===i?void 0:i._config.maxActions)&&void 0!==a?a:30)&&u.shift(),u.push(d)},e.prototype.getUser=function(){return this.user},e.prototype.setUser=function(e){var n;if(a(e)&&Object.keys(e).length<=6)return this.user=t(t({},this.user),e),this.getUser();null===(n=this._client)||void 0===n||n._logger.warn(l("setUser should be an object and have up to 6 attributes",e))},e.prototype.addMetaData=function(e,t){return f(this.metaData,e,t)},e.prototype.getMetaData=function(e){return d(this.metaData,e)},e.prototype.deleteMetaData=function(e){return p(this.metaData,e)},e.prototype.toJSON=function(){var e=this;return{apiKey:e.apiKey,appVersion:e.appVersion,appType:e.appType,timestamp:e.timestamp,category:e.category,type:e.type,sdk:e.sdk,device:e.device,detail:e.detail,user:e.user,actions:e.actions,metaData:e.metaData,releaseStage:e.releaseStage}},e}();var h=function(){function e(e){var t=this,n=e.sdk,r=e.config,o=e.schema,i=void 0===o?u:o,c=e.device,s=e.notifier,l=function(e,t){return Object.keys(t).reduce((function(n,r){var o=e[r],i=t[r],a=i.defaultValue,u=i.message,c=i.validate;return void 0!==o?c(o)?n.config[r]=o:(n.config[r]=a,n.errors[r]=u):n.config[r]=a,n}),{config:{},errors:{}})}(r,i),f=l.config,d=l.errors;this._sdk=n,this._config=f,this._logger=f.logger,this._device=c,this._notifier=s,this._extensions=[],this._hooks={created:f.created,notified:f.notified},this._actions=[],this._user=f.user,this._metaData={},a(f.metaData)&&Object.keys(f.metaData).forEach((function(e){t.addMetaData(e,f.metaData[e])})),Object.keys(d).length&&this._logger.warn(function(e,t){return new Error("Invalid configuration\n"+Object.keys(e).map((function(n){return"- "+n+" "+e[n]+", got "+JSON.stringify(t[n])})).join("\n")+"\n ")}(d,r))}return e.prototype.use=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return c.apply(void 0,n([e,this],t))},e.prototype.createEvent=function(e){var t,n,r,o,u,c,s,l,f,d,p,h,g=(t=e,s=(c=(n=this)._config).apiKey,l=c.appVersion,f=c.appType,d=c.releaseStage,p=(new Date).toISOString(),h=n._device(n),a(t)&&Object.prototype.hasOwnProperty.call(t,"type")&&Object.prototype.hasOwnProperty.call(t,"detail")?(r=t.category||"error",o=t.type,u=t.detail):(r="error",o="unknownError",u=t),new v({apiKey:s,appVersion:l,appType:f,timestamp:p,category:r,type:o,sdk:n._sdk,device:h,user:n._user,detail:u,actions:n._actions,metaData:n._metaData,releaseStage:d},n));return i(this._hooks.created)?this._hooks.created(g,this):g},e.prototype.notify=function(e,t){var n;return n=Boolean(e)&&!function(e){return Boolean(null==e?void 0:e._isOhbugEvent)}(e)?this.createEvent(e):e,t&&(n=t(n)),function(e,t){return function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function(){var n,r;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),n=null,e?[4,t._notifier(e)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return i(t._hooks.notified)&&t._hooks.notified(e,t),[2,n];case 3:return r=o.sent(),t._logger.error(r),[3,4];case 4:return[2]}}))}))}(n,this)},e.prototype.addAction=function(e,t,n,r){var i=this._actions,a=o(e)?e:"",u=t||{},c=o(n)?n:"",l=new s(a,u,c,r);i.length>=this._config.maxActions&&i.shift(),i.push(l)},e.prototype.getUser=function(){return this._user},e.prototype.setUser=function(e){if(a(e)&&Object.keys(e).length<=6)return this._user=t(t({},this._user),e),this.getUser();this._logger.warn(l("setUser should be an object and have up to 6 attributes",e))},e.prototype.addMetaData=function(e,t){return f(this._metaData,e,t)},e.prototype.getMetaData=function(e){return d(this._metaData,e)},e.prototype.deleteMetaData=function(e){return p(this._metaData,e)},e}(),g="ajaxError",y="fetchError",m="websocketError";
30
- /*! *****************************************************************************
31
- Copyright (c) Microsoft Corporation.
32
-
33
- Permission to use, copy, modify, and/or distribute this software for any
34
- purpose with or without fee is hereby granted.
35
-
36
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
37
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
38
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
39
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
40
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
41
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
42
- PERFORMANCE OF THIS SOFTWARE.
43
- ***************************************************************************** */
44
- function b(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}Object.freeze({__proto__:null,UNCAUGHT_ERROR:"uncaughtError",RESOURCE_ERROR:"resourceError",UNHANDLEDREJECTION_ERROR:"unhandledrejectionError",AJAX_ERROR:"ajaxError",FETCH_ERROR:"fetchError",WEBSOCKET_ERROR:"websocketError",UNKNOWN_ERROR:"unknownError",MESSAGE:"message",FEEDBACK:"feedback",VIEW:"view",REACT:"react",VUE:"vue",ANGULAR:"angular",MINIAPP_ERROR:"miniappError",MINIAPP_UNHANDLEDREJECTION_ERROR:"miniappUnhandledrejectionError",MINIAPP_PAGENOTFOUND_ERROR:"miniappPagenotfoundError",MINIAPP_MEMORYWARNING_ERROR:"miniappMemorywarningError"});var E=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,b(["Ohbug"],e))};function _(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];try{if("production"!==process.env.NODE_ENV){if(void 0===t)throw new Error("`Ohbug warning(condition, format, ...args)` requires a warning message argument");if(!e){var o=0,i=t.replace(/%s/g,(function(){return n[o++]}));E(i)}}}catch(e){}}var O={};function w(){return"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:O}function R(){var e=w();return function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(void 0===t)throw new Error("`Ohbug warning(condition, format, ...args)` requires a warning message argument");if(!e){var o=0,i=t.replace(/%s/g,(function(){return n[o++]}));throw new Error("Ohbug "+i)}}(Boolean(e.__OHBUG__),"Failed to get `OhbugObject`, please confirm if `Ohbug.init`"),e.__OHBUG__}function k(e,t,n){if(t in e){var r=e[t],o=n(r);return e[t]=o,r}}function S(e){if("string"!=typeof e)return{};var t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};var n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],relative:t[5]+n+r}}function j(e,t){e.parentNode&&(t.push(e.parentNode),j(e.parentNode,t))}function N(e){var t=[];return t.push(e),j(e,t),t}var T,D,L,M=function(e){for(var t=e.target||e.srcElement,n=e.target||e.srcElement,r=[],o=0;n&&n.nodeType===Node.ELEMENT_NODE&&n.nodeType!==Node.DOCUMENT_TYPE_NODE;n=n.previousSibling)o&&r.push(n),o+=1;var i=void 0===e.path?N(e.target):e.path,a=t.outerHTML;return i.reverse().map((function(e){return(e.localName||"")+(e.id?"#"+e.id:"")+(e.className?"."+e.className:"")+(e.outerHTML===a?":nth-child("+r.length+")":"")})).filter((function(e){return Boolean(e)})).join(" > ")},A=function(){var e={};if(navigator){var t=navigator.language,n=navigator.userAgent;e.language=t,e.userAgent=n}if(document){var r=document.title;e.title=r}if(window.location){var o=window.location.href;e.url=o}return e},x="1.0.19",H=w();function U(e,t){var n,r=R().client,o=S(null===(n=null==H?void 0:H.location)||void 0===n?void 0:n.href),i=S(e),a=S(t);i.path||(i=o),L=t;var u=e,c=t;o.protocol===a.protocol&&o.host===a.host&&(c=a.relative),o.protocol===i.protocol&&o.host===i.host&&(u=i.relative),u!==c&&r.addAction("navigation to "+t,{from:e,to:t},"navigation")}function P(e){return function(t,n,r){return r&&U(L,String(r)),e.apply(this,[t,n,r])}}var V={pushState:null===(T=null==H?void 0:H.history)||void 0===T?void 0:T.pushState,replaceState:null===(D=null==H?void 0:H.history)||void 0===D?void 0:D.replaceState,onpopstate:null==H?void 0:H.onpopstate};function q(e){var t=e;U(t.oldURL,t.newURL)}function B(){var e;V.pushState=k(null==H?void 0:H.history,"pushState",P),V.replaceState=k(null==H?void 0:H.history,"replaceState",P),V.onpopstate=k(H,"onpopstate",(function(e){return function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=null===(t=null==H?void 0:H.location)||void 0===t?void 0:t.href;return U(L,o),e.apply(this,n)}})),null===(e=null==H?void 0:H.addEventListener)||void 0===e||e.call(H,"hashchange",q,!0)}var I=w();function F(e){if(e.target){var t=R().client,n=e.target,r=n.tagName,o=n.id,i=n.className,a=n.name,u=n.src,c=n.outerHTML,s=n.nodeType,l=M(e);t.addAction("click node",{tagName:r,id:o,className:i,name:a,src:u,outerHTML:c,nodeType:s,selector:l},"click")}}
45
- /*! *****************************************************************************
46
- Copyright (c) Microsoft Corporation.
47
-
48
- Permission to use, copy, modify, and/or distribute this software for any
49
- purpose with or without fee is hereby granted.
50
-
51
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
52
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
53
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
54
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
55
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
56
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
57
- PERFORMANCE OF THIS SOFTWARE.
58
- ***************************************************************************** */
59
- var X=function(){return(X=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},C=["log","info","warn","error"],W=Object.keys(C).reduce((function(e,t){var n;return X(X({},e),((n={})[t]=console[t],n))}),{log:null,info:null,warn:null,error:null});function K(e){var t=e.message?e:{message:e},n=R().client,r=n.createEvent({category:"error",type:"unknownError",detail:t});n.notify(r)}function G(e){try{var t=e.type;if("error"===t){var n=e,r=n.message,o=n.error,i=e.target||e.srcElement;r&&o?function(e){var t=e.message,n=e.filename,r=e.lineno,o=e.colno,i=e.error,a=i.stack,u={name:i.name,message:t,filename:n,lineno:r,colno:o,stack:a},c=R().client,s=c.createEvent({category:"error",type:"uncaughtError",detail:u});c.notify(s)}(n):i&&function(e){var t=e.target||e.srcElement,n=t.outerHTML,r=M(e),o={outerHTML:n,src:t&&t.src,tagName:t&&t.tagName,id:t&&t.id,className:t&&t.className,name:t&&t.name,nodeType:t&&t.nodeType,selector:r},i=R().client,a=i.createEvent({category:"error",type:"resourceError",detail:o});i.notify(a)}(n)}else"unhandledrejection"===t?function(e){var t={message:e.reason.message||e.reason,stack:e.reason.stack},n=R().client,r=n.createEvent({category:"error",type:"unhandledrejectionError",detail:t});n.notify(r)}(e):K(e)}catch(o){K(o)}}function J(e,t){try{switch(e){case g:!function(e){var t=R().client,n=t.createEvent({category:"error",type:g,detail:e});t.notify(n)}(t);break;case y:!function(e){var t=R().client,n=t.createEvent({category:"error",type:y,detail:e});t.notify(n)}(t);break;case m:!function(e){var t=R().client,n=t.createEvent({category:"error",type:m,detail:e});t.notify(n)}(t)}}catch(e){K(e)}}var Y="XMLHttpRequest"in w(),z=Y?{open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send}:{};var $=w(),Q="fetch"in $,Z=Q?$.fetch:null;var ee=w();var te=w();function ne(e){G(e)}var re=w();function oe(e){G(e)}function ie(){B(),function(){var e,t;null===(t=null===(e=null==I?void 0:I.document)||void 0===e?void 0:e.addEventListener)||void 0===t||t.call(e,"click",F)}()}function ae(){!function(){var e;H.history.pushState=V.pushState,H.history.replaceState=V.replaceState,H.onpopstate=V.onpopstate,null===(e=null==H?void 0:H.removeEventListener)||void 0===e||e.call(H,"hashchange",q,!0)}(),function(){var e,t;null===(t=null===(e=null==I?void 0:I.document)||void 0===e?void 0:e.removeEventListener)||void 0===t||t.call(e,"click",F)}()}function ue(){!function(){if(_(Y,"Binding `AJAX` monitoring failed, the current environment did not find the object `XMLHttpRequest`"),Y){var e=R().client,t={method:"",url:""},n=null===XMLHttpRequest||void 0===XMLHttpRequest?void 0:XMLHttpRequest.prototype;z.open=k(n,"open",(function(e){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=n[0],i=n[1];return t.method=o,t.url=i,e.apply(this,n)}})),z.send=k(n,"send",(function(n){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return this.addEventListener("readystatechange",(function(){if(4===this.readyState&&t.url!==e._config.endpoint){var n={req:{url:t.url,method:t.method,data:r[0]||{}},res:{status:this.status,statusText:this.statusText,response:this.response}};e.addAction("ajax",n,"ajax"),(!this.status||this.status>=400)&&J(g,n)}})),n.apply(this,r)}}))}}(),function(){if(_(Q,"Binding `fetch` monitoring failed, the current environment did not find the object `fetch`"),Q){var e=R().client;Z=k($,"fetch",(function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t.apply(this,n).then((function(t){var r=n[0],o=n[1],i={req:{url:r,method:o&&o.method,data:o&&o.body||{}},res:{status:t.status,statusText:t.statusText}};return e.addAction("fetch",i,"fetch"),(!t.status||t.status>=400)&&J(y,i),t})).catch((function(e){J(y,e)}))}}))}}(),function(){if(_("WebSocket"in ee,"Binding `WebSocket` monitoring failed, the current environment did not find the object `WebSocket`"),"WebSocket"in ee){var e=null===WebSocket||void 0===WebSocket?void 0:WebSocket.prototype,t=Object.getOwnPropertyDescriptor(e,"onerror");Object.defineProperty(e,"onerror",{set:function(){var e,n=arguments[0];null===(e=null==t?void 0:t.set)||void 0===e||e.call(this,(function(e){var t=e.target,r=t.url,o=t.readyState,i=t.protocol,a=t.extensions,u=t.binaryType,c=t.bufferedAmount,s=e.timeStamp;J(m,{url:r,timeStamp:s,readyState:o,protocol:i,extensions:a,binaryType:u,bufferedAmount:c}),n.apply(this,arguments)}))}})}}()}function ce(){!function(){if(Y&&z.open&&z.send){var e=null===XMLHttpRequest||void 0===XMLHttpRequest?void 0:XMLHttpRequest.prototype;e.open=z.open,e.send=z.send}}(),Q&&Z&&($.fetch=Z)}function se(){var e=w();_(Boolean(e.addEventListener),"Binding script monitoring failed, the current environment did not find the object `addEventListener`"),e.addEventListener&&(function(){var e;null===(e=null==te?void 0:te.addEventListener)||void 0===e||e.call(te,"error",ne,!0)}(),function(){var e;null===(e=null==re?void 0:re.addEventListener)||void 0===e||e.call(re,"unhandledrejection",oe,!0)}())}function le(){!function(){var e;null===(e=null==te?void 0:te.removeEventListener)||void 0===e||e.call(te,"error",ne,!0)}(),function(){var e;null===(e=null==re?void 0:re.removeEventListener)||void 0===e||e.call(re,"unhandledrejection",oe,!0)}()}function fe(){var e;se(),ue(),ie(),e=R().client,C.forEach((function(t){W[t]=k(console,t,(function(n){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return r.some((function(e){return"string"==typeof e&&e.includes("Ohbug")}))||e.addAction("console."+t,r,"console"),n.apply(this,r)}}))}))}var de=w();function pe(){var e;null===(e=null==de?void 0:de.addEventListener)||void 0===e||e.call(de,"unload",(function(){le(),ce(),ae(),console&&C.forEach((function(e){console[e]=W[e]}))}),!0)}var ve={name:"OhbugBrowser",init:function(){fe(),pe()}};function he(e){var t=R().client._config.endpoint;return new Promise((function(n,r){var o=JSON.stringify(e);if(navigator.sendBeacon){var i=navigator.sendBeacon(t,o);n(i)}else{var a=new XMLHttpRequest;a.onreadystatechange=function(){if(a.readyState===XMLHttpRequest.DONE){if(a.status>=200&&a.status<300)return n(a.response);r(a)}},a.open("POST",t),a.setRequestHeader("Content-Type","application/json;charset=UTF-8"),a.send(o)}}))}var ge={_client:null,init:function(e){var t;return ge._client?(null===(t=ge._client._logger)||void 0===t||t.log("init() has been called. Ignored."),ge._client):(ge._client=function(e){var t=w(),n=new h({sdk:{platform:"ohbug-browser",version:x},config:e,device:A,notifier:he});return t.__OHBUG__={client:n},n.use(ve),console.log("%c @ohbug/browser %c Detected Ohbug v1.0.19 %c","background:#333; padding: 2px 1px; color: #FFF","background:#FF6F61; padding: 2px 1px; color: #FFF","background:transparent"),n}(e),ge._client)}};e.Client=ge,e.default=ge,Object.defineProperty(e,"__esModule",{value:!0})}));
package/dist/version.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const version = "1.0.19";
2
- //# sourceMappingURL=version.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAA"}