@ohbug/browser 1.0.18 → 2.0.0

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 (91) hide show
  1. package/README.md +2 -3
  2. package/dist/index.d.ts +70 -6
  3. package/dist/index.js +674 -0
  4. package/dist/index.mjs +653 -0
  5. package/package.json +20 -21
  6. package/src/capture/action/captureClick.ts +35 -0
  7. package/src/capture/action/captureUrlChange.ts +100 -0
  8. package/src/capture/console/captureConsole.ts +45 -0
  9. package/src/capture/index.ts +64 -0
  10. package/src/capture/network/captureAjaxError.ts +81 -0
  11. package/src/capture/network/captureFetchError.ts +69 -0
  12. package/src/capture/network/captureWebSocketError.ts +51 -0
  13. package/src/capture/script/captureUncaughtError.ts +20 -0
  14. package/src/capture/script/captureUnhandledrejectionError.ts +20 -0
  15. package/src/client.ts +46 -0
  16. package/src/destroy.ts +22 -0
  17. package/src/device.ts +19 -0
  18. package/src/dispatch/index.ts +2 -0
  19. package/src/dispatch/networkDispatcher.ts +29 -0
  20. package/src/dispatch/scriptDispatcher.ts +30 -0
  21. package/src/extension.ts +12 -0
  22. package/src/handle/ajaxErrorHandler.ts +26 -0
  23. package/src/handle/fetchErrorHandler.ts +25 -0
  24. package/src/handle/index.ts +16 -0
  25. package/src/handle/resourceErrorHandler.ts +41 -0
  26. package/src/handle/uncaughtErrorHandler.ts +37 -0
  27. package/src/handle/unhandledrejectionErrorHandler.ts +21 -0
  28. package/src/handle/unknownErrorHandler.ts +18 -0
  29. package/src/handle/websocketErrorHandler.ts +23 -0
  30. package/src/index.ts +13 -0
  31. package/src/notifier.ts +42 -0
  32. package/src/version.ts +1 -0
  33. package/dist/capture/action/captureClick.d.ts +0 -3
  34. package/dist/capture/action/captureClick.d.ts.map +0 -1
  35. package/dist/capture/action/captureUrlChange.d.ts +0 -3
  36. package/dist/capture/action/captureUrlChange.d.ts.map +0 -1
  37. package/dist/capture/console/captureConsole.d.ts +0 -3
  38. package/dist/capture/console/captureConsole.d.ts.map +0 -1
  39. package/dist/capture/index.d.ts +0 -10
  40. package/dist/capture/index.d.ts.map +0 -1
  41. package/dist/capture/network/captureAjaxError.d.ts +0 -6
  42. package/dist/capture/network/captureAjaxError.d.ts.map +0 -1
  43. package/dist/capture/network/captureFetchError.d.ts +0 -6
  44. package/dist/capture/network/captureFetchError.d.ts.map +0 -1
  45. package/dist/capture/network/captureWebSocketError.d.ts +0 -5
  46. package/dist/capture/network/captureWebSocketError.d.ts.map +0 -1
  47. package/dist/capture/script/captureUncaughtError.d.ts +0 -6
  48. package/dist/capture/script/captureUncaughtError.d.ts.map +0 -1
  49. package/dist/capture/script/captureUnhandledrejectionError.d.ts +0 -6
  50. package/dist/capture/script/captureUnhandledrejectionError.d.ts.map +0 -1
  51. package/dist/client.d.ts +0 -8
  52. package/dist/client.d.ts.map +0 -1
  53. package/dist/destroy.d.ts +0 -2
  54. package/dist/destroy.d.ts.map +0 -1
  55. package/dist/device.d.ts +0 -3
  56. package/dist/device.d.ts.map +0 -1
  57. package/dist/dispatch/index.d.ts +0 -3
  58. package/dist/dispatch/index.d.ts.map +0 -1
  59. package/dist/dispatch/networkDispatcher.d.ts +0 -2
  60. package/dist/dispatch/networkDispatcher.d.ts.map +0 -1
  61. package/dist/dispatch/scriptDispatcher.d.ts +0 -2
  62. package/dist/dispatch/scriptDispatcher.d.ts.map +0 -1
  63. package/dist/extension.d.ts +0 -2
  64. package/dist/extension.d.ts.map +0 -1
  65. package/dist/handle/ajaxErrorHandler.d.ts +0 -15
  66. package/dist/handle/ajaxErrorHandler.d.ts.map +0 -1
  67. package/dist/handle/fetchErrorHandler.d.ts +0 -14
  68. package/dist/handle/fetchErrorHandler.d.ts.map +0 -1
  69. package/dist/handle/index.d.ts +0 -15
  70. package/dist/handle/index.d.ts.map +0 -1
  71. package/dist/handle/resourceErrorHandler.d.ts +0 -13
  72. package/dist/handle/resourceErrorHandler.d.ts.map +0 -1
  73. package/dist/handle/uncaughtErrorHandler.d.ts +0 -10
  74. package/dist/handle/uncaughtErrorHandler.d.ts.map +0 -1
  75. package/dist/handle/unhandledrejectionErrorHandler.d.ts +0 -6
  76. package/dist/handle/unhandledrejectionErrorHandler.d.ts.map +0 -1
  77. package/dist/handle/unknownErrorHandler.d.ts +0 -5
  78. package/dist/handle/unknownErrorHandler.d.ts.map +0 -1
  79. package/dist/handle/websocketErrorHandler.d.ts +0 -12
  80. package/dist/handle/websocketErrorHandler.d.ts.map +0 -1
  81. package/dist/index.d.ts.map +0 -1
  82. package/dist/notifier.d.ts +0 -3
  83. package/dist/notifier.d.ts.map +0 -1
  84. package/dist/ohbug-browser.es.js +0 -1530
  85. package/dist/ohbug-browser.es.min.js +0 -58
  86. package/dist/ohbug-browser.umd.js +0 -1542
  87. package/dist/ohbug-browser.umd.min.js +0 -58
  88. package/dist/types.d.ts +0 -10
  89. package/dist/types.d.ts.map +0 -1
  90. package/dist/version.d.ts +0 -2
  91. package/dist/version.d.ts.map +0 -1
