Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uniapp 微信小程序 引入探针代码后报Cannot read property 'apply' of undefined #202

Open
592229712 opened this issue Sep 6, 2021 · 8 comments

Comments

@592229712
Copy link

image
按教程引入
image

@a597873885
Copy link
Owner

@592229712 你是用的uni-app探针吗?是转成微信小程序,还是转成h5的

@592229712
Copy link
Author

592229712 commented Sep 6, 2021

@a597873885 微信小程序,请问如何调试探针源码

@a597873885
Copy link
Owner

@592229712 这个嘛,按理说应该不会出问题啊。 你把探针发出来看下

@592229712
Copy link
Author

!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){let r=uni;var n,o;o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",(n=r).btoa=n.btoa||function(e){for(var t,r,n,a,s="",i=0,c=(e=String(e)).length%3;i<e.length;){if((r=e.charCodeAt(i++))>255||(n=e.charCodeAt(i++))>255||(a=e.charCodeAt(i++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=o.charAt((t=r<<16|n<<8|a)>>18&63)+o.charAt(t>>12&63)+o.charAt(t>>6&63)+o.charAt(63&t)}return c?s.slice(0,c-3)+"===".substring(c):s};var a="webfunny52691",s="2.8.1",i="wmonitor.brightscholar.net",c="http://"+i,u=c+"/server/upMog",g="CUSTOMER_PV",h="CUS_LEAVE",l="HTTP_LOG",f="JS_ERROR",d="LAST_BROWSE_DATE",p="WM_PAGE_ENTRY_TIME",y="WM_VISIT_PAGE_COUNT",m=[f,g,l];class v{static getUuid(){var e=v.formatDate((new Date).getTime(),"yMdhms");return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16Math.random()|0;return("x"==e?t:3&t|8).toString(16)})+"-"+e}static getCustomerKey(){var e=v.getUuid(),t=r.getStorageSync("monitorCustomerKey");return t||(r.setStorage({key:"monitorCustomerKey",data:e}),t=e),t}static isTodayBrowse(e){var t=r.getStorageSync(e),n=(new Date).getFullYear()+"-"+((new Date).getMonth()+1)+"-"+(new Date).getDate();return t&&n==t?!(!t||n!=t):(r.setStorageSync(e,n),!1)}static formatDate(e,t){var r=new Date(e).getFullYear(),n=new Date(e).getMonth()+1,o=new Date(e).getDate(),a=new Date(e).getHours(),s=new Date(e).getMinutes(),i=new Date(e).getSeconds();return n=n>9?n:"0"+n,o=o>9?o:"0"+o,a=a>9?a:"0"+a,s=s>9?s:"0"+s,i=i>9?i:"0"+i,t.replace("y",r).replace("M",n).replace("d",o).replace("h",a).replace("m",s).replace("s",i)}static getPageKey(){var e=r.getStorageSync("monitorPageKey"),t=v.getUuid();return e&&/^[0-9a-z]{8}(-[0-9a-z]{4}){3}-[0-9a-z]{12}-\d{13}$/.test(e)||(e=t),e}static setPageKey(){r.setStorage({key:"monitorPageKey",data:v.getUuid()})}static ajax(e,t,n,o,a){r.request({method:e,url:t,data:n,header:{"Content-Type":"application/json"},success:e=>{"function"==typeof o&&o(e)},fail:e=>{"function"==typeof a&&a(e)}})}static encryptObj(e){if(e instanceof Array){for(var t=[],r=0;r<e.length;++r)t[r]=v.encryptObj(e[r]);return t}if(e instanceof Object){t={};for(var r in e)t[r]=v.encryptObj(e[r]);return t}return(e+="").length>50&&(e=e.substring(0,10)+"***"+e.substring(e.length-9,e.length)),e}static getDevice(){return r.getSystemInfoSync()}static b64EncodeUnicode(e){var t=encodeURIComponent(e);try{return r.btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}catch(e){return t}}static utf8_encode(e){if(!e)return"";var t="";e=e.replace(/\r\n/g,"\n");for(var r=0;r<e.length;r++){var n=e.charCodeAt(r);n<128?t+=String.fromCharCode(n):n>127&&n<2048?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t}}class S{constructor(){var e=r.getStorageSync("wmUserInfo"),t=e?JSON.parse(e):{},n=getCurrentPages().length?getCurrentPages()[0].route:"App Launched";this.wmVersion=s,this.happenTime=(new Date).getTime(),this.webMonitorId=a,this.simpleUrl=n,this.completeUrl=n,this.customerKey=v.getCustomerKey(),this.userId=t.userId,this.projectVersion=t.projectVersion||"",this.firstUserParam=v.b64EncodeUnicode(t.userTag||""),this.secondUserParam=v.b64EncodeUnicode(t.secondUserParam||"")}handleLogInfo(e,t){var n=r.getStorageSync(e),o=n||[];o.push(t),r.setStorageSync(e,o)}}class x extends S{constructor(e,t,r,n){super();var o=v.getDevice();this.uploadType=g,this.pageKey=v.getPageKey(),this.deviceName=o.model,this.os=o.system,this.browserName=o.platform,this.browserVersion=o.version,this.monitorIp="",this.country="",this.province="",this.city="",this.loadType=e,this.loadTime=t,this.newStatus=r,this.referrer=(n||"").split("?")[0].replace("#","")}}class w{constructor(e){var t=getCurrentPages().length?getCurrentPages()[0].route:"App Launched";this.uploadType=h,this.webMonitorId=a,this.leaveType=e,this.happenTime=(new Date).getTime(),this.simpleUrl=t,this.customerKey=v.getCustomerKey()}}class T extends S{constructor(e,t,r,n){super();var o=v.getDevice();this.uploadType=e,this.infoType=t,this.pageKey=v.getPageKey(),this.deviceName=o.model,this.os=o.system,this.browserName=o.platform,this.browserVersion=o.version,this.monitorIp="",this.country="china",this.province="",this.city="",this.errorMessage=v.b64EncodeUnicode(r),this.errorStack=v.b64EncodeUnicode(n),this.browserInfo=""}}class b extends S{constructor(e,t,r,n,o,a,s,i,c){super(),this.uploadType=e,this.method=t,this.httpUrl=v.b64EncodeUnicode(r),this.status=n,this.statusText=o,this.statusResult=a,this.requestText=v.b64EncodeUnicode(s),this.responseText=v.b64EncodeUnicode(i),this.loadTime=c}}var C="";function P(){var e=v.isTodayBrowse(d),t=(new Date).getTime();r.setStorageSync(p,t);var n=getCurrentPages().length?getCurrentPages()[0].route:"App Launched",o=null,a=v.formatDate(t,"y-M-d"),s=n,i=r.getStorageSync(y);if(i){var c=i.split("$$$"),h=c[0],l=c[1],f=parseInt(c[2],10);a==l?s!=h&&1==f&&(r.setStorageSync(y,s+"$$$"+a+"$$$2"),o=new w(2)):(r.setStorageSync(y,s+"$$$"+a+"$$$1"),o=new w(1))}else r.setStorageSync(y,s+"$$$"+a+"$$$1"),o=new w(1);var m=r.getStorageSync("monitorCustomerKey");if(m){var S="",T=m?m.match(/\d{14}/g):[];if(T&&T.length>0){var b=T[0].match(/\d{2}/g),C=b[0]+b[1]+"-"+b[2]+"-"+b[3]+" "+b[4]+":"+b[5]+":"+b[6],P=new Date(C).getTime();S=(new Date).getTime()-P>300?0==e?"o_uv":"o":"n_uv"}}else S="n_uv",v.getCustomerKey();var D=new x("reload",0,S,"");if("n_uv"===S||"o_uv"===S){var O=[D,o];v.ajax("POST",u,O)}else D.handleLogInfo(g,D)}var D=uni.request;function O(){if(getCurrentPages().length){var e=getCurrentPages()[0].route;C!=e&&(P(),C=e)}}uni.request=function(){let e=arguments[0];if(-1==e.url.indexOf(i)){e.startTime=(new Date).getTime();var t=e.method,r=e.url,n=new b(l,t,r,"200","OK","request","","",0);n.handleLogInfo(l,n)}var o=arguments[0].success,a=arguments[0].fail;return arguments[0].success=function(...t){if(-1==e.url.indexOf(i)){var r=(new Date).getTime()-e.startTime,n=e.method,a=e.url,s=t[0],c=s.statusCode,u=JSON.stringify(e.data),g=JSON.stringify(s.data),h=parseInt("1000")||5e3;g&&g.length>h&&(g="内容太长");var f=new b(l,n,a,c,"OK","response",u,g,r);f.handleLogInfo(l,f)}o(...t)},arguments[0].fail=function(...t){if(-1==e.url.indexOf(i)){var r=(new Date).getTime()-e.startTime,n=e.method,o=e.url,s=t[0],c=JSON.stringify(e.data),u=s.errMsg,g=new b(l,n,o,555,"fail","response",c,u,r);g.handleLogInfo(l,g)}a(...t)},D.apply(uni,arguments)},uni.webfunny=function(e){var t=(new Date).getTime();setInterval(function(){O();let e=(new Date).getTime();if(e-t>=8e3){for(var n=[],o=0;o<m.length;o++){var a=r.getStorageSync(m[o]);n=n.concat(a)}for(var s=0;s<m.length;s++)r.setStorageSync(m[s],[]);n.length>0&&v.ajax("POST",u,n,function(){},function(){}),t=e}},200);var n={onLaunch:function(){P()},onError:function(e){var t="";"string"==typeof e?t=e:"object"==typeof e&&(t=e.stack||"");var r=t.split("\n")[2];getCurrentPages().length&&getCurrentPages()[0].route,function(e,t,r,n,o,a){O();var s=new T(f,e,t||"",a||"");s.handleLogInfo(f,s)}("on_error",r,0,0,0,t)}};for(const t in n){const r="function"==typeof e[t]&&e[t];e[t]=function(){n[t].apply(this,arguments),r&&r.apply(this,arguments)}}return e}}]);
@a826604005

@592229712
Copy link
Author

我增加了这两行代码,测试了下好像没啥问题
image

@a597873885
Copy link
Owner

@592229712 你好,你关闭了,是因为解决了吗?

@a597873885
Copy link
Owner

能否辛苦在下方补充一下原因和解决办法,谢谢

@592229712
Copy link
Author

592229712 commented Sep 7, 2021

image
我就初始化探针代码里面,succcess和fail两个方法就可以了 @a826604005

@592229712 592229712 reopened this Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants