@weaveui/web 0.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.
- package/LICENSE +35 -0
- package/README.md +119 -0
- package/THIRD_PARTY_NOTICES +29 -0
- package/dist/apm-log.es.js +996 -0
- package/dist/apm-log.umd.cjs +1 -0
- package/dist/business/apm-log/behavior-directive.d.ts +9 -0
- package/dist/business/apm-log/behavior-log.d.ts +6 -0
- package/dist/business/apm-log/behavior-types.d.ts +121 -0
- package/dist/business/apm-log/browser.d.ts +3 -0
- package/dist/business/apm-log/directive.d.ts +13 -0
- package/dist/business/apm-log/index.d.ts +8 -0
- package/dist/business/apm-log/legacy-apm-log.d.ts +6 -0
- package/dist/business/apm-log/types.d.ts +147 -0
- package/dist/business/apm-log/vue.d.ts +5 -0
- package/dist/business/monitor/index.d.ts +81 -0
- package/dist/business/monitor/monitor-plugin.d.ts +9 -0
- package/dist/business/monitor/runtime-types.d.ts +166 -0
- package/dist/business/monitor/runtime.d.ts +6 -0
- package/dist/business/monitor/types.d.ts +221 -0
- package/dist/business/permission/Permission.d.ts +18 -0
- package/dist/business/permission/PermissionPluginClass.d.ts +40 -0
- package/dist/business/permission/directive.d.ts +7 -0
- package/dist/business/permission/index.d.ts +35 -0
- package/dist/business/permission/permission-plugin.d.ts +16 -0
- package/dist/business/permission/storage.d.ts +30 -0
- package/dist/business/permission/tree.d.ts +19 -0
- package/dist/business/permission/types.d.ts +115 -0
- package/dist/business/upload-cos/index.d.ts +117 -0
- package/dist/business/upload-cos/src/UploadCos.vue.d.ts +70 -0
- package/dist/business/upload-cos/src/types.d.ts +72 -0
- package/dist/business/upload-cos/src/utils.d.ts +9 -0
- package/dist/index.d.ts +1894 -0
- package/dist/index.es.js +4315 -0
- package/dist/index.umd.cjs +6 -0
- package/dist/monitor.es.js +1217 -0
- package/dist/monitor.umd.cjs +1 -0
- package/dist/permission.es.js +631 -0
- package/dist/permission.umd.cjs +1 -0
- package/dist/style.css +1 -0
- package/dist/upload-cos.es.js +426 -0
- package/dist/upload-cos.style.css +1 -0
- package/dist/upload-cos.umd.cjs +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/is.d.ts +2 -0
- package/dist/utils/withInstall.d.ts +7 -0
- package/package.json +105 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(C,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],_):(C=typeof globalThis<"u"?globalThis:C||self,_(C.ElementCustomUIApmLog={}))})(this,function(C){"use strict";function _(){const t=globalThis.document;return typeof(t==null?void 0:t.addEventListener)=="function"?t:void 0}function ht(t){const e=globalThis.Element;return typeof e<"u"&&t instanceof e}function ot(t){const e=globalThis.MouseEvent;return typeof e<"u"&&t instanceof e}function it(t){return t.tagName.toLowerCase()}function Et(t,e){var u,s;if(typeof t=="string"){const g=t.trim();return g?{type:"click",properties:{action:g,element:it(e)}}:void 0}if(!t)return;const n=((u=t.type)==null?void 0:u.trim())||"click",c={element:it(e),...t.properties};return(s=t.label)!=null&&s.trim()&&(c.label=t.label.trim()),{type:n,properties:c,context:t.context?{...t.context}:void 0}}function at(t){const e=new WeakMap;return{mounted(n,c){const u={value:c.value,listener:s=>{if(!ot(s))return;const g=Et(u.value,n);g&&t.track(g)}};n.addEventListener("click",u.listener),e.set(n,u)},updated(n,c){const u=e.get(n);u&&(u.value=c.value)},unmounted(n){const c=e.get(n);c&&(n.removeEventListener("click",c.listener),e.delete(n))}}}const St=Symbol("EasyOilBehaviorLog"),bt=100,Dt=2,Ut=1e3,Pt="[data-behavior-log]",Nt="behavior-log";function q(t){return t?{...t}:{}}function kt(t){return t?{...t}:void 0}function wt(t,e){return!Number.isFinite(t)||!t||t<1?e:Math.floor(t)}function Tt(t,e){return!Number.isFinite(t)||t===void 0||t<0?e:Math.floor(t)}function Rt(t){var n;const e=(n=globalThis.crypto)==null?void 0:n.randomUUID;return typeof e=="function"?e.call(globalThis.crypto):`eol_${Date.now().toString(36)}_${t.toString(36)}_${Math.random().toString(36).slice(2,10)}`}function ct(t){if(t.fullPath)return t.fullPath;if(t.path)return t.path;if(t.name!==null&&t.name!==void 0)return String(t.name)}function At(t){var s;const e=(s=t.meta)==null?void 0:s.title,n=t.fullPath,c=n?n.split(/[?#]/,1)[0]:void 0,u=t.path||c;return{...u?{path:u}:{},...t.name!==null&&t.name!==void 0?{name:String(t.name)}:{},...typeof e=="string"&&e.trim()?{title:e.trim()}:{}}}function xt(t){const e=t.currentRoute;if(e)return"value"in e?e.value:e}function It(t,e){const n=ct(t),c=ct(e);return!!(n&&n===c)}function Ct(t){const e=wt(t.maxQueueSize,bt),n=Tt(t.maxRetries,Dt),c=t.dropStrategy??"oldest",u=[],s=new WeakSet;let g=0,l=!1,f=!1,d,b,w,D,x,T,F;function P(r,o){var a;try{(a=t.onError)==null||a.call(t,r,o)}catch{}}function R(r,o,a){var m;try{(m=t.onDrop)==null||m.call(t,r,{reason:o,error:a})}catch{}}function z(r){const o=u.indexOf(r);o>=0&&u.splice(o,1)}function N(){const r=u.findIndex(a=>a!==x);if(r<0)return;const[o]=u.splice(r,1);return o}function tt(r){if(u.length>=e){if(c==="newest")return R(r,"queue-full"),!1;const o=N();if(!o)return R(r,"queue-full"),!1;R(o.event,"queue-full")}return u.push({event:r,attempts:0}),!0}function et(r,o){try{const a=typeof t.retryDelay=="function"?t.retryDelay(r,o):t.retryDelay;if(typeof a=="number"&&Number.isFinite(a)&&a>=0)return a}catch(a){P(a,{stage:"transport",attempt:r})}return Ut}function nt(r,o){b||f||!l||(b=globalThis.setTimeout(()=>{b=void 0,y()},et(r,o)))}async function $(r){let o,a;if(t.getSessionId)try{o=await t.getSessionId()||void 0}catch(m){return{ok:!1,error:m,stage:"session-context"}}if(t.getUserContext)try{a=kt(await t.getUserContext())}catch(m){return{ok:!1,error:m,stage:"user-context"}}return{ok:!0,event:{...r,properties:q(r.properties),...r.context?{context:q(r.context)}:{},...o?{sessionId:o}:{},...a?{user:a}:{}}}}async function i(r){const o=await $(r.event);if(!o.ok)return o;if(f||!l)return{ok:!1,error:new Error("Behavior log was stopped before delivery."),stage:"transport"};try{return await t.transport(o.event),{ok:!0}}catch(a){return{ok:!1,error:a,stage:"transport"}}}async function p(){for(;l&&!f;){const r=u[0];if(!r)return;x=r;const o=await i(r);if(x===r&&(x=void 0),f||!l)return;if(o.ok){z(r);continue}if(u.includes(r)){if(r.attempts+=1,P(o.error,{stage:o.stage,event:r.event,attempt:r.attempts}),r.attempts>n){z(r),R(r.event,"transport-failed",o.error);continue}nt(r.attempts,o.error);return}}}function y(){if(f||!l)return Promise.resolve();if(d)return d;b&&(globalThis.clearTimeout(b),b=void 0);const r=p().catch(o=>{P(o,{stage:"transport"})}).finally(()=>{d===r&&(d=void 0,E())});return d=r,r}function E(){f||!l||!u.length||d||b||y()}function v(r,o){if(o.resolveRoute)try{const a=o.resolveRoute(r);if(a)return{...a}}catch(a){P(a,{stage:"router"})}return At(r)}function S(r,o,a){Q({type:"page_enter",properties:{page:v(r,a),...o?{from:v(o,a)}:{}}}),T=r,F=Date.now()}function U(r,o,a,m){if(a||f||!l)return;const h=T??o;h&&!m.includeSameRoute&&It(h,r)||(T&&F!==void 0&&Q({type:"page_leave",properties:{page:v(T,m),to:v(r,m),durationMs:Math.max(0,Date.now()-F)}}),S(r,h,m))}function rt(){const r=t.router,o=t.routeTracking;if(!r||o===!1)return;const a=o??{};try{const m=r.afterEach((h,I,j)=>{U(h,I,j,a)});if(typeof m=="function"&&(w=m),a.trackInitialRoute){const h=xt(r);h&&S(h,void 0,a)}}catch(m){P(m,{stage:"router"})}}function ee(r){var m,h;const o=((m=r.getAttribute("data-behavior-log"))==null?void 0:m.trim())||"click",a=(h=r.getAttribute("data-behavior-log-label"))==null?void 0:h.trim();return{type:"click",properties:{action:o,element:r.tagName.toLowerCase(),...a?{label:a}:{}}}}function ne(r,o){if(ht(r.target))return r.target.closest(o)??void 0}function re(){const r=t.clickTracking;if(!r)return;const o=r.root??_();if(!o)return;const a=r.selector??Pt,m=h=>{if(!(!ot(h)||f||!l))try{const I=ne(h,a);if(!I)return;const j=r.getPayload?r.getPayload(h,I):ee(I);j&&Q(j)}catch(I){P(I,{stage:"click-tracking"})}};try{o.addEventListener("click",m),D=()=>o.removeEventListener("click",m)}catch(h){P(h,{stage:"click-tracking"})}}function vt(){return f?!1:(l||(l=!0,rt(),re(),E()),!0)}function Q(r,o){if(!l||f)return;const a=typeof r=="string"?{type:r,properties:o}:r,m=a.type.trim();if(!m)return;g+=1;const h={id:Rt(g),type:m,timestamp:new Date().toISOString(),properties:q(a.properties),...a.context?{context:q(a.context)}:{}};if(tt(h))return E(),h}function oe(r){if(s.has(r))return;s.add(r),r.provide(St,K);const o=t.directiveName===void 0?Nt:t.directiveName;o&&r.directive(o,at(K)),vt()}function ie(){if(f)return;f=!0,l=!1,b&&(globalThis.clearTimeout(b),b=void 0);const r=w;w=void 0;const o=D;D=void 0;try{r==null||r()}catch(a){P(a,{stage:"router"})}try{o==null||o()}catch(a){P(a,{stage:"click-tracking"})}for(;u.length;){const a=u.shift();a&&R(a.event,"destroyed")}}const K={get isStarted(){return l},get isDestroyed(){return f},install:oe,start:vt,track:Q,flush:y,createClickDirective:()=>at(K),destroy:ie};return K}function O(t){if(t==null||t==="")return null;try{return String(t)}catch{return null}}function Lt(t,e){return typeof e=="string"?O(e):(e==null?void 0:e.buttonName)!==void 0?O(e.buttonName):O(t.innerText||t.textContent||void 0)}function Ft(t,e){return typeof t!="string"&&(t==null?void 0:t.pageName)!==void 0?O(t.pageName):e.pageName}function _t(t,e){const n=new WeakMap;return{mounted(c,u){const s={value:u.value,listener:()=>{try{const g=e();t.addTask("ClickButton",{fromUrl:null,fromPage:null,toUrl:null,toPage:null,pageName:Ft(s.value,g),buttonName:Lt(c,s.value),stopDuration:null,systemStopDuration:null})}catch{}}};c.addEventListener("click",s.listener),n.set(c,s)},updated(c,u){const s=n.get(c);s&&(s.value=u.value)},unmounted(c){const u=n.get(c);u&&(c.removeEventListener("click",u.listener),n.delete(c))}}}const ut="v1.0.0",H="6cff83cad70a55a7cfd197e1f29ff0d6",st="9e09e21609f011ce6eab6effd527bc63",Y="4bcbb789845ec91c1fb804235a797e0a";function M(){return typeof globalThis.window<"u"&&typeof globalThis.document<"u"}function lt(){return M()?globalThis.window:void 0}function ft(){const t=lt();if(t)try{return t.sessionStorage}catch{return}}function X(t){var e;try{return((e=ft())==null?void 0:e.getItem(t))||void 0}catch{return}}function B(t,e){var n;try{(n=ft())==null||n.setItem(t,e)}catch{}}function dt(t){const e=Number(X(t));return Number.isFinite(e)&&e>0?e:void 0}function Mt(){var e;const t=(e=globalThis.crypto)==null?void 0:e.randomUUID;return typeof t=="function"?t.call(globalThis.crypto):`eol_legacy_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,12)}`}function J(){if(!M())return;const t=X(H);if(t)return t;const e=Mt();return B(H,e),e}function k(t){if(t==null)return"";try{return String(t)}catch{return""}}function L(t){if(t!==void 0)return t===null?null:k(t)}function A(t){return t&&k(t)||null}function gt(t){return typeof t!="string"?void 0:t.trim()||void 0}function mt(t){return typeof t=="number"&&Number.isFinite(t)&&t!==0?t:null}function Bt(t=new Date){const e=t.getFullYear(),n=t.getMonth()+1,c=String(t.getDate()).padStart(2,"0"),u=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0"),g=String(t.getSeconds()).padStart(2,"0");return`${e}-${n}-${c} ${u}:${s}:${g}`}function zt(){var e;const t={deviceSystem:"unknow",deviceModel:"web",deviceSystemVersion:"unknow",browser:"unknow"};if(!M())return t;try{const n=globalThis.navigator,c=n.userAgent||"",s=((e=n.userAgentData)==null?void 0:e.platform)||n.platform||"unknow",g=/Android|webOS|iPhone|iPod|BlackBerry/i.test(c)?"phone":"web";let l="unknow",f="unknow";if(c.includes("Chrome")){const d=c.match(/Chrome\/([\d.]+)/);l=(d==null?void 0:d[1])||"unknow",f=(d==null?void 0:d[0])||"Chrome"}else if(c.includes("Safari")){const d=c.match(/Version\/([\d.]+)/);l=(d==null?void 0:d[1])||"unknow",f="Safari"}else if(c.includes("Firefox")){const d=c.match(/Firefox\/([\d.]+)/);l=(d==null?void 0:d[1])||"unknow",f=(d==null?void 0:d[0])||"unknow"}return{deviceSystem:s,deviceModel:g,deviceSystemVersion:l,browser:f}}catch{return t}}function $t(t){const e=t.trim();if(e)return`${e.replace(/\/+$/,"")}/frontEndLog/add`}function qt(t){return{"Content-Type":"application/json",x_app_channel_id:k(t.appChannelId),x_data_channel_id:k(t.dataChannelId)}}function V(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ot(t,e){const n=t.action;if(!V(n))return{type:e,fromPage:null,pageName:null,buttonName:null,stopDuration:null};const c=gt(n.type)||e,u=L(n.fromUrl),s=L(n.toUrl),g=L(n.toPage),l=n.systemStopDuration,f={type:c,fromPage:A(n.fromPage),pageName:A(n.pageName),buttonName:A(n.buttonName),stopDuration:mt(n.stopDuration)};return u!==void 0&&(f.fromUrl=u),s!==void 0&&(f.toUrl=s),g!==void 0&&(f.toPage=g),(l===null||typeof l=="number"&&Number.isFinite(l))&&(f.systemStopDuration=l),f}function Yt(t){return{account:k(t==null?void 0:t.account),nickName:k(t==null?void 0:t.nickName)}}function Vt(t){if(t)try{Promise.resolve(t()).catch(()=>{})}catch{}}function Wt(t,e){if(t)try{Promise.resolve(t(e)).catch(()=>{})}catch{}}async function pt(t){if(!t)return"";try{return k(await t())}catch{return""}}async function Gt(t){const[e,n]=await Promise.all([pt(t.getAccountFn),pt(t.getNickNameFn)]);return{account:e,nickName:n}}function Qt(t,e){try{return typeof t=="string"?t===e:t instanceof RegExp?(t.lastIndex=0,t.test(e)):t(e)}catch{return!1}}function Kt(t,e){if(!t||t.mode!=="match"&&t.mode!=="ignore")return!1;const c=(Array.isArray(t.rules)?t.rules:[t.rules]).some(u=>Qt(u,e));return t.mode==="ignore"?c:!c}function W(t){return t&&(t.fullPath||t.path)||null}function jt(t){return(t==null?void 0:t.path)||W(t)}function Z(t){var n;if(!t)return null;const e=(n=t.meta)==null?void 0:n.title;return typeof e=="string"||typeof e=="number"?A(e):typeof t.name=="string"||typeof t.name=="number"||typeof t.name=="symbol"?k(t.name):null}function Ht(t){const e=t==null?void 0:t.currentRoute;if(e)return"value"in e?e.value:e}function G(t,e){return t===void 0?null:Math.max(0,e-t)}function Xt(t,e,n){const c=L(e.fromUrl),u=L(e.toUrl),s=L(e.toPage),g=A(e.pageName);g&&(n.currentPageName=g);const l={type:t,fromPage:A(e.fromPage),pageName:g||n.currentPageName||null,buttonName:A(e.buttonName),stopDuration:mt(e.stopDuration)};return c!==void 0&&(l.fromUrl=c),u!==void 0&&(l.toUrl=u),s!==void 0&&(l.toPage=s),e.systemStopDuration!==void 0&&(l.systemStopDuration=e.systemStopDuration),l}function Jt(t){const e=V(t)?t:{},n=typeof e.version=="string"&&e.version.trim()?e.version.trim():ut;return{envUrl:typeof e.envUrl=="string"?e.envUrl:"",...typeof e.appChannelId=="string"||typeof e.appChannelId=="number"||e.appChannelId===null?{appChannelId:e.appChannelId}:{},...typeof e.dataChannelId=="string"||typeof e.dataChannelId=="number"||e.dataChannelId===null?{dataChannelId:e.dataChannelId}:{},...V(e.router)?{router:e.router}:{},...typeof e.getAccountFn=="function"?{getAccountFn:e.getAccountFn}:{},...typeof e.getNickNameFn=="function"?{getNickNameFn:e.getNickNameFn}:{},...V(e.pageFilter)?{pageFilter:e.pageFilter}:{},...typeof e.success=="function"?{success:e.success}:{},...typeof e.failed=="function"?{failed:e.failed}:{},version:n}}function Zt(t){const e=Jt(t),n={currentRouteUrl:null,currentPageName:null,systemEnteredAt:void 0,pageEnteredAt:void 0},c=zt(),u=new WeakSet;let s=!1,g=!1,l,f=!1,d,b;const w=Ct({directiveName:!1,maxRetries:0,getSessionId:()=>J(),getUserContext:()=>Gt(e),transport:async i=>{if(!M())return;const p=$t(e.envUrl);if(!p)throw new Error("Legacy apm-log requires a non-empty envUrl.");if(typeof globalThis.fetch!="function")throw new Error("The browser Fetch API is unavailable.");const y=Ot(i.properties,i.type),E=Yt(i.user),v={sessionId:i.sessionId||J()||null,account:E.account,nickName:E.nickName,deviceInfo:{...c},action:y,version:e.version||ut,time:Bt()},S=await globalThis.fetch(p,{method:"POST",headers:qt(e),body:JSON.stringify(v)});if(!S.ok)throw new Error(`Legacy apm-log request failed with HTTP ${S.status}.`);Vt(e.success)},onDrop:(i,p)=>{p.reason==="transport-failed"&&Wt(e.failed,p.error)}});function D(i,p={}){if(s)return;const y=gt(i);if(!y)return;const E=k(p.toUrl),v=p.filter||e.pageFilter;if(Kt(v,E))return;const S=Xt(y,p,n);return w.track({type:y,properties:{action:S}})}function x(i,p){if(s)return;const y=Date.now(),E=W(p)||n.currentRouteUrl,v=Z(p)||n.currentPageName,S=W(i),U=Z(i),rt=!!X(H);J(),n.systemEnteredAt===void 0&&(n.systemEnteredAt=dt(st)||y),n.pageEnteredAt===void 0&&(n.pageEnteredAt=dt(Y)||y),rt?n.currentRouteUrl?(D("EnterPage",{fromUrl:E,fromPage:v,toUrl:S,toPage:U,pageName:U,stopDuration:null,systemStopDuration:null}),D("LeavePage",{fromUrl:E,fromPage:v,toUrl:S,toPage:U,pageName:U,stopDuration:G(n.pageEnteredAt,y),systemStopDuration:G(n.systemEnteredAt,y)}),n.pageEnteredAt=y,B(Y,String(y))):(D("EnterPage",{fromUrl:E,fromPage:v,toUrl:S,toPage:U,pageName:U,stopDuration:null,systemStopDuration:null}),n.pageEnteredAt=y,B(Y,String(y))):(n.systemEnteredAt=y,n.pageEnteredAt=y,B(st,String(y)),B(Y,String(y)),D("EnterSystem",{fromUrl:E,fromPage:null,toUrl:S,toPage:U,pageName:U,stopDuration:null,systemStopDuration:null}),D("EnterPage",{fromUrl:E,fromPage:v,toUrl:S,toPage:U,pageName:U,stopDuration:null,systemStopDuration:null})),n.currentRouteUrl=jt(i),n.currentPageName=U}function T(i){var E;if(!i||!M()||f)return;l=i;const p=(v,S)=>{try{x(v,S)}catch{}},y=(v,S,U)=>{if(!U)try{x(v,S)}catch{}};try{const v=i.beforeEach?i.beforeEach(p):(E=i.afterEach)==null?void 0:E.call(i,y);typeof v=="function"&&(d=v),f=!0}catch{l=void 0}}function F(){s||(D("LeavePage",{fromUrl:null,fromPage:n.currentRouteUrl,toUrl:null,toPage:null,pageName:null,buttonName:null,stopDuration:null,systemStopDuration:null}),D("LeaveSystem",{fromUrl:null,fromPage:n.currentRouteUrl,toUrl:null,toPage:null,pageName:null,buttonName:null,stopDuration:null,systemStopDuration:null}))}function P(){if(s)return;const i=Date.now();D("LeavePage",{fromUrl:n.currentRouteUrl,fromPage:n.currentPageName,toUrl:"",toPage:"",pageName:"",buttonName:null,stopDuration:G(n.pageEnteredAt,i),systemStopDuration:null}),D("LeaveSystem",{fromUrl:n.currentRouteUrl,fromPage:n.currentPageName,toUrl:"",toPage:"",pageName:"",buttonName:null,stopDuration:null,systemStopDuration:G(n.systemEnteredAt,i)})}function R(){const i=lt();if(!i||b)return;const p=()=>{try{P()}catch{}};try{i.addEventListener("beforeunload",p),b=()=>i.removeEventListener("beforeunload",p)}catch{}}function z(i,p){D("ClickButton",{fromUrl:null,fromPage:null,toUrl:null,toPage:null,pageName:i||n.currentPageName,buttonName:p,stopDuration:null,systemStopDuration:null})}const N={get isInitialized(){return g&&!s},init(i){return s||(T(i||l||e.router),R(),g=!0),N},initRouter(i){return s||(T(i||l||e.router),g=!0),N},initUniRouter(){return N},mountBtnFunction(){},mountExitSystemFunction(){},addListener(){return s||(R(),g=!0),N},addRouterListener(){return s||(T(l||e.router),g=!0),N}};function tt(){return _t($,()=>{const i=Ht(l||e.router);return{pageName:Z(i)||n.currentPageName,routeUrl:W(i)||n.currentRouteUrl}})}function et(i){if(!(s||u.has(i))){u.add(i);try{w.install(i)}catch{}try{i.directive("BtnLog",tt())}catch{}try{i.config.globalProperties.LogClass=$,i.config.globalProperties.MixinClass=N,i.config.globalProperties.$btnLog=z,i.config.globalProperties.$exitSystem=F}catch{}N.init(e.router)}}function nt(){if(s)return;s=!0;const i=d,p=b;d=void 0,b=void 0,f=!1,l=void 0;try{i==null||i()}catch{}try{p==null||p()}catch{}w.destroy()}const $={behaviorLog:w,mixinClass:N,options:e,get isDestroyed(){return s},install:et,addTask:D,btnLog:z,exitSystem:F,flush:()=>w.flush(),destroy:nt};return $}const yt=new WeakMap,te={install(t,e){if(yt.get(t))return;const c=Zt(e);yt.set(t,c),c.install(t)}};C.default=te,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ObjectDirective } from 'vue';
|
|
2
|
+
import { BehaviorLog, BehaviorLogClickDirectiveValue } from './behavior-types';
|
|
3
|
+
type DirectiveValue = BehaviorLogClickDirectiveValue | string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Creates the v-behavior-log directive for one logger instance. It records
|
|
6
|
+
* only explicit labels/configuration and never reads element text by default.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createBehaviorLogClickDirective(behaviorLog: BehaviorLog): ObjectDirective<HTMLElement, DirectiveValue>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BehaviorLog, BehaviorLogOptions } from './behavior-types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a company-facing behavior logger. Calling this function alone has no
|
|
4
|
+
* browser side effects; call start() or install it with app.use(...) instead.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createBehaviorLog(options: BehaviorLogOptions): BehaviorLog;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { App, ObjectDirective, ObjectPlugin } from 'vue';
|
|
2
|
+
export type BehaviorLogProperties = Record<string, unknown>;
|
|
3
|
+
export type BehaviorLogUserContext = Record<string, unknown>;
|
|
4
|
+
export type BehaviorLogMaybePromise<T> = T | Promise<T>;
|
|
5
|
+
/**
|
|
6
|
+
* The event created locally before user context is resolved and it is sent.
|
|
7
|
+
*/
|
|
8
|
+
export interface BehaviorLogEvent {
|
|
9
|
+
id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
properties: BehaviorLogProperties;
|
|
13
|
+
context?: BehaviorLogProperties;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The payload passed to the caller-provided transport function.
|
|
17
|
+
*/
|
|
18
|
+
export interface BehaviorLogDelivery extends BehaviorLogEvent {
|
|
19
|
+
sessionId?: string;
|
|
20
|
+
user?: BehaviorLogUserContext;
|
|
21
|
+
}
|
|
22
|
+
export type BehaviorLogTransport = (event: BehaviorLogDelivery) => BehaviorLogMaybePromise<void>;
|
|
23
|
+
export interface BehaviorLogTrackInput {
|
|
24
|
+
type: string;
|
|
25
|
+
properties?: BehaviorLogProperties;
|
|
26
|
+
context?: BehaviorLogProperties;
|
|
27
|
+
}
|
|
28
|
+
export interface BehaviorLogRouteLocation {
|
|
29
|
+
fullPath?: string;
|
|
30
|
+
path?: string;
|
|
31
|
+
name?: string | number | symbol | null;
|
|
32
|
+
meta?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface BehaviorLogRouteContext {
|
|
35
|
+
path?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
title?: string;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
export type BehaviorLogAfterEachGuard = (to: BehaviorLogRouteLocation, from: BehaviorLogRouteLocation, failure?: unknown) => void;
|
|
41
|
+
/**
|
|
42
|
+
* A minimal Vue Router-compatible contract. Vue Router is intentionally not a
|
|
43
|
+
* package dependency of this extension.
|
|
44
|
+
*/
|
|
45
|
+
export interface BehaviorLogRouter {
|
|
46
|
+
afterEach(guard: BehaviorLogAfterEachGuard): (() => void) | void;
|
|
47
|
+
currentRoute?: BehaviorLogRouteLocation | {
|
|
48
|
+
value: BehaviorLogRouteLocation;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface BehaviorLogRouteTrackingOptions {
|
|
52
|
+
/** Track the Router's current route when the logger is started. */
|
|
53
|
+
trackInitialRoute?: boolean;
|
|
54
|
+
/** Track a navigation even when its route identity has not changed. */
|
|
55
|
+
includeSameRoute?: boolean;
|
|
56
|
+
/** Select exactly the route fields that are allowed into the log payload. */
|
|
57
|
+
resolveRoute?: (route: BehaviorLogRouteLocation) => BehaviorLogRouteContext | undefined;
|
|
58
|
+
}
|
|
59
|
+
export interface BehaviorLogClickTrackingOptions {
|
|
60
|
+
/** The delegated root. The browser document is used when this is omitted. */
|
|
61
|
+
root?: Document | HTMLElement;
|
|
62
|
+
/** Elements matching this selector are tracked by delegated click handling. */
|
|
63
|
+
selector?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Builds a click event payload. Return false or undefined to ignore a click.
|
|
66
|
+
* Avoid deriving sensitive data from element text in this callback.
|
|
67
|
+
*/
|
|
68
|
+
getPayload?: (event: MouseEvent, element: Element) => BehaviorLogTrackInput | false | undefined;
|
|
69
|
+
}
|
|
70
|
+
export interface BehaviorLogClickDirectiveValue {
|
|
71
|
+
type?: string;
|
|
72
|
+
label?: string;
|
|
73
|
+
properties?: BehaviorLogProperties;
|
|
74
|
+
context?: BehaviorLogProperties;
|
|
75
|
+
}
|
|
76
|
+
export type BehaviorLogDropReason = 'queue-full' | 'transport-failed' | 'destroyed';
|
|
77
|
+
export type BehaviorLogErrorStage = 'click-tracking' | 'router' | 'session-context' | 'user-context' | 'transport';
|
|
78
|
+
export interface BehaviorLogErrorContext {
|
|
79
|
+
stage: BehaviorLogErrorStage;
|
|
80
|
+
event?: BehaviorLogEvent;
|
|
81
|
+
attempt?: number;
|
|
82
|
+
}
|
|
83
|
+
export interface BehaviorLogDropContext {
|
|
84
|
+
reason: BehaviorLogDropReason;
|
|
85
|
+
error?: unknown;
|
|
86
|
+
}
|
|
87
|
+
export interface BehaviorLogOptions {
|
|
88
|
+
/**
|
|
89
|
+
* Required delivery boundary. The extension does not contain a URL, request
|
|
90
|
+
* client, authentication data, or company-specific protocol.
|
|
91
|
+
*/
|
|
92
|
+
transport: BehaviorLogTransport;
|
|
93
|
+
getUserContext?: () => BehaviorLogMaybePromise<BehaviorLogUserContext | null | undefined>;
|
|
94
|
+
getSessionId?: () => BehaviorLogMaybePromise<string | null | undefined>;
|
|
95
|
+
router?: BehaviorLogRouter;
|
|
96
|
+
routeTracking?: false | BehaviorLogRouteTrackingOptions;
|
|
97
|
+
clickTracking?: false | BehaviorLogClickTrackingOptions;
|
|
98
|
+
/** Register v-behavior-log when the instance is installed into a Vue app. */
|
|
99
|
+
directiveName?: string | false;
|
|
100
|
+
/** Maximum number of in-memory events, including an in-flight event. */
|
|
101
|
+
maxQueueSize?: number;
|
|
102
|
+
/** Number of retries after the initial failed delivery attempt. */
|
|
103
|
+
maxRetries?: number;
|
|
104
|
+
/** Retry delay in milliseconds, or a delay resolver for each retry. */
|
|
105
|
+
retryDelay?: number | ((attempt: number, error: unknown) => number);
|
|
106
|
+
/** When the queue is full, drop the oldest queued event or the incoming one. */
|
|
107
|
+
dropStrategy?: 'oldest' | 'newest';
|
|
108
|
+
onError?: (error: unknown, context: BehaviorLogErrorContext) => void;
|
|
109
|
+
onDrop?: (event: BehaviorLogEvent, context: BehaviorLogDropContext) => void;
|
|
110
|
+
}
|
|
111
|
+
export interface BehaviorLog extends ObjectPlugin<[]> {
|
|
112
|
+
readonly isStarted: boolean;
|
|
113
|
+
readonly isDestroyed: boolean;
|
|
114
|
+
install(app: App): void;
|
|
115
|
+
start(): boolean;
|
|
116
|
+
track(input: BehaviorLogTrackInput): BehaviorLogEvent | undefined;
|
|
117
|
+
track(type: string, properties?: BehaviorLogProperties): BehaviorLogEvent | undefined;
|
|
118
|
+
flush(): Promise<void>;
|
|
119
|
+
createClickDirective(): ObjectDirective<HTMLElement, BehaviorLogClickDirectiveValue | string | undefined>;
|
|
120
|
+
destroy(): void;
|
|
121
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ObjectDirective } from 'vue';
|
|
2
|
+
import { LegacyApmLog, LegacyApmLogButtonDirectiveValue } from './types';
|
|
3
|
+
type DirectiveValue = LegacyApmLogButtonDirectiveValue | string | undefined;
|
|
4
|
+
type CurrentPageContext = {
|
|
5
|
+
pageName: string | null;
|
|
6
|
+
routeUrl: string | null;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A per-adapter implementation of the former `v-BtnLog` directive. It does
|
|
10
|
+
* not rely on vnode internals or a global router instance.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createLegacyApmLogButtonDirective(logger: LegacyApmLog, getCurrentPageContext: () => CurrentPageContext): ObjectDirective<HTMLElement, DirectiveValue>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LegacyApmLogPlugin } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Company behavior-log plugin, used the same way as the old internal package:
|
|
4
|
+
* `app.use(ApmLog, options)`.
|
|
5
|
+
*/
|
|
6
|
+
declare const ApmLog: LegacyApmLogPlugin;
|
|
7
|
+
export default ApmLog;
|
|
8
|
+
export type { LegacyApmLog, LegacyApmLogAction, LegacyApmLogAfterEachGuard, LegacyApmLogBeforeEachGuard, LegacyApmLogBtnLog, LegacyApmLogButtonDirectiveValue, LegacyApmLogDeviceInfo, LegacyApmLogExitSystem, LegacyApmLogFilter, LegacyApmLogFilterRule, LegacyApmLogMixinClass, LegacyApmLogOptions, LegacyApmLogPlugin, LegacyApmLogRequestBody, LegacyApmLogRequestHeaders, LegacyApmLogRouteLocation, LegacyApmLogRouter, LegacyApmLogTaskInput, LegacyApmLogText, LegacyApmLogValue, LegacyApmLogValueGetter } from './types';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LegacyApmLog, LegacyApmLogOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Adapts the former `@jiniu/apm-log-jiniu` plugin API to the public behavior
|
|
4
|
+
* logger while retaining the old report payload and endpoint convention.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createLegacyApmLog(options: LegacyApmLogOptions): LegacyApmLog;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { App, ObjectPlugin } from 'vue';
|
|
2
|
+
import { BehaviorLog, BehaviorLogEvent, BehaviorLogMaybePromise } from './behavior-types';
|
|
3
|
+
export type LegacyApmLogValue = string | number | boolean | null | undefined;
|
|
4
|
+
export type LegacyApmLogValueGetter = () => BehaviorLogMaybePromise<LegacyApmLogValue>;
|
|
5
|
+
export type LegacyApmLogFilterRule = string | RegExp | ((content: string) => boolean);
|
|
6
|
+
/**
|
|
7
|
+
* Keeps the match/ignore semantics of the former amp-log `pageFilter` option.
|
|
8
|
+
* `ignore` drops matching routes; `match` drops routes that do not match.
|
|
9
|
+
*/
|
|
10
|
+
export interface LegacyApmLogFilter {
|
|
11
|
+
mode: 'match' | 'ignore';
|
|
12
|
+
rules: LegacyApmLogFilterRule | readonly LegacyApmLogFilterRule[];
|
|
13
|
+
}
|
|
14
|
+
export interface LegacyApmLogRouteLocation {
|
|
15
|
+
fullPath?: string;
|
|
16
|
+
path?: string;
|
|
17
|
+
name?: string | number | symbol | null;
|
|
18
|
+
meta?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export type LegacyApmLogBeforeEachGuard = (to: LegacyApmLogRouteLocation, from: LegacyApmLogRouteLocation) => void;
|
|
21
|
+
export type LegacyApmLogAfterEachGuard = (to: LegacyApmLogRouteLocation, from: LegacyApmLogRouteLocation, failure?: unknown) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Deliberately small Vue Router-compatible contract. Vue Router remains a host
|
|
24
|
+
* application dependency rather than a dependency of this package.
|
|
25
|
+
*/
|
|
26
|
+
export interface LegacyApmLogRouter {
|
|
27
|
+
beforeEach?: (guard: LegacyApmLogBeforeEachGuard) => (() => void) | void;
|
|
28
|
+
afterEach?: (guard: LegacyApmLogAfterEachGuard) => (() => void) | void;
|
|
29
|
+
currentRoute?: LegacyApmLogRouteLocation | {
|
|
30
|
+
value: LegacyApmLogRouteLocation;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export type LegacyApmLogText = string | number | null | undefined;
|
|
34
|
+
/** Accepted by the old `LogClass.addTask(actionType, args)` API. */
|
|
35
|
+
export interface LegacyApmLogTaskInput {
|
|
36
|
+
fromUrl?: LegacyApmLogText;
|
|
37
|
+
fromPage?: LegacyApmLogText;
|
|
38
|
+
toUrl?: LegacyApmLogText;
|
|
39
|
+
toPage?: LegacyApmLogText;
|
|
40
|
+
pageName?: LegacyApmLogText;
|
|
41
|
+
buttonName?: LegacyApmLogText;
|
|
42
|
+
stopDuration?: number | null;
|
|
43
|
+
systemStopDuration?: number | null;
|
|
44
|
+
filter?: LegacyApmLogFilter;
|
|
45
|
+
}
|
|
46
|
+
/** The `action` object preserved in requests to `/frontEndLog/add`. */
|
|
47
|
+
export interface LegacyApmLogAction {
|
|
48
|
+
type: string;
|
|
49
|
+
fromUrl?: string | null;
|
|
50
|
+
fromPage: string | null;
|
|
51
|
+
toUrl?: string | null;
|
|
52
|
+
toPage?: string | null;
|
|
53
|
+
pageName: string | null;
|
|
54
|
+
buttonName: string | null;
|
|
55
|
+
stopDuration: number | null;
|
|
56
|
+
systemStopDuration?: number | null;
|
|
57
|
+
}
|
|
58
|
+
export interface LegacyApmLogDeviceInfo {
|
|
59
|
+
deviceSystem: string;
|
|
60
|
+
deviceModel: string;
|
|
61
|
+
deviceSystemVersion: string;
|
|
62
|
+
browser: string;
|
|
63
|
+
deviceId?: string;
|
|
64
|
+
deviceType?: string;
|
|
65
|
+
scene?: string;
|
|
66
|
+
sceneZN?: string;
|
|
67
|
+
}
|
|
68
|
+
/** The legacy backend request body, retained for existing services. */
|
|
69
|
+
export interface LegacyApmLogRequestBody {
|
|
70
|
+
sessionId: string | null;
|
|
71
|
+
account: string;
|
|
72
|
+
nickName: string;
|
|
73
|
+
deviceInfo: LegacyApmLogDeviceInfo;
|
|
74
|
+
action: LegacyApmLogAction;
|
|
75
|
+
version: string;
|
|
76
|
+
time: string;
|
|
77
|
+
}
|
|
78
|
+
export interface LegacyApmLogRequestHeaders {
|
|
79
|
+
[name: string]: string;
|
|
80
|
+
'Content-Type': 'application/json';
|
|
81
|
+
x_app_channel_id: string;
|
|
82
|
+
x_data_channel_id: string;
|
|
83
|
+
}
|
|
84
|
+
export interface LegacyApmLogOptions {
|
|
85
|
+
/** Legacy report service origin, forwarded to `${envUrl}/frontEndLog/add`. */
|
|
86
|
+
envUrl: string;
|
|
87
|
+
appChannelId?: string | number | null;
|
|
88
|
+
dataChannelId?: string | number | null;
|
|
89
|
+
router?: LegacyApmLogRouter;
|
|
90
|
+
getAccountFn?: LegacyApmLogValueGetter;
|
|
91
|
+
getNickNameFn?: LegacyApmLogValueGetter;
|
|
92
|
+
version?: string;
|
|
93
|
+
pageFilter?: LegacyApmLogFilter;
|
|
94
|
+
/** Called after one legacy task receives a successful HTTP response. */
|
|
95
|
+
success?: () => void | Promise<void>;
|
|
96
|
+
/** Called after a task has permanently failed to send. */
|
|
97
|
+
failed?: (error: unknown) => void | Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
export interface LegacyApmLogButtonDirectiveValue {
|
|
100
|
+
pageName?: LegacyApmLogText;
|
|
101
|
+
buttonName?: LegacyApmLogText;
|
|
102
|
+
}
|
|
103
|
+
export type LegacyApmLogBtnLog = (pageName?: LegacyApmLogText, buttonName?: LegacyApmLogText) => void;
|
|
104
|
+
export type LegacyApmLogExitSystem = () => void;
|
|
105
|
+
/**
|
|
106
|
+
* Compatibility bridge for the former `app.config.globalProperties.MixinClass`.
|
|
107
|
+
* Browser route and unload behavior is activated through `init(router?)`.
|
|
108
|
+
*/
|
|
109
|
+
export interface LegacyApmLogMixinClass {
|
|
110
|
+
readonly isInitialized: boolean;
|
|
111
|
+
init(router?: LegacyApmLogRouter): LegacyApmLogMixinClass;
|
|
112
|
+
initRouter(router?: LegacyApmLogRouter): LegacyApmLogMixinClass;
|
|
113
|
+
/** Retained as a no-op bridge because the public adapter has no uni-app runtime. */
|
|
114
|
+
initUniRouter(): LegacyApmLogMixinClass;
|
|
115
|
+
mountBtnFunction(): void;
|
|
116
|
+
mountExitSystemFunction(): void;
|
|
117
|
+
addListener(): LegacyApmLogMixinClass;
|
|
118
|
+
addRouterListener(): LegacyApmLogMixinClass;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* An isolated legacy adapter instance. It is intentionally not installed by
|
|
122
|
+
* the Element Custom UI root plugin; callers opt in with `app.use(instance)`.
|
|
123
|
+
*/
|
|
124
|
+
export interface LegacyApmLog extends ObjectPlugin<[]> {
|
|
125
|
+
readonly behaviorLog: BehaviorLog;
|
|
126
|
+
readonly mixinClass: LegacyApmLogMixinClass;
|
|
127
|
+
readonly options: Readonly<LegacyApmLogOptions>;
|
|
128
|
+
readonly isDestroyed: boolean;
|
|
129
|
+
install(app: App): void;
|
|
130
|
+
addTask(actionType: string, args?: LegacyApmLogTaskInput): BehaviorLogEvent | undefined;
|
|
131
|
+
btnLog: LegacyApmLogBtnLog;
|
|
132
|
+
exitSystem: LegacyApmLogExitSystem;
|
|
133
|
+
flush(): Promise<void>;
|
|
134
|
+
destroy(): void;
|
|
135
|
+
}
|
|
136
|
+
/** Default plugin shape used by `app.use(LegacyApmLog, options)`. */
|
|
137
|
+
export interface LegacyApmLogPlugin extends ObjectPlugin<[LegacyApmLogOptions]> {
|
|
138
|
+
install(app: App, options: LegacyApmLogOptions): void;
|
|
139
|
+
}
|
|
140
|
+
declare module 'vue' {
|
|
141
|
+
interface ComponentCustomProperties {
|
|
142
|
+
LogClass: LegacyApmLog;
|
|
143
|
+
MixinClass: LegacyApmLogMixinClass;
|
|
144
|
+
$btnLog: LegacyApmLogBtnLog;
|
|
145
|
+
$exitSystem: LegacyApmLogExitSystem;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
import { BehaviorLog } from './behavior-types';
|
|
3
|
+
export declare const BehaviorLogKey: InjectionKey<BehaviorLog>;
|
|
4
|
+
/** Returns the logger registered by app.use(createBehaviorLog(...)). */
|
|
5
|
+
export declare function useBehaviorLog(): BehaviorLog | undefined;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
export interface MonitorReport {
|
|
3
|
+
moduleId?: string;
|
|
4
|
+
type: string;
|
|
5
|
+
status?: string;
|
|
6
|
+
time: number;
|
|
7
|
+
pageUrl?: string;
|
|
8
|
+
appChannelId?: string;
|
|
9
|
+
dataChannelId?: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
userId?: string | number;
|
|
12
|
+
message?: unknown;
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
export type MonitorLogPayload = string | Record<string, unknown>;
|
|
17
|
+
export type MonitorBeforeDataReport = (report: MonitorReport) => MonitorReport | false | void | Promise<MonitorReport | false | void>;
|
|
18
|
+
export interface MonitorPlugin {
|
|
19
|
+
type?: string;
|
|
20
|
+
transform?: (report: MonitorReport) => void;
|
|
21
|
+
core?: (context: MonitorPluginContext) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface MonitorPluginConstructor<TOptions = unknown> {
|
|
24
|
+
new (options: TOptions): MonitorPlugin;
|
|
25
|
+
}
|
|
26
|
+
export interface MonitorPluginContext {
|
|
27
|
+
readonly options: Readonly<MonitorOptions>;
|
|
28
|
+
readonly transportData: {
|
|
29
|
+
send: (payload: MonitorLogPayload) => boolean;
|
|
30
|
+
};
|
|
31
|
+
readonly breadcrumb: {
|
|
32
|
+
push: (payload: MonitorLogPayload) => boolean;
|
|
33
|
+
};
|
|
34
|
+
readonly notify: (type: string, payload?: MonitorLogPayload) => boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface MonitorOptions {
|
|
37
|
+
dsn?: string;
|
|
38
|
+
version?: string;
|
|
39
|
+
appChannelId?: string;
|
|
40
|
+
dataChannelId?: string;
|
|
41
|
+
userId?: string | number;
|
|
42
|
+
getUserId?: () => string | number | null | undefined;
|
|
43
|
+
silentXhr?: boolean;
|
|
44
|
+
silentFetch?: boolean;
|
|
45
|
+
silentClick?: boolean;
|
|
46
|
+
silentError?: boolean;
|
|
47
|
+
silentUnhandledrejection?: boolean;
|
|
48
|
+
silentHashchange?: boolean;
|
|
49
|
+
silentHistory?: boolean;
|
|
50
|
+
silentPerformance?: boolean;
|
|
51
|
+
filterXhrUrlRegExp?: RegExp;
|
|
52
|
+
beforeDataReport?: MonitorBeforeDataReport;
|
|
53
|
+
repeatCodeError?: boolean;
|
|
54
|
+
silentWhiteScreen?: boolean;
|
|
55
|
+
skeletonProject?: boolean;
|
|
56
|
+
whiteBoxElements?: string | readonly string[];
|
|
57
|
+
silentRecordScreen?: boolean;
|
|
58
|
+
recordScreentime?: number;
|
|
59
|
+
recordScreenTypeList?: readonly string[];
|
|
60
|
+
useImgUpload?: boolean;
|
|
61
|
+
throttleDelayTime?: number;
|
|
62
|
+
overTime?: number;
|
|
63
|
+
maxBreadcrumbs?: number;
|
|
64
|
+
beforePushBreadcrumb?: (data: unknown) => unknown;
|
|
65
|
+
handleHttpStatus?: (data: unknown) => boolean;
|
|
66
|
+
defHttp?: unknown;
|
|
67
|
+
router?: unknown;
|
|
68
|
+
}
|
|
69
|
+
export interface MonitorClient {
|
|
70
|
+
readonly started: boolean;
|
|
71
|
+
readonly options: Readonly<MonitorOptions> | undefined;
|
|
72
|
+
init: (options?: MonitorOptions) => MonitorClient;
|
|
73
|
+
install: (app: App, options?: MonitorOptions) => void;
|
|
74
|
+
log: (payload: MonitorLogPayload) => boolean;
|
|
75
|
+
errorBoundary: (error: unknown) => boolean;
|
|
76
|
+
use: <TOptions>(plugin: MonitorPluginConstructor<TOptions>, options?: TOptions) => MonitorPlugin | undefined;
|
|
77
|
+
stop: () => void;
|
|
78
|
+
destroy: () => void;
|
|
79
|
+
}
|
|
80
|
+
declare const _default: MonitorClient;
|
|
81
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LegacyMonitorClient, LegacyMonitorOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a separately managed `monitor-jiniu` compatibility adapter.
|
|
4
|
+
* It has no browser side effects until `init()` or `install()` is called.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createLegacyMonitor(defaultOptions?: LegacyMonitorOptions): LegacyMonitorClient;
|
|
7
|
+
declare const legacyMonitor: LegacyMonitorClient;
|
|
8
|
+
export default legacyMonitor;
|
|
9
|
+
export type { LegacyBeforeDataReport, LegacyMonitorClient, LegacyMonitorLogPayload, LegacyMonitorMapping, LegacyMonitorOptions, LegacyMonitorPlugin, LegacyMonitorPluginConstructor, LegacyMonitorPluginContext, LegacyMonitorReport, LegacyUnsupportedOption, LegacyUnsupportedOptionNotice, LegacyUnsupportedOptionHandler, LegacyMonitorTransport, LegacyMonitorRuntime } from './types';
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
export type MonitorLevel = 'debug' | 'info' | 'warning' | 'error' | 'fatal';
|
|
3
|
+
export type MonitorEventType = 'exception' | 'message' | 'resource' | 'unhandledrejection' | 'navigation' | 'performance' | 'request';
|
|
4
|
+
export type MonitorContext = Record<string, unknown>;
|
|
5
|
+
export type MonitorTags = Record<string, string | number | boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* A string beginning with `/` matches the request pathname (and optional query
|
|
8
|
+
* string) even when the browser request URL is absolute. Other strings match a
|
|
9
|
+
* substring of the full URL; regular expressions and functions receive it.
|
|
10
|
+
*/
|
|
11
|
+
export type MonitorUrlMatcher = string | RegExp | ((url: string) => boolean);
|
|
12
|
+
export interface MonitorExceptionData {
|
|
13
|
+
name: string;
|
|
14
|
+
message: string;
|
|
15
|
+
stack?: string;
|
|
16
|
+
source?: 'manual' | 'window.error' | 'vue' | 'unhandledrejection';
|
|
17
|
+
filename?: string;
|
|
18
|
+
line?: number;
|
|
19
|
+
column?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface MonitorMessageData {
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
24
|
+
export interface MonitorResourceData {
|
|
25
|
+
element: string;
|
|
26
|
+
url: string;
|
|
27
|
+
}
|
|
28
|
+
export interface MonitorNavigationData {
|
|
29
|
+
source: 'history' | 'hashchange' | 'popstate';
|
|
30
|
+
method?: 'pushState' | 'replaceState';
|
|
31
|
+
from: string;
|
|
32
|
+
to: string;
|
|
33
|
+
duration: number;
|
|
34
|
+
}
|
|
35
|
+
export interface MonitorPerformanceData {
|
|
36
|
+
navigationType?: string;
|
|
37
|
+
duration: number;
|
|
38
|
+
redirect: number;
|
|
39
|
+
dns: number;
|
|
40
|
+
connection: number;
|
|
41
|
+
request: number;
|
|
42
|
+
response: number;
|
|
43
|
+
domInteractive: number;
|
|
44
|
+
domContentLoaded: number;
|
|
45
|
+
load: number;
|
|
46
|
+
}
|
|
47
|
+
export interface MonitorRequestData {
|
|
48
|
+
kind: 'fetch' | 'xhr';
|
|
49
|
+
method: string;
|
|
50
|
+
url: string;
|
|
51
|
+
status?: number;
|
|
52
|
+
duration: number;
|
|
53
|
+
ok: boolean;
|
|
54
|
+
error?: string;
|
|
55
|
+
}
|
|
56
|
+
interface MonitorEventBase<TType extends MonitorEventType, TData> {
|
|
57
|
+
type: TType;
|
|
58
|
+
level: MonitorLevel;
|
|
59
|
+
timestamp: number;
|
|
60
|
+
url: string;
|
|
61
|
+
context: MonitorContext;
|
|
62
|
+
tags: MonitorTags;
|
|
63
|
+
data: TData;
|
|
64
|
+
}
|
|
65
|
+
export type MonitorEvent = MonitorEventBase<'exception', MonitorExceptionData> | MonitorEventBase<'message', MonitorMessageData> | MonitorEventBase<'resource', MonitorResourceData> | MonitorEventBase<'unhandledrejection', MonitorExceptionData> | MonitorEventBase<'navigation', MonitorNavigationData> | MonitorEventBase<'performance', MonitorPerformanceData> | MonitorEventBase<'request', MonitorRequestData>;
|
|
66
|
+
/**
|
|
67
|
+
* Network APIs for monitor reporting. Use these methods inside `transport` and
|
|
68
|
+
* recorder callbacks rather than `window.fetch` or a newly-created XHR. They
|
|
69
|
+
* bypass request reporting in every EasyOil monitor attached to the same
|
|
70
|
+
* browser window, preventing cross-monitor transport loops. Application
|
|
71
|
+
* traffic that does not use this context continues to be observed normally.
|
|
72
|
+
*/
|
|
73
|
+
export interface MonitorTransportContext {
|
|
74
|
+
fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
75
|
+
createXMLHttpRequest: () => XMLHttpRequest;
|
|
76
|
+
}
|
|
77
|
+
export type MonitorTransport = (event: MonitorEvent, context: MonitorTransportContext) => void | Promise<void>;
|
|
78
|
+
export type MonitorSanitizer = (event: MonitorEvent) => MonitorEvent | null;
|
|
79
|
+
export interface MonitorRedactionOptions {
|
|
80
|
+
/** Object keys whose values should be redacted before they reach transport. */
|
|
81
|
+
keys?: readonly (string | RegExp)[];
|
|
82
|
+
/** Query-string keys that should be redacted in event URLs. */
|
|
83
|
+
queryParams?: readonly (string | RegExp)[];
|
|
84
|
+
/** Replacement text used for redacted values. Defaults to `[REDACTED]`. */
|
|
85
|
+
replacement?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface MonitorRequestOptions {
|
|
88
|
+
/** Patch and observe `window.fetch`. */
|
|
89
|
+
fetch?: boolean;
|
|
90
|
+
/** Patch and observe `XMLHttpRequest`. */
|
|
91
|
+
xhr?: boolean;
|
|
92
|
+
/** Report successful requests too. Failed and slow requests are always reported. */
|
|
93
|
+
includeSuccessful?: boolean;
|
|
94
|
+
/** Report successful requests whose duration reaches this threshold in milliseconds. */
|
|
95
|
+
slowThreshold?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Optional integration point for a recorder such as rrweb. The package neither
|
|
99
|
+
* imports nor starts a recorder unless the host application supplies one.
|
|
100
|
+
*/
|
|
101
|
+
export interface MonitorRecorder {
|
|
102
|
+
start?: (context: MonitorTransportContext) => void | Promise<void>;
|
|
103
|
+
stop?: (context: MonitorTransportContext) => void | Promise<void>;
|
|
104
|
+
capture?: (event: MonitorEvent, context: MonitorTransportContext) => void | Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
export interface MonitorOptions {
|
|
107
|
+
/**
|
|
108
|
+
* Receives sanitized events. No HTTP endpoint is built into this extension.
|
|
109
|
+
* Use the supplied context for report requests so monitors attached to the
|
|
110
|
+
* same browser window do not capture transport traffic.
|
|
111
|
+
*/
|
|
112
|
+
transport?: MonitorTransport;
|
|
113
|
+
/** Sampling rate from 0 to 1. Defaults to 1. */
|
|
114
|
+
sampleRate?: number;
|
|
115
|
+
/** Runs after built-in redaction. Return `null` to suppress an event. */
|
|
116
|
+
sanitize?: MonitorSanitizer;
|
|
117
|
+
redact?: MonitorRedactionOptions;
|
|
118
|
+
/**
|
|
119
|
+
* Requests matching these rules are never reported. A string such as
|
|
120
|
+
* `/monitor/report` matches that pathname on any origin; use it for legacy
|
|
121
|
+
* transports that cannot use the transport context APIs.
|
|
122
|
+
*/
|
|
123
|
+
ignoreUrls?: readonly MonitorUrlMatcher[];
|
|
124
|
+
/** Opt-in request instrumentation. Disabled by default. */
|
|
125
|
+
captureRequests?: boolean | MonitorRequestOptions;
|
|
126
|
+
captureNavigation?: boolean;
|
|
127
|
+
capturePerformance?: boolean;
|
|
128
|
+
captureGlobalErrors?: boolean;
|
|
129
|
+
captureUnhandledRejections?: boolean;
|
|
130
|
+
captureResourceErrors?: boolean;
|
|
131
|
+
/** Static context sent with every event. */
|
|
132
|
+
context?: MonitorContext;
|
|
133
|
+
/** Dynamic context resolved when an event is reported, for example user identity. */
|
|
134
|
+
getContext?: () => MonitorContext | undefined;
|
|
135
|
+
tags?: MonitorTags;
|
|
136
|
+
release?: string;
|
|
137
|
+
environment?: string;
|
|
138
|
+
/** Allows a host or test to provide a browser window explicitly. */
|
|
139
|
+
window?: Window;
|
|
140
|
+
/** Explicit optional recorder integration. It is never enabled by default. */
|
|
141
|
+
recorder?: MonitorRecorder;
|
|
142
|
+
/** Injectable only for deterministic tests. */
|
|
143
|
+
random?: () => number;
|
|
144
|
+
/** Injectable only for deterministic tests. */
|
|
145
|
+
now?: () => number;
|
|
146
|
+
}
|
|
147
|
+
export interface MonitorVuePluginOptions {
|
|
148
|
+
/** Start monitoring when the host explicitly calls `app.use(plugin)`. */
|
|
149
|
+
startOnInstall?: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface MonitorVuePlugin {
|
|
152
|
+
install: (app: App) => void;
|
|
153
|
+
}
|
|
154
|
+
export interface MonitorClient {
|
|
155
|
+
readonly started: boolean;
|
|
156
|
+
/** Starts browser instrumentation. Returns false outside a browser or after destroy. */
|
|
157
|
+
start: () => boolean;
|
|
158
|
+
/** Stops instrumentation and restores browser APIs. The client can be started again. */
|
|
159
|
+
stop: () => void;
|
|
160
|
+
/** Final cleanup, including installed Vue error handlers and the optional recorder. */
|
|
161
|
+
destroy: () => void;
|
|
162
|
+
captureException: (exception: unknown, context?: MonitorContext) => void;
|
|
163
|
+
captureMessage: (message: string, level?: MonitorLevel, context?: MonitorContext) => void;
|
|
164
|
+
createVuePlugin: (options?: MonitorVuePluginOptions) => MonitorVuePlugin;
|
|
165
|
+
}
|
|
166
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MonitorClient, MonitorOptions } from './runtime-types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a browser monitor without starting it. Calling `start()` is always
|
|
4
|
+
* required before it attaches listeners or patches browser APIs.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createMonitor(options?: MonitorOptions): MonitorClient;
|