@xm-fe/xm-mp-log 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 +21 -0
- package/README.md +42 -0
- package/lib/xm-mp-log.es5.min.js +2 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2020 by authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# xm-log
|
|
2
|
+
|
|
3
|
+
## 开发
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### 编译
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm run build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### web 端发布
|
|
16
|
+
|
|
17
|
+
#### 方法一(升版本,每个接入应用都要发布)
|
|
18
|
+
|
|
19
|
+
- 修改版本号(打包脚本内内部)
|
|
20
|
+
- npm run build
|
|
21
|
+
- 把 dist/monitor@0.0.x.es5.min.js上传至七牛云
|
|
22
|
+
- 替换目标系统为新版本
|
|
23
|
+
|
|
24
|
+
#### 方法二(不升版本,所有应用不需要发布,但是有缓存时间)
|
|
25
|
+
|
|
26
|
+
- npm run build
|
|
27
|
+
- 把 dist/monitor@0.0.x.es5.min.js上传至七牛云
|
|
28
|
+
- 去微软云刷新缓存
|
|
29
|
+
- 等待缓存刷新,或让目标用户清缓存
|
|
30
|
+
|
|
31
|
+
### 小程序端发布
|
|
32
|
+
|
|
33
|
+
- index-mp.js,将会被打包上传至 npm
|
|
34
|
+
- 更新相应小程序版本号
|
|
35
|
+
|
|
36
|
+
### 信息文档
|
|
37
|
+
|
|
38
|
+
https://summerfarm.yuque.com/tech-xe1hi/tech/labawh
|
|
39
|
+
|
|
40
|
+
### 接入文档
|
|
41
|
+
|
|
42
|
+
https://summerfarm.yuque.com/tech-xe1hi/tech/yt9ray
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! xm-mp-log 0.0.1 */
|
|
2
|
+
!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).monitor={})}(this,(function(e){"use strict";function t(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var n={uid:"",cid:"",logstores:"fe-test",env:2,isDev:!1,set:function(e){e.logstores&&(this.logstores=e.logstores),e.uid&&(this.uid=e.uid),e.isDev&&(this.isDev=e.isDev)},customLog:function(e,t){this.log(this.level.log,this.type.custom,{msg:e,ext:t})},warn:function(e,t){this.log(this.level.warn,this.type.custom,{msg:e,ext:t})},onResponse:function(e,t){try{if(200!=e.statusCode){var o={ap:t.apiPath,code:e.statusCode,msg:e.data.message||e.data.error,ai:JSON.stringify({data:t.data,method:t.method||"get",header:t.header})};n.log(this.level.error,this.type.api,o)}}catch(e){console.log(e)}},onError:function(e){this.log(this.level.error,this.type.js,{msg:e})},onFail:function(e,t){try{var o={};o=e&&(e.errMsg||e.errno||e.errCode)?{msg:e.errMsg,eno:e.errno,eco:e.errCode}:{ext:e},t&&t.apiPath?(o.ap=t.apiPath,o.ai=JSON.stringify({data:t.data,method:t.method||"get",header:t.header})):t&&(o.extt=t),this.log(this.level.error,this.type.fail,o)}catch(e){console.log(e)}},log:function(e,o,i){try{var c=wx.getAccountInfoSync().miniProgram;if(!n.isDev&&"develop"==c.envVersion)return;var s=function(e){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?t(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({url:getCurrentPages().map((function(e){return e.route})).join("_"),mpv:JSON.stringify({v:c.version,e:c.envVersion}),cid:n.cid,uid:n.uid,en:n.env,le:e,tp:o},i);s.ext&&(s.ext=n._toStr(s.ext));var a="https://xianmu-front-end-log.cn-hangzhou.log.aliyuncs.com/logstores/"+(n.isDev?"fe-test":n.logstores)+"/track_ua.gif";wx.request({url:"".concat(a,"?APIVersion=0.6.0&").concat(n.objectToQuery(s))})}catch(e){console.log(e)}},level:{log:"l",error:"e",warn:"w"},type:{click:"cl",pv:"pv",custom:"c",api:"a",js:"j",src:"s",promise:"p",fail:"f"},_toStr:function(e){return"object"===o(e)?JSON.stringify(e):e},_getStr:function(e,t,o){if("[object Object]"==Object.prototype.toString.call(e))for(var r in e)this._getStr(e[r],t+"."+r,o);else"[object Array]"==Object.prototype.toString.call(e)?e.forEach((function(e){o.push("".concat(t,"=").concat(encodeURIComponent(e)))})):o.push("".concat(t,"=").concat(encodeURIComponent(e)))},objectToQuery:function(e){var t=[];for(var o in e)void 0!==e[o]&&this._getStr(e[o],o,t);return t.join("&")}};try{var i=wx.getStorageSync("_xm_log_cid");i?n.cid=i:(n.cid=Date.now()+"-"+Math.ceil(1e6*Math.random()),wx.setStorage({key:"_xm_log_cid",data:n.cid}))}catch(e){console.log(e)}e._xmLog=n,Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xm-fe/xm-mp-log",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "xm-mp-log",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"xm-mp-log"
|
|
7
|
+
],
|
|
8
|
+
"repository": "xm-mp-log",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"files": [
|
|
11
|
+
"lib/"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"main": "./lib/xm-mp-log.es5.min.js",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rollup -c"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@babel/core": "^7.10.2",
|
|
23
|
+
"@babel/preset-env": "^7.10.2",
|
|
24
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
25
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
26
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
27
|
+
"eslint": "^8.4.1",
|
|
28
|
+
"rollup": "^2.29.0",
|
|
29
|
+
"rollup-plugin-terser": "^7.0.2"
|
|
30
|
+
}
|
|
31
|
+
}
|