@heimdallr-sdk/fetch
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -1,1 +0,1 @@ | ||
var HEIMDALLR_FETCH=function(){"use strict";var e,t,r,o,n,a,s,c,E,i,l,O,u,R,p,C,d,x,S,h,D,T,m,f,A,I,L,g,M,P,U,b,v,H;(e||(e={})).NAME="@heimdallr-sdk","[".concat(e.NAME,"]:"),(t||(t={})).VUE="Vue",(o=r||(r={})).SESSION="HEIMDALLR_SDK_SESSION_ID",o.APP="HEIMDALLR_SDK_APP_ID",(a=n||(n={})).GET="GET",a.POST="POST",a.PUT="PUT",a.DELETE="DELETE",(c=s||(s={})).API="api",c.DOM="dom",c.PERFORMANCE="performance",c.ROUTE="route",c.ERROR="error",c.CONSOLE="console",c.CUSTOMER="customer",c.VUE="vue",c.LIFECYCLE="lifeCycle",c.EXTEND="extend",(E||(E={})).UNCAUGHTEXCEPTION="uncaughtException",(l=i||(i={})).CODEERROR="code",l.RESOURCEERROR="resource",l.UNHANDLEDREJECTION="unhandledrejection",l.PAGECRASH="pageCrash",(O||(O={})).CLICK="click",(R=u||(u={})).LOG="log",R.INFO="info",R.WARN="warn",R.ERROR="error",R.ASSERT="assert",(C=p||(p={})).FETCH="fetch",C.XHR="xhr",(x=d||(d={})).FMP="fmp",x.FPS="fps",x.BASIC="basic",x.VITALS="vitals",x.RESOURCE="resource",(h=S||(S={})).HASH="hash",h.HISTORY="history",(D||(D={})).CUSTOMER="customer",(m=T||(T={})).LOCAL="local",m.SESSION="session",m.COOKIE="cookie",m.GLOBAL="global",(A=f||(f={})).BEACON="beacon",A.IMG="img",A.GET="get",(L=I||(I={})).LOAD="enter",L.UNLOAD="leave",(M=g||(g={})).MOBILE="mobile",M.PC="pc",(P||(P={})).ERROR="error",(b=U||(U={})).BASIC="basic",b.RESOURCE="resource",b.FMP="fmp",b.FPS="fps",b.VITALS="vitals",(H=v||(v={})).ROUTE="Route",H.CLICK="UI.Click",H.CONSOLE="Console",H.XHR="Xhr",H.FETCH="Fetch",H.UNHANDLEDREJECTION="Unhandledrejection",H.RESOURCE="Resource",H.CODE_ERROR="CodeError",H.CUSTOMER="Customer",H.FRAMEWORK="Framework",H.LIFECYCLE="LifeCycle",H.CRASH="Crash";var N=function(e){var t="".concat((e||"").replace(/^http(s|):/,"").split("?")[0]),r=t.length-1;return"/"===t[r]?t.substring(0,r):t};var w=function(e,t){void 0===e&&(e="Y-M-D h:m:s"),void 0===t&&(t=Date.now());var r=new Date(t||Date.now()),o={Y:"".concat(r.getFullYear()),M:"".concat(r.getMonth()+1),D:"".concat(r.getDate()),h:r.getHours(),m:r.getMinutes(),s:r.getSeconds()},n=function(e){return e>10?e:"0"+e};return(e||"Y-M-D h:m:s").replace("Y",o.Y).replace("M",o.M).replace("D",o.D).replace("h",n(o.h)).replace("m",n(o.m)).replace("s",n(o.s))};var y=Object.defineProperty,F=Object.defineProperties,j=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,K=(e,t,r)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,k=(e,t)=>{for(var r in t||(t={}))Y.call(t,r)&&K(e,r,t[r]);if(G)for(var r of G(t))_.call(t,r)&&K(e,r,t[r]);return e};return{name:"fetchPlugin",monitor(e){const{ignoreUrls:t=[]}=this.getOptions(),{initUrl:r,uploadUrl:o}=this.context,a=[...t,o,r].map((e=>N(e)));!function(e,t,r,o){if(void 0!==e&&(t in e||o)){var n=r(e[t]);"function"==typeof n&&(e[t]=n)}}(window,p.FETCH,(t=>function(r,o={}){const s=Date.now(),c={request:{url:r,method:o&&o.method||n.GET,data:o&&o.body},time:s,response:{}},E=new Headers(o.headers||{});var i;Object.assign(E,{setRequestHeader:E.set}),i=k({},o),o=F(i,j({headers:E}));const l=a.includes(N(r));return t.apply(window,[r,o]).then((t=>{const r=t.clone(),o=Date.now();return c.elapsedTime=o-s,c.response.status=r.status,r.text().then((t=>{l||(c.response.data=t,e(c))})),t}),(t=>{if(l)return;const r=Date.now();throw c.elapsedTime=r-s,c.response.status=0,e(c),t}))}))},transform(e){const t=(r=(new Date).getTime(),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})));var r;return this.breadcrumb.unshift({eventId:t,type:v.FETCH,data:e}),{id:t,time:w(),type:s.API,data:k({sub_type:p.FETCH},e)}}}}(); | ||
var HEIMDALLR_FETCH=function(){"use strict";var e,t,r,o,n,a,s,E,c,i,O,R,l,u,C,T,p,A,d,I,h,L,S,D,x,N,m,f,U,g,P,F,M,H,v,b,w,y,G,j,B,Y,_,k,K;(e||(e={})).NAME="@heimdallr-sdk","[".concat(e.NAME,"]:"),(r=t||(t={})).FATAL="fatal",r.ERROR="error",r.WARN="warn",r.INFO="info",r.DEBUG="debug",(n=o||(o={})).SESSION="HEIMDALLR_SDK_SESSION_ID",n.APP="HEIMDALLR_SDK_APP_ID",(s=a||(a={})).GET="GET",s.POST="POST",s.PUT="PUT",s.DELETE="DELETE",(c=E||(E={})).API="api",c.DOM="dom",c.PERFORMANCE="performance",c.ROUTE="route",c.ERROR="error",c.CONSOLE="console",c.CUSTOMER="customer",c.VUE="vue",c.LIFECYCLE="lifeCycle",c.EXTEND="extend",(O=i||(i={})).CODEERROR="code",O.RESOURCEERROR="resource",O.UNHANDLEDREJECTION="unhandledrejection",O.PAGECRASH="pageCrash",(l=R||(R={})).UNCAUGHTEXCEPTION="uncaughtException",l.UNHANDLEDREJECTION="unhandledrejection",(u||(u={})).UNCAUGHTEXCEPTION="uncaughtException",(C||(C={})).CLICK="click",(p=T||(T={})).LOG="log",p.INFO="info",p.WARN="warn",p.ERROR="error",p.ASSERT="assert",(d=A||(A={})).FETCH="fetch",d.XHR="xhr",(h=I||(I={})).FMP="fmp",h.FPS="fps",h.BASIC="basic",h.VITALS="vitals",h.RESOURCE="resource",(S=L||(L={})).HASH="hash",S.HISTORY="history",(D||(D={})).CUSTOMER="customer",(N=x||(x={})).LOCAL="local",N.SESSION="session",N.COOKIE="cookie",N.GLOBAL="global",(f=m||(m={})).BEACON="beacon",f.IMG="img",f.GET="get",(g=U||(U={})).LOAD="enter",g.UNLOAD="leave",(F=P||(P={})).MOBILE="mobile",F.PC="pc",(M||(M={})).ERROR="error",(v=H||(H={})).BROWSER="browser",v.NODE="nodejs",v.WECHAT="wechat",(w=b||(b={})).ROUTE="Route",w.CLICK="UI.Click",w.CONSOLE="Console",w.XHR="Xhr",w.FETCH="Fetch",w.UNHANDLEDREJECTION="Unhandledrejection",w.RESOURCE="Resource",w.CODE_ERROR="CodeError",w.CUSTOMER="Customer",w.FRAMEWORK="Framework",w.LIFECYCLE="LifeCycle",w.CRASH="Crash",(G=y||(y={})).API="Api",G.ROUTE="Route",G.CLICK="UI.Click",G.ERROR="Error",G.LIFECYCLE="LifeCycle",G.CUSTOMER="Customer",(B=j||(j={})).SWITCHTAB="switchTab",B.RELAUNCH="reLaunch",B.REDIRECTTO="redirectTo",B.NAVIGATETO="navigateTo",B.NAVIGATEBACK="navigateBack",B.NAVIGATETOMINIPROGRAM="navigateToMiniProgram",B.ROUTEFAIL="routeFail",(_=Y||(Y={})).REQUEST="request",_.DOWNLOADFILE="downloadFile",_.UPLOADFILE="uploadFile",(K=k||(k={})).BASIC="basic",K.RESOURCE="resource",K.FMP="fmp",K.FPS="fps",K.VITALS="vitals";var W=function(e){var t="".concat((e||"").replace(/^http(s|):/,"").split("?")[0]),r=t.length-1;return"/"===t[r]?t.substring(0,r):t};var V=function(e,t){void 0===e&&(e="Y-M-D h:m:s"),void 0===t&&(t=Date.now());var r=new Date(t||Date.now()),o={Y:"".concat(r.getFullYear()),M:"".concat(r.getMonth()+1),D:"".concat(r.getDate()),h:r.getHours(),m:r.getMinutes(),s:r.getSeconds()},n=function(e){return e>10?e:"0"+e};return(e||"Y-M-D h:m:s").replace("Y",o.Y).replace("M",o.M).replace("D",o.D).replace("h",n(o.h)).replace("m",n(o.m)).replace("s",n(o.s))};var X=Object.defineProperty,q=Object.defineProperties,J=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,Z=(e,t,r)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ee=(e,t)=>{for(var r in t||(t={}))Q.call(t,r)&&Z(e,r,t[r]);if($)for(var r of $(t))z.call(t,r)&&Z(e,r,t[r]);return e};return{name:"fetchPlugin",monitor(e){const{ignoreUrls:t=[]}=this.getOptions(),{initUrl:r,uploadUrl:o}=this.context,n=[...t,o,r].map((e=>W(e)));!function(e,t,r,o){if(void 0!==e&&(t in e||o)){var n=r(e[t]);"function"==typeof n&&(e[t]=n)}}(window,A.FETCH,(t=>function(r,o={}){const s=Date.now(),E={request:{url:r,method:o&&o.method||a.GET,data:o&&o.body},time:s,response:{}},c=new Headers(o.headers||{});var i;Object.assign(c,{setRequestHeader:c.set}),i=ee({},o),o=q(i,J({headers:c}));const O=n.includes(W(r));return t.apply(window,[r,o]).then((t=>{const r=t.clone(),o=Date.now();return E.elapsedTime=o-s,E.response.status=r.status,r.text().then((t=>{O||(E.response.data=t,e(E))})),t}),(t=>{if(O)return;const r=Date.now();throw E.elapsedTime=r-s,E.response.status=0,e(E),t}))}))},transform(e){const r=(o=(new Date).getTime(),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(o+16*Math.random())%16|0;return o=Math.floor(o/16),("x"==e?t:3&t|8).toString(16)})));var o;const{request:{method:n,url:a,data:s},elapsedTime:c=0,response:{status:i}}=e;return this.breadcrumb.unshift({eventId:r,type:b.FETCH,level:200!=i?t.WARN:t.INFO,message:`${n} "${a}" width "${JSON.stringify(s)}" took ${c/1e3} seconds`}),{id:r,time:V(),type:E.API,data:ee({sub_type:A.FETCH},e)}}}}(); |
@@ -13,6 +13,10 @@ (function (global, factory) { | ||
var BaseBreadcrumbTypes; | ||
(function(BaseBreadcrumbTypes2) { | ||
BaseBreadcrumbTypes2["VUE"] = "Vue"; | ||
})(BaseBreadcrumbTypes || (BaseBreadcrumbTypes = {})); | ||
var BreadcrumbLevel; | ||
(function(BreadcrumbLevel2) { | ||
BreadcrumbLevel2["FATAL"] = "fatal"; | ||
BreadcrumbLevel2["ERROR"] = "error"; | ||
BreadcrumbLevel2["WARN"] = "warn"; | ||
BreadcrumbLevel2["INFO"] = "info"; | ||
BreadcrumbLevel2["DEBUG"] = "debug"; | ||
})(BreadcrumbLevel || (BreadcrumbLevel = {})); | ||
@@ -44,6 +48,2 @@ var StoreKeyType; | ||
})(EventTypes || (EventTypes = {})); | ||
var NodeErrorTypes; | ||
(function(NodeErrorTypes2) { | ||
NodeErrorTypes2["UNCAUGHTEXCEPTION"] = "uncaughtException"; | ||
})(NodeErrorTypes || (NodeErrorTypes = {})); | ||
var BrowserErrorTypes; | ||
@@ -56,2 +56,11 @@ (function(BrowserErrorTypes2) { | ||
})(BrowserErrorTypes || (BrowserErrorTypes = {})); | ||
var NodeErrorTypes; | ||
(function(NodeErrorTypes2) { | ||
NodeErrorTypes2["UNCAUGHTEXCEPTION"] = "uncaughtException"; | ||
NodeErrorTypes2["UNHANDLEDREJECTION"] = "unhandledrejection"; | ||
})(NodeErrorTypes || (NodeErrorTypes = {})); | ||
var WxErrorTypes; | ||
(function(WxErrorTypes2) { | ||
WxErrorTypes2["UNCAUGHTEXCEPTION"] = "uncaughtException"; | ||
})(WxErrorTypes || (WxErrorTypes = {})); | ||
var DomTypes; | ||
@@ -118,12 +127,8 @@ (function(DomTypes2) { | ||
})(VueTypes || (VueTypes = {})); | ||
var PerformanceFeat; | ||
(function(PerformanceFeat2) { | ||
PerformanceFeat2["BASIC"] = "basic"; | ||
PerformanceFeat2["RESOURCE"] = "resource"; | ||
PerformanceFeat2["FMP"] = "fmp"; | ||
PerformanceFeat2["FPS"] = "fps"; | ||
PerformanceFeat2["VITALS"] = "vitals"; | ||
})(PerformanceFeat || (PerformanceFeat = {})); | ||
var PlatformTypes; | ||
(function(PlatformTypes2) { | ||
PlatformTypes2["BROWSER"] = "browser"; | ||
PlatformTypes2["NODE"] = "nodejs"; | ||
PlatformTypes2["WECHAT"] = "wechat"; | ||
})(PlatformTypes || (PlatformTypes = {})); | ||
var BrowserBreadcrumbTypes; | ||
@@ -144,3 +149,37 @@ (function(BrowserBreadcrumbTypes2) { | ||
})(BrowserBreadcrumbTypes || (BrowserBreadcrumbTypes = {})); | ||
var WxBreadcrumbTypes; | ||
(function(WxBreadcrumbTypes2) { | ||
WxBreadcrumbTypes2["API"] = "Api"; | ||
WxBreadcrumbTypes2["ROUTE"] = "Route"; | ||
WxBreadcrumbTypes2["CLICK"] = "UI.Click"; | ||
WxBreadcrumbTypes2["ERROR"] = "Error"; | ||
WxBreadcrumbTypes2["LIFECYCLE"] = "LifeCycle"; | ||
WxBreadcrumbTypes2["CUSTOMER"] = "Customer"; | ||
})(WxBreadcrumbTypes || (WxBreadcrumbTypes = {})); | ||
var WxRouteEvents; | ||
(function(WxRouteEvents2) { | ||
WxRouteEvents2["SWITCHTAB"] = "switchTab"; | ||
WxRouteEvents2["RELAUNCH"] = "reLaunch"; | ||
WxRouteEvents2["REDIRECTTO"] = "redirectTo"; | ||
WxRouteEvents2["NAVIGATETO"] = "navigateTo"; | ||
WxRouteEvents2["NAVIGATEBACK"] = "navigateBack"; | ||
WxRouteEvents2["NAVIGATETOMINIPROGRAM"] = "navigateToMiniProgram"; | ||
WxRouteEvents2["ROUTEFAIL"] = "routeFail"; | ||
})(WxRouteEvents || (WxRouteEvents = {})); | ||
var WxXhrTypes; | ||
(function(WxXhrTypes2) { | ||
WxXhrTypes2["REQUEST"] = "request"; | ||
WxXhrTypes2["DOWNLOADFILE"] = "downloadFile"; | ||
WxXhrTypes2["UPLOADFILE"] = "uploadFile"; | ||
})(WxXhrTypes || (WxXhrTypes = {})); | ||
var PerformanceFeat; | ||
(function(PerformanceFeat2) { | ||
PerformanceFeat2["BASIC"] = "basic"; | ||
PerformanceFeat2["RESOURCE"] = "resource"; | ||
PerformanceFeat2["FMP"] = "fmp"; | ||
PerformanceFeat2["FPS"] = "fps"; | ||
PerformanceFeat2["VITALS"] = "vitals"; | ||
})(PerformanceFeat || (PerformanceFeat = {})); | ||
var getUrlPath = function(url) { | ||
@@ -270,6 +309,12 @@ var path = "".concat((url || "").replace(/^http(s|):/, "").split("?")[0]); | ||
const id = generateUUID(); | ||
const { | ||
request: { method, url, data: params }, | ||
elapsedTime = 0, | ||
response: { status } | ||
} = collectedData; | ||
this.breadcrumb.unshift({ | ||
eventId: id, | ||
type: BrowserBreadcrumbTypes.FETCH, | ||
data: collectedData | ||
level: status != 200 ? BreadcrumbLevel.WARN : BreadcrumbLevel.INFO, | ||
message: `${method} "${url}" width "${JSON.stringify(params)}" took ${elapsedTime / 1e3} seconds` | ||
}); | ||
@@ -276,0 +321,0 @@ return { |
@@ -21,3 +21,3 @@ var __assign = (this && this.__assign) || function () { | ||
}; | ||
import { BrowserBreadcrumbTypes, EventTypes, HttpTypes, MethodTypes } from '@heimdallr-sdk/types'; | ||
import { BreadcrumbLevel, BrowserBreadcrumbTypes, EventTypes, HttpTypes, MethodTypes } from '@heimdallr-sdk/types'; | ||
import { formatDate, generateUUID, getUrlPath, replaceOld } from '@heimdallr-sdk/utils'; | ||
@@ -76,6 +76,8 @@ var fetchPlugin = { | ||
var id = generateUUID(); | ||
var _a = collectedData.request, method = _a.method, url = _a.url, params = _a.data, _b = collectedData.elapsedTime, elapsedTime = _b === void 0 ? 0 : _b, status = collectedData.response.status; | ||
this.breadcrumb.unshift({ | ||
eventId: id, | ||
type: BrowserBreadcrumbTypes.FETCH, | ||
data: collectedData, | ||
level: status != 200 ? BreadcrumbLevel.WARN : BreadcrumbLevel.INFO, | ||
message: "".concat(method, " \"").concat(url, "\" width \"").concat(JSON.stringify(params), "\" took ").concat(elapsedTime / 1000, " seconds") | ||
}); | ||
@@ -82,0 +84,0 @@ return { |
{ | ||
"name": "@heimdallr-sdk/fetch", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "A Plugin For Browser SDK", | ||
@@ -39,6 +39,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"@heimdallr-sdk/types": "^0.0.10", | ||
"@heimdallr-sdk/utils": "^0.0.13" | ||
"@heimdallr-sdk/types": "^0.0.11", | ||
"@heimdallr-sdk/utils": "^0.0.14" | ||
}, | ||
"gitHead": "6d63b337568e49a61f65f6c998f48e385f847910" | ||
"gitHead": "84a816567f6ba7b5d1c51aa04dfe74e784859481" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24685
431
+ Added@heimdallr-sdk/types@0.0.11(transitive)
+ Added@heimdallr-sdk/utils@0.0.14(transitive)
- Removed@heimdallr-sdk/types@0.0.10(transitive)
- Removed@heimdallr-sdk/utils@0.0.13(transitive)
Updated@heimdallr-sdk/types@^0.0.11
Updated@heimdallr-sdk/utils@^0.0.14