@@ -1,58 +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,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())}))}function r(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=a.trys,(o=o.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])}}}function o(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 i(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}var a="Ohbug";function u(e){return"string"==typeof e}function c(e){return"function"==typeof e}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}var l={apiKey:{defaultValue:void 0,message:"is required",validate:function(e){return Boolean(e)&&u(e)}},appVersion:{defaultValue:void 0,message:"should be a string",validate:function(e){return void 0===e||u(e)}},appType:{defaultValue:void 0,message:"should be a string",validate:function(e){return void 0===e||u(e)}},releaseStage:{defaultValue:"production",message:"should be a string",validate:function(e){return void 0===e||u(e)}},endpoint:{defaultValue:"http://localhost:6660/report",message:"should be a string",validate:function(e){return void 0===e||u(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||c(e)}},notified:{defaultValue:function(){},message:"should be a function",validate:function(e){return void 0===e||c(e)}},logger:{defaultValue:{log:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,i([a],e))},info:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.info.apply(console,i([a],e))},warn:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,i([a],e))},error:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,i([a],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||s(e)&&Object.keys(e).length<=6}},metaData:{defaultValue:void 0,message:"should be an object",validate:function(e){return void 0===e||s(e)}}};function f(e,t){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var a=null===(n=e.init)||void 0===n?void 0:n.call.apply(n,o([e,t],r));return t._extensions.push(e),t._hooks.created=function(e,t){var n,r,i=o([t._config.created],t._extensions.filter((function(e){return c(e.created)})).map((function(e){return e.created})));return 0===i.length?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e}(e,t):1===i.length?null===(n=i[0])||void 0===n?void 0:n.call(i,e,t):null===(r=i.reduce((function(e,n){return function(r){return n(e(r,t),t)}})))||void 0===r?void 0:r(e,t)},t._hooks.notified=function(e,t){return o([t._config.notified],t._extensions.filter((function(e){return c(e.notified)})).map((function(e){return e.notified}))).forEach((function(n){return null==n?void 0:n(e,t)}))},a||t}var d=function(e,t,n,r){this.type=n,this.timestamp=r||(new Date).toISOString(),this.message=e,this.data=t};function p(e,t){return new Error("Invalid data\n- "+e+", got "+JSON.stringify(t))}function v(e,t,n){t&&(e[t]=n)}function h(e,t){if(e[t])return e[t]}function g(e,t){if(e[t])return delete e[t]}var y=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 o,i,a=this.actions,c=u(e)?e:"",s=t||{},l=u(n)?n:"",f=new d(c,s,l,r);a.length>=(null!==(i=null===(o=this._client)||void 0===o?void 0:o._config.maxActions)&&void 0!==i?i:30)&&a.shift(),a.push(f)},e.prototype.getUser=function(){return this.user},e.prototype.setUser=function(e){var n;if(s(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(p("setUser should be an object and have up to 6 attributes",e))},e.prototype.addMetaData=function(e,t){return v(this.metaData,e,t)},e.prototype.getMetaData=function(e){return h(this.metaData,e)},e.prototype.deleteMetaData=function(e){return g(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 m=function(){function e(e){var t=this,n=e.sdk,r=e.config,o=e.schema,i=void 0===o?l:o,a=e.device,u=e.notifier,c=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=c.config,d=c.errors;this._sdk=n,this._config=f,this._logger=f.logger,this._device=a,this._notifier=u,this._extensions=[],this._hooks={created:f.created,notified:f.notified},this._actions=[],this._user=f.user,this._metaData={},s(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=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return f.apply(void 0,o([e,this],t))},e.prototype.createEvent=function(e){var t=function(e,t){var n,r,o,i=t._config,a=i.apiKey,u=i.appVersion,c=i.appType,l=i.releaseStage,f=(new Date).toISOString(),d=t._device(t);return s(e)&&Object.prototype.hasOwnProperty.call(e,"type")&&Object.prototype.hasOwnProperty.call(e,"detail")?(n=e.category||"error",r=e.type,o=e.detail):(n="error",r="unknownError",o=e),new y({apiKey:a,appVersion:u,appType:c,timestamp:f,category:n,type:r,sdk:t._sdk,device:d,user:t._user,detail:o,actions:t._actions,metaData:t._metaData,releaseStage:l},t)}(e,this);return c(this._hooks.created)?this._hooks.created(t,this):t},e.prototype.notify=function(e,t){var o;return o=Boolean(e)&&!function(e){return Boolean(null==e?void 0:e._isOhbugEvent)}(e)?this.createEvent(e):e,t&&(o=t(o)),function(e,t){return n(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),n=null,e?[4,t._notifier(e)]:[3,2];case 1:n=r.sent(),r.label=2;case 2:return c(t._hooks.notified)&&t._hooks.notified(e,t),[2,n];case 3:return o=r.sent(),t._logger.error(o),[3,4];case 4:return[2]}}))}))}(o,this)},e.prototype.addAction=function(e,t,n,r){var o=this._actions,i=u(e)?e:"",a=t||{},c=u(n)?n:"",s=new d(i,a,c,r);o.length>=this._config.maxActions&&o.shift(),o.push(s)},e.prototype.getUser=function(){return this._user},e.prototype.setUser=function(e){if(s(e)&&Object.keys(e).length<=6)return this._user=t(t({},this._user),e),this.getUser();this._logger.warn(p("setUser should be an object and have up to 6 attributes",e))},e.prototype.addMetaData=function(e,t){return v(this._metaData,e,t)},e.prototype.getMetaData=function(e){return h(this._metaData,e)},e.prototype.deleteMetaData=function(e){return g(this._metaData,e)},e}();
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
- ***************************************************************************** */function b(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e}var E="Ohbug",_=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,b([E],e))};function w(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++]}));_(i)}}}catch(e){}}var O={};function k(){return"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:O}function S(){var e=k();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 j(e,t,n){if(t in e){var r=e[t],o=n(r);return e[t]=o,r}}function R(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 T(e,t){e.parentNode&&(t.push(e.parentNode),T(e.parentNode,t))}function D(e){var t=[];return t.push(e),T(e,t),t}var L,N,x,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?D(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(" > ")},H=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="1.0.18",V=k();function U(e,t){var n,r=S().client,o=R(null===(n=null==V?void 0:V.location)||void 0===n?void 0:n.href),i=R(e),a=R(t);i.path||(i=o),x=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 q(e){return function(t,n,r){return r&&U(x,String(r)),e.apply(this,[t,n,r])}}var B={pushState:null===(L=null==V?void 0:V.history)||void 0===L?void 0:L.pushState,replaceState:null===(N=null==V?void 0:V.history)||void 0===N?void 0:N.replaceState,onpopstate:null==V?void 0:V.onpopstate};function X(e){var t=e;U(t.oldURL,t.newURL)}function F(){var e;B.pushState=j(null==V?void 0:V.history,"pushState",q),B.replaceState=j(null==V?void 0:V.history,"replaceState",q),B.onpopstate=j(V,"onpopstate",(function(e){return function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=null===(t=null==V?void 0:V.location)||void 0===t?void 0:t.href;return U(x,o),e.apply(this,n)}})),null===(e=null==V?void 0:V.addEventListener)||void 0===e||e.call(V,"hashchange",X,!0)}var P=k();function W(e){if(e.target){var t=S().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")}}
44
- /*! *****************************************************************************
45
- Copyright (c) Microsoft Corporation.
46
-
47
- Permission to use, copy, modify, and/or distribute this software for any
48
- purpose with or without fee is hereby granted.
49
-
50
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
51
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
52
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
53
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
54
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
55
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
56
- PERFORMANCE OF THIS SOFTWARE.
57
- ***************************************************************************** */
58
- var K=function(){return(K=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"],I=Object.keys(C).reduce((function(e,t){var n;return K(K({},e),((n={})[t]=console[t],n))}),{log:null,info:null,warn:null,error:null});var J="uncaughtError",G="resourceError",z="unhandledrejectionError",Y="ajaxError",$="fetchError",Q="websocketError",Z="unknownError",ee=Object.freeze({__proto__:null,UNCAUGHT_ERROR:J,RESOURCE_ERROR:G,UNHANDLEDREJECTION_ERROR:z,AJAX_ERROR:Y,FETCH_ERROR:$,WEBSOCKET_ERROR:Q,UNKNOWN_ERROR:Z,MESSAGE:"message",VIEW:"view"});function te(e){var t=e.message?e:{message:e},n=S().client,r=n.createEvent({category:"error",type:"unknownError",detail:t});n.notify(r)}function ne(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=S().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=S().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=S().client,r=n.createEvent({category:"error",type:"unhandledrejectionError",detail:t});n.notify(r)}(e):te(e)}catch(o){te(o)}}function re(e,t){try{switch(e){case"ajaxError":!function(e){var t=S().client,n=t.createEvent({category:"error",type:"ajaxError",detail:e});t.notify(n)}(t);break;case"fetchError":!function(e){var t=S().client,n=t.createEvent({category:"error",type:"fetchError",detail:e});t.notify(n)}(t);break;case"websocketError":!function(e){var t=S().client,n=t.createEvent({category:"error",type:"websocketError",detail:e});t.notify(n)}(t)}}catch(e){te(e)}}var oe=k(),ie=Y,ae="XMLHttpRequest"in oe,ue=ae?{open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send}:{};var ce=k(),se=$,le="fetch"in ce,fe=le?ce.fetch:null;var de=k(),pe=Q;var ve=k();function he(e){ne(e)}var ge=k();function ye(e){ne(e)}function me(){F(),function(){var e,t;null===(t=null===(e=null==P?void 0:P.document)||void 0===e?void 0:e.addEventListener)||void 0===t||t.call(e,"click",W)}()}function be(){!function(){var e;V.history.pushState=B.pushState,V.history.replaceState=B.replaceState,V.onpopstate=B.onpopstate,null===(e=null==V?void 0:V.removeEventListener)||void 0===e||e.call(V,"hashchange",X,!0)}(),function(){var e,t;null===(t=null===(e=null==P?void 0:P.document)||void 0===e?void 0:e.removeEventListener)||void 0===t||t.call(e,"click",W)}()}function Ee(){!function(){if(w(ae,"Binding `AJAX` monitoring failed, the current environment did not find the object `XMLHttpRequest`"),ae){var e=S().client,t={method:"",url:""},n=null===XMLHttpRequest||void 0===XMLHttpRequest?void 0:XMLHttpRequest.prototype;ue.open=j(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)}})),ue.send=j(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)&&re(ie,n)}})),n.apply(this,r)}}))}}(),function(){if(w(le,"Binding `fetch` monitoring failed, the current environment did not find the object `fetch`"),le){var e=S().client;fe=j(ce,"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)&&re(se,i),t})).catch((function(e){re(se,e)}))}}))}}(),function(){if(w("WebSocket"in de,"Binding `WebSocket` monitoring failed, the current environment did not find the object `WebSocket`"),"WebSocket"in de){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;re(pe,{url:r,timeStamp:s,readyState:o,protocol:i,extensions:a,binaryType:u,bufferedAmount:c}),n.apply(this,arguments)}))}})}}()}function _e(){!function(){if(ae&&ue.open&&ue.send){var e=null===XMLHttpRequest||void 0===XMLHttpRequest?void 0:XMLHttpRequest.prototype;e.open=ue.open,e.send=ue.send}}(),le&&fe&&(ce.fetch=fe)}function we(){var e=k();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==ve?void 0:ve.addEventListener)||void 0===e||e.call(ve,"error",he,!0)}(),function(){var e;null===(e=null==ge?void 0:ge.addEventListener)||void 0===e||e.call(ge,"unhandledrejection",ye,!0)}())}function Oe(){!function(){var e;null===(e=null==ve?void 0:ve.removeEventListener)||void 0===e||e.call(ve,"error",he,!0)}(),function(){var e;null===(e=null==ge?void 0:ge.removeEventListener)||void 0===e||e.call(ge,"unhandledrejection",ye,!0)}()}function ke(){var e;we(),Ee(),me(),e=S().client,C.forEach((function(t){I[t]=j(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 Se=k();function je(){var e;null===(e=null==Se?void 0:Se.addEventListener)||void 0===e||e.call(Se,"unload",(function(){Oe(),_e(),be(),console&&C.forEach((function(e){console[e]=I[e]}))}),!0)}var Re={name:"OhbugBrowser",init:function(){ke(),je()}};function Te(e){var t=S().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 De={_client:null,init:function(e){var t;return De._client?(null===(t=De._client._logger)||void 0===t||t.log("init() has been called. Ignored."),De._client):(De._client=function(e){var t=k(),n=new m({sdk:{platform:"ohbug-browser",version:A},config:e,device:H,notifier:Te});return t.__OHBUG__={client:n},n.use(Re),console.log("%c @ohbug/browser %c Detected Ohbug v1.0.18 %c","background:#333; padding: 2px 1px; color: #FFF","background:#FF6F61; padding: 2px 1px; color: #FFF","background:transparent"),n}(e),De._client)}};e.Client=De,e.default=De,e.types=ee,Object.defineProperty(e,"__esModule",{value:!0})}));
package/dist/types.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export declare const UNCAUGHT_ERROR = "uncaughtError";
2
- export declare const RESOURCE_ERROR = "resourceError";
3
- export declare const UNHANDLEDREJECTION_ERROR = "unhandledrejectionError";
4
- export declare const AJAX_ERROR = "ajaxError";
5
- export declare const FETCH_ERROR = "fetchError";
6
- export declare const WEBSOCKET_ERROR = "websocketError";
7
- export declare const UNKNOWN_ERROR = "unknownError";
8
- export declare const MESSAGE = "message";
9
- export declare const VIEW = "view";
10
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,kBAAkB,CAAA;AAC7C,eAAO,MAAM,cAAc,kBAAkB,CAAA;AAC7C,eAAO,MAAM,wBAAwB,4BAA4B,CAAA;AACjE,eAAO,MAAM,UAAU,cAAc,CAAA;AACrC,eAAO,MAAM,WAAW,eAAe,CAAA;AACvC,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAC/C,eAAO,MAAM,aAAa,iBAAiB,CAAA;AAE3C,eAAO,MAAM,OAAO,YAAY,CAAA;AAEhC,eAAO,MAAM,IAAI,SAAS,CAAA"}
package/dist/version.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const version = "1.0.18";
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"}