@fle-sdk/event-tracking-web 1.1.2-alpha.0 → 1.2.0-beta.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/README.md CHANGED
@@ -1,4 +1,3 @@
1
- # @fle.sdk/event-tracking-web
2
1
  > **构建用户数据体系,让用户行为数据发挥深远的价值。**
3
2
 
4
3
 
@@ -53,128 +52,113 @@ WebTracking.init({
53
52
  {
54
53
  "desc": "Web 浏览页面",
55
54
  "event": "PageView",
56
- "appKey": "218844",
57
- "siteId": "",
58
55
  "itemKey": "218844.app_other",
59
- "requestTime": 1638456820316,
60
- "deviceId": "f9e3f35a6371f369a2c9f21c48dcabe8",
56
+ "requestTime": 1709524231171,
57
+ "deviceId": "1dd539cdea9332ebb9d5c087f9d4471f",
61
58
  "privateParamMap": {
62
59
  "currentUrl": "http://localhost:9999/app/other",
63
60
  "targetUrl": null,
61
+ "pageWidth": 414,
62
+ "pageHeight": 672,
63
+ "screenWidth": 414,
64
+ "screenHeight": 672,
64
65
  "sdkVersion": "1.1.0",
65
- "pageWidth": 742,
66
- "pageHeight": 867,
67
- "screenWidth": 1680,
68
- "screenHeight": 1050,
69
66
  "systemsInfo": {
70
67
  "language": "zh-CN",
71
- "platform": "pc",
72
- "client": "Mac, MacOS 10.15.7",
73
- "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36",
74
- "navigationStart": 1638456820099,
75
- "navigation": "1ms",
76
- "dns": "0ms",
77
- "tcp": "0ms",
78
- "request": "2ms",
79
- "response": "1ms"
68
+ "client": "iPhone, iOS 11.0, WeChat 8.0.5",
69
+ "platform": "h5",
70
+ "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 wechatdevtools/1.06.2310080 MicroMessenger/8.0.5 Language/zh_CN webview/17095233761068527 webdebugger port/25477 token/e60c2e75ed74647fb2c0d949c0a31774"
80
71
  },
81
72
  "urlParams": {},
82
73
  "userInfo": {
83
- "userId": 20211232232123
74
+ "userId": 20211232232123,
75
+ "userName": "asheng"
76
+ },
77
+ "business": {
78
+ "appId": "1000010"
84
79
  }
85
80
  }
86
81
  }
87
-
82
+ ```
83
+ ```json
88
84
  {
89
85
  "desc": "Web 元素点击",
90
86
  "event": "WebClick",
91
- "appKey": "218844",
92
- "siteId": "",
93
- "itemKey": "218844.main.8ydgk",
94
- "requestTime": 1638460476808,
95
- "deviceId": "f9e3f35a6371f369a2c9f21c48dcabe8",
87
+ "itemKey": "218844.main.h1",
88
+ "requestTime": 1709524472904,
89
+ "deviceId": "1dd539cdea9332ebb9d5c087f9d4471f",
96
90
  "privateParamMap": {
97
- "position": [
98
- 126,
99
- 87
100
- ],
101
91
  "targetEle": {
102
92
  "id": "",
103
93
  "nodeName": "H1",
104
- "className": ""
94
+ "className": "",
95
+ "position": [
96
+ 66,
97
+ 108
98
+ ]
105
99
  },
106
- "pointerType": "mouse",
100
+ "pointerType": "",
107
101
  "currentUrl": "http://localhost:9999/main?a=1",
108
102
  "elementSelector": "#root > div:nth-of-type(1) > div:nth-of-type(1) > h1:nth-of-type(1)",
103
+ "pageWidth": 414,
104
+ "pageHeight": 672,
105
+ "screenWidth": 414,
106
+ "screenHeight": 672,
109
107
  "sdkVersion": "1.1.0",
110
- "pageWidth": 742,
111
- "pageHeight": 867,
112
- "screenWidth": 1680,
113
- "screenHeight": 1050,
114
108
  "systemsInfo": {
115
109
  "language": "zh-CN",
116
- "platform": "pc",
117
- "client": "Mac, MacOS 10.15.7",
118
- "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36",
119
- "navigationStart": 1638456820099,
120
- "navigation": "1ms",
121
- "dns": "0ms",
122
- "tcp": "0ms",
123
- "request": "2ms",
124
- "response": "1ms",
125
- "domComplete (domLoaded)": "201ms (186ms)",
126
- "loadEvent": "1ms",
127
- "total (DOM)": "218ms (217ms)"
110
+ "client": "iPhone, iOS 11.0, WeChat 8.0.5",
111
+ "platform": "h5",
112
+ "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 wechatdevtools/1.06.2310080 MicroMessenger/8.0.5 Language/zh_CN webview/17095233761068527 webdebugger port/25477 token/e60c2e75ed74647fb2c0d949c0a31774"
128
113
  },
129
114
  "urlParams": {
130
115
  "a": "1"
131
116
  },
132
117
  "userInfo": {
133
- "userId": 20211232232123
118
+ "userId": 20211232232123,
119
+ "userName": "asheng"
120
+ },
121
+ "business": {
122
+ "appId": "1000010"
134
123
  }
135
124
  }
136
125
  }
137
-
126
+ ```
127
+ ```json
138
128
  {
139
129
  "desc": "Web 页面浏览时长",
140
130
  "event": "PageRetained",
141
- "appKey": "218844",
142
- "siteId": "",
143
- "itemKey": "218844.app_other",
144
- "requestTime": 1638460554657,
145
- "deviceId": "f9e3f35a6371f369a2c9f21c48dcabe8",
131
+ "itemKey": "218844.main",
132
+ "requestTime": 1709524334413,
133
+ "deviceId": "1dd539cdea9332ebb9d5c087f9d4471f",
146
134
  "privateParamMap": {
135
+ "pageWidth": 414,
136
+ "pageHeight": 672,
137
+ "screenWidth": 414,
138
+ "screenHeight": 672,
147
139
  "sdkVersion": "1.1.0",
148
- "pageWidth": 742,
149
- "pageHeight": 867,
150
- "screenWidth": 1680,
151
- "screenHeight": 1050,
152
- "currentUrl": "http://localhost:9999/app/other",
153
140
  "systemsInfo": {
154
141
  "language": "zh-CN",
155
- "platform": "pc",
156
- "client": "Mac, MacOS 10.15.7",
157
- "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36",
158
- "navigationStart": 1638456820099,
159
- "navigation": "1ms",
160
- "dns": "0ms",
161
- "tcp": "0ms",
162
- "request": "2ms",
163
- "response": "1ms",
164
- "domComplete (domLoaded)": "201ms (186ms)",
165
- "loadEvent": "1ms",
166
- "total (DOM)": "218ms (217ms)"
142
+ "client": "iPhone, iOS 11.0, WeChat 8.0.5",
143
+ "platform": "h5",
144
+ "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 wechatdevtools/1.06.2310080 MicroMessenger/8.0.5 Language/zh_CN webview/17095233761068527 webdebugger port/25477 token/e60c2e75ed74647fb2c0d949c0a31774"
145
+ },
146
+ "urlParams": {
147
+ "a": "1"
167
148
  },
168
- "urlParams": {},
169
149
  "userInfo": {
170
- "userId": 20211232232123
171
- }
172
- },
173
- "retainedStartTime": 1638460451953
150
+ "userId": 20211232232123,
151
+ "userName": "asheng"
152
+ },
153
+ "currentUrl": "http://localhost:9999/main?a=1",
154
+ "business": {
155
+ "appId": "1000010"
156
+ },
157
+ "retainedDuration": 103243
158
+ }
174
159
  }
175
160
  ```
176
161
 
177
-
178
162
  ---
179
163
 
180
164
 
@@ -195,12 +179,13 @@ WebTracking
195
179
  | serverUrl | string | 数据接收地址 | 是 | - |
196
180
  | autoTrack | boolean | 是否开启全埋点(指的是:页面浏览、元素点击事件自动上报) | 否 | false |
197
181
  | showLog | boolean | 是否在网页控制台打印发送的数据 | 否 | false |
198
- | useClientTime | boolean | 是否使用客户端系统时间 | 否 | true |
199
182
  | sendTimeout | number | 接口发送超时时长,超过该时长未发送成功将强制取消 | 否 | 3000 |
200
183
  | isTrackSinglePage | boolean | 是否采集单页面应用的路由变化 | 否 | false |
201
- | siteId | numberstring | 站点 Id | 否 | - |
202
184
  | contentType | string | application/json
203
185
  application/x-www-form-urlencoded | 否 | application/x-www-form-urlencoded |
186
+ | business | {[key: string]: any} | 全局自定义业务参数(如果后续手动上报了业务字段,会进行合并) | 否 | - |
187
+ | platform | string | 手动指定应用平台类型 | 否 | - |
188
+ | header | {[key: string]: any} | 自定义请求头 | 否 | - |
204
189
 
205
190
 
206
191
  #### 例子
@@ -212,13 +197,17 @@ import WebTracking from "@fle-sdk/event-tracking-web";
212
197
 
213
198
  const App = () => {
214
199
  useLayoutEffect(() => {
215
- // init tracking
200
+ // 初始化埋点
216
201
  WebTracking.init({
217
- appKey: "xxxxxx", // 由接口生成,应用唯一标识
218
- serverUrl: "https://www.serverHost.com/serverApi/push",
219
- autoTrack: true,
202
+ appKey: "218844",
220
203
  showLog: true,
221
- isTrackSinglePage: true
204
+ autoTrack: true,
205
+ platform: 'h5',
206
+ isTrackSinglePage: true,
207
+ serverUrl: "https://qa-gateway.fxqifu.net/pangu/buriedpoint/record/push",
208
+ business: {
209
+ appId: "1000010",
210
+ }
222
211
  });
223
212
  }, []);
224
213
 
@@ -236,10 +225,13 @@ export default App;
236
225
  | --- | --- | --- | --- | --- |
237
226
  | autoTrack | boolean | 是否开启全埋点(指的是:页面浏览、元素点击事件自动上报) | 否 | false |
238
227
  | showLog | boolean | 是否在网页控制台打印发送的数据 | 否 | false |
239
- | useClientTime | boolean | 是否使用客户端系统时间 | 否 | true |
240
228
  | sendTimeout | number | 接口发送超时时长,超过该时长未发送成功将强制取消 | 否 | 3000 |
241
229
  | isTrackSinglePage | boolean | 是否采集单页面应用的路由变化 | 否 | false |
242
- | siteId | numberstring | 站点 Id | 否 | - |
230
+ | contentType | string | application/json
231
+ application/x-www-form-urlencoded | 否 | application/x-www-form-urlencoded |
232
+ | business | {[key: string]: any} | 手动埋点参数 | 否 | {} |
233
+ | platform | string | 手动指定应用平台类型 | 否 | - |
234
+ | header | {[key: string]: any} | 自定义请求头 | 否 | - |
243
235
 
244
236
  #### 例子
245
237
  ```jsx
@@ -280,7 +272,7 @@ export default App;
280
272
  #### 参数
281
273
  | 参数名 | type | 描述 | 是否必填 | 默认值 |
282
274
  | --- | --- | --- | --- | --- |
283
- | userId | numberstring | 用户ID | | - |
275
+ | params | {[key: string]: any} | 用户信息 | | - |
284
276
 
285
277
  #### 例子
286
278
  ```jsx
@@ -290,8 +282,8 @@ import { LoginStore } from "store";
290
282
 
291
283
  const Test = () => {
292
284
  const getUserInfo = () => {
293
- const { userId } = await LoginStore.getUserInfo();
294
- WebTracking.Login("用户ID");
285
+ const userInfo = await LoginStore.getUserInfo();
286
+ WebTracking.Login(userInfo);
295
287
  }
296
288
  useEffect(() => {
297
289
  getUserInfo()
@@ -304,9 +296,9 @@ export default Test;
304
296
  ```
305
297
 
306
298
 
307
- ### GetDeviceId
299
+ ### GetDistinctId
308
300
  #### 例子
309
- > 获取设备唯一标识,单用户没有登录时即用户唯一标识
301
+ > 获取设备唯一标识,当用户没有登录时即用户唯一标识
310
302
 
311
303
  ```jsx
312
304
  import React, { useEffect } from "react";
@@ -315,7 +307,7 @@ import { LoginStore } from "store";
315
307
 
316
308
  const Test = () => {
317
309
  useEffect(() => {
318
- WebTracking.getDeviceId();
310
+ WebTracking.getDistinctId();
319
311
  }, []);
320
312
 
321
313
  return <div className="Test"></div>;
@@ -333,7 +325,8 @@ export default Test;
333
325
  | --- | --- | --- | --- | --- |
334
326
  | partkey | numberstring | 上报事件 Key(由前后端协商定义或由后端接口生成,该应用下需唯一且具有一定意义,例:goods_detail_pv) | 是 | - |
335
327
  | desc | string | 上报事件描述 | 否 | 自定义上报事件 |
336
- | business | object | 上报的业务参数 | 否 | - |
328
+ | business | {[key: string]: any} | 上报的业务参数 | 否 | - |
329
+ | header | {[key: string]: any} | 自定义请求头 | 否 | - |
337
330
 
338
331
 
339
332
  #### 例子
@@ -376,24 +369,13 @@ export default Index;
376
369
  ### 4.1 request参数明细
377
370
  | **参数名** | **type** | **描述** | **示例值** |
378
371
  | --- | --- | --- | --- |
379
- | appKey | string | 应用唯一标识(由接口生成) | - |
380
372
  | event | string | 有四种类型的值:
381
373
  PageViewPageRetainedCustomTrackWebClick | - |
374
+ | desc | string | 埋点事件描述 | - |
382
375
  | itemKey | string | 当前埋点事件Key | appkey.pagekey.partkey |
383
- | serverUrl | string | 数据接收地址 | - |
384
- | siteId | numberstring | 站点 ID | - |
385
- | showLog | boolean | 是否在网页控制台打印发送的数据 | false |
386
- | platform | string | 应用平台类型,如不传会自动获取
387
- 可选值:h5pc | - |
388
- | autoTrack | boolean | 是否开启全埋点 指的是:页面浏览、元素点击事件自动上报 | true |
389
- | useClientTime | boolean | (是否使用客户端系统时间)注意:客户端系统时间可能会不准确,导致该字段不准确 | true |
390
376
  | requestTime | number | 发送请求事件 | - |
391
- | sendTimeout | number | 接口发送超时时长,超过该时长未发送成功将强制取消,单位:毫秒 | 3000 |
392
- | isTrackSinglePage | boolean | 是否采集单页面应用的路由变化 | false |
393
- | contentType | string | 可选值:
394
- application/json
395
- application/x-www-form-urlencoded | application/x-www-form-urlencoded |
396
377
  | privateParamMap | object | 私有参数 | [查看详情](#mWMBL) |
378
+ | deviceId | string | 设备ID | 9ce0159574b00867c7d2c5b200bd2f60 |
397
379
 
398
380
  #### 4.2.1 privateParamMap参数明细
399
381
  | **参数名** | **type** | **描述** | **示例值** |
@@ -429,4 +411,6 @@ application/x-www-form-urlencoded | application/x-www-form-urlencoded |
429
411
  | network | string | 网络类型 | - |
430
412
  | ua | string | userAgent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 |
431
413
  | client | string | 客户端(Mac/Android/iPhone/iPad/iPod/WeChat) | Mac, MacOS 10.15.7 |
414
+ | platform | string | 应用平台类型,如不传会自动获取
415
+ 枚举:h5iPadpcother | h5 |
432
416
 
package/lib/index.esm.js CHANGED
@@ -12,5 +12,5 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
12
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
13
  PERFORMANCE OF THIS SOFTWARE.
14
14
  ***************************************************************************** */
15
- var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};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)},n=new(function(n){function r(){var e=n.call(this)||this;return e.userId=null,e.currentUrl="",e.pageKey="",e.eventDescMap={PageView:"Web 浏览页面",WebClick:"Web 元素点击",PageRetained:"Web 页面浏览时长",CustomTrack:"Web 自定义代码上报"},e.init=function(t){e.preset(t);var n=window.location.pathname;e.currentUrl=window.location.href,e.pageKey=n.replace(/\//g,"_").substr(1),e.systemsInfo=e.getSystemsInfo(),e.setCookie("retainedStartTime",e.getTimeStamp())},e.preset=function(t){t instanceof Object&&e.each(t,(function(t,n){void 0!==e.config[n]&&(e.config[n]=t)})),/^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-\(\)]*[\w@?^=%&/~+#-\(\)])?$/.test(e.config.serverUrl)||(e.printLog("当前 server_url 为空或不正确,只在控制台打印日志,network 中不会发数据,请配置正确的 server_url!"),e.config.showLog=!0),e.config.autoTrack?e.listener():e.unlistener()},e.login=function(t){["number","string"].includes(typeof t)&&(e.userId=t)},e.track=function(t){var n=t.desc,r=t.partkey,o=t.business,i=e.getParams({desc:n,event:"CustomTrack",itemKey:e.getItemKey(r),extroInfo:{business:o}});return e.sendAjax(i)},e.listener=function(){e.config.isTrackSinglePage&&(e.rewriteHistory(),e.addSinglePageEvent(e.onPageViewCallback)),e.each(["load","beforeunload"],(function(t){e.addEventListener(window,t,e.onPageViewCallback)})),e.addEventListener(window,"click",e.onClickCallback)},e.unlistener=function(){if(e.config.isTrackSinglePage){var t=window.history.pushState?"popstate":"hashchange";e.each(["pushState","replaceState",t],(function(t){e.removeEventListener(window,t,e.onPageViewCallback)}))}e.each(["load","beforeunload"],(function(t){e.removeEventListener(window,t,e.onPageViewCallback)})),e.removeEventListener(window,"click",e.onClickCallback)},e.onClickCallback=function(t){var n,r;if(null===(r=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.dataset)||void 0===r?void 0:r.partKey){var o=[t.pageX,t.pageY],i=t.target.id,a=t.target.className,s={id:i,nodeName:t.target.nodeName,className:a},c=e.getParams({event:"WebClick",desc:e.eventDescMap.WebClick,itemKey:e.getItemKey(t.target.dataset.partKey),extroInfo:{position:o,targetEle:s,pointerType:t.pointerType,currentUrl:e.currentUrl,elementSelector:e.getDomSelector(t.target)}});return e.sendAjax(c)}},e.onPageViewCallback=function(t){var n,r,o=window.location.origin;e.sendPageViewData(t.type,{event:"PageView",desc:e.eventDescMap.PageView,extroInfo:{currentUrl:e.currentUrl,targetUrl:(null===(n=t.arguments)||void 0===n?void 0:n[2])?o+(null===(r=t.arguments)||void 0===r?void 0:r[2]):null}}),e.currentUrl=window.location.href,e.pageKey=window.location.pathname.replace(/\//g,"_").substr(1)},e.getParams=function(n){var r=n.event,o=n.desc,i=n.itemKey,a=n.extroInfo,s=void 0===a?{}:a,c=e.config,u=c.appKey,d=c.sdkVersion,l=c.siteId,p=window.innerWidth,g=window.innerHeight,f=window.screen.width,m=window.screen.height;return{desc:o,event:r,appKey:u,siteId:l,itemKey:i||e.getItemKey(),requestTime:e.getTimeStamp(),deviceId:e.getDistinctId(),privateParamMap:t(t({},s),{sdkVersion:d,pageWidth:p,pageHeight:g,screenWidth:f,screenHeight:m,currentUrl:s.currentUrl||e.currentUrl,systemsInfo:e.systemsInfo,urlParams:e.getQueryValue(),userInfo:{userId:e.userId}})}},e.sendPageViewData=function(t,n){var r=e.getParams(n);return e.sendRetained(t),e.sendAjax(r)},e.sendAjax=function(t){var n=e.config,r=n.serverUrl,o=n.sendTimeout,i=n.contentType;return n.showLog&&e.printLog(t),new Promise((function(n,a){e.ajax({url:r,type:"POST",data:JSON.stringify(t),contentType:i,credentials:!1,timeout:o,cors:!0,success:function(e){return n(e)},error:function(e){return a(e)}})}))},e.sendRetained=function(n){var r=e.config.serverUrl,o=e.getParams({event:"PageRetained",desc:e.eventDescMap.PageRetained});if(["beforeunload","pushState","replaceState","hashchange","popstate"].indexOf(n)>=0){var i=e.getCookie("retainedStartTime"),a=i?+i:e.getTimeStamp(),s=t(t({},o),{retainedStartTime:a});"beforeunload"===n?e.sendBeacon({url:r,data:s}):e.sendAjax(s).finally((function(){return e.setCookie("retainedStartTime",e.getTimeStamp())}))}},e.getItemKey=function(t){return[e.config.appKey,e.pageKey,t?t.toString():void 0].filter((function(e){return!!e})).reduce((function(e,t){return e+(e.length?".":"")+t}),"")},e.config={sdkVersion:"1.1.0",appKey:"",siteId:"",showLog:!1,serverUrl:"",autoTrack:!1,useClientTime:!0,queueTimeout:500,sendTimeout:3e3,isTrackSinglePage:!1,contentType:"application/x-www-form-urlencoded"},e.systemsInfo={},e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,n),r.prototype.addSinglePageEvent=function(e){var t=this,n=window.history.pushState?"popstate":"hashchange";this.each(["pushState","replaceState",n],(function(n){t.addEventListener(window,n,e)}))},r}(function(){function e(){var e=this;this.getPlatformType=function(){for(var e=navigator.userAgent,t=new Array("Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"),n=!0,r=0;r<t.length;r++)if(e.indexOf(t[r])>0){n=!1;break}return n?"pc":"h5"},this.addEventListener=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,(function(t){return n.call(e,t)}),!1)},this.removeEventListener=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n):e.detachEvent&&e.detachEvent("on"+t,(function(t){return n.call(e,t)}),!0)},this.rewriteHistory=function(){var e=window.history,t=function(e){var t=window.history,n=t[e],r=new Event(e);return function(){var e=n.apply(t,arguments);return r.arguments=arguments,window.dispatchEvent(r),e}};window.history.pushState&&(e.pushState=t("pushState"),e.replaceState=t("replaceState"))},this.isArray=Array.isArray||function(e){return"[object Array]"===toString.call(e)},this.formatJsonString=function(e){try{return JSON.stringify(e,null," ")}catch(t){return JSON.stringify(e)}},this.nativeForEach=Array.prototype.forEach,this.slice=Array.prototype.slice,this.hasOwnProperty=Object.prototype.hasOwnProperty,this.breaker={},this.each=function(t,n,r){if(null==t)return!1;if(e.nativeForEach&&t.forEach===e.nativeForEach)t.forEach(n,r);else if(e.isArray(t)&&t.length===+t.length){for(var o=0,i=t.length;o<i;o++)if(o in t&&n.call(r,t[o],o,t)===e.breaker)return!1}else for(var a in t)if(e.hasOwnProperty.call(t,a)&&n.call(r,t[a],a,t)===e.breaker)return!1},this.getDomIndex=function(e){if(!e.parentNode)return-1;for(var t=0,n=e.tagName,r=e.parentNode.children,o=0;o<r.length;o++)if(r[o].tagName===n){if(e===r[o])return t;t++}return-1},this.selector=function(t){var n=t.parentNode&&9==t.parentNode.nodeType?-1:e.getDomIndex(t);return t.getAttribute&&t.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(t.getAttribute("id"))?"#"+t.getAttribute("id"):t.tagName.toLowerCase()+(~n?":nth-of-type("+(n+1)+")":"")},this.getDomSelector=function(t,n){if(!t||!t.parentNode||!t.parentNode.children)return!1;n=n&&n.join?n:[];var r=t.nodeName.toLowerCase();return t&&"body"!==r&&1==t.nodeType?(n.unshift(e.selector(t)),t.getAttribute&&t.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(t.getAttribute("id"))?n.join(" > "):e.getDomSelector(t.parentNode,n)):(n.unshift("body"),n.join(" > "))},this.getCookie=function(e){for(var t=e+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(t))return this._decodeURIComponent(o.substring(t.length,o.length))}return null},this.setCookie=function(e,t,n){var r,o="";n=null==n?73e3:n;var i=this.getMainHost();if(r=i?"; domain="+i:"",0!==n){var a=new Date;"s"===String(n).slice(-1)?a.setTime(a.getTime()+1e3*Number(String(n).slice(0,-1))):a.setTime(a.getTime()+24*n*60*60*1e3),o="; expires="+a.toUTCString()}function s(e){return e||!1}var c="",u="",d="";e&&(c=s(e)),t&&(u=s(t)),r&&(d=s(r)),c&&u&&(document.cookie=c+"="+encodeURIComponent(u)+o+"; path=/"+d)},this.removeCookie=function(t){e.setCookie(t,"",-1)},this.getTimeStamp=function(){return(new Date).getTime()},this.uuid=function(){return"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},this.getDistinctId=function(){var t=e.getCookie("distinctId");return t||(t=e.uuid(),e.setCookie("distinctId",t),t)},this.getQueryValue=function(e){for(var t=decodeURI(window.location.href).match(new RegExp("[?&][^?&]+=[^?&]+","g"))||[],n={},r=0;r<t.length;r++){var o=t[r].replace(/\?|\&/,"").split("=");if(o[0]===e)return o[1];n[o[0]]=o[1]}return e?null:n},this.ajax=function(t){function n(e){if(!e)return"";try{return JSON.parse(e)}catch(e){return{}}}t.timeout=t.timeout||3e4,t.credentials=void 0===t.credentials||t.credentials;var r=e.xhr(t.cors);if(!r)return!1;t.type||(t.type=t.data?"POST":"GET");var o,i=t.success,a=t.error;t.success=function(e){i(e),o&&(clearTimeout(o),o=null)},t.error=function(e){a(e),o&&(clearTimeout(o),o=null)},o=setTimeout((function(){!function(){try{e.isObject(r)&&r.abort&&r.abort()}catch(t){e.printLog(t)}o&&(clearTimeout(o),o=null,t.error&&t.error(),r.onreadystatechange=null,r.onload=null,r.onerror=null)}()}),t.timeout),r.onreadystatechange=function(){try{4==r.readyState&&(r.status>=200&&r.status<300||304==r.status?t.success(n(r.responseText)):t.error(n(r.responseText),r.status),r.onreadystatechange=null,r.onload=null)}catch(e){r.onreadystatechange=null,r.onload=null}},r.open(t.type,t.url,!0);try{t.credentials&&(r.withCredentials=!0),e.isObject(t.header)&&e.each(t.header,(function(e,t){r.setRequestHeader&&r.setRequestHeader(t,e)})),t.data&&(t.cors||r.setRequestHeader&&r.setRequestHeader("X-Requested-With","XMLHttpRequest"),"application/json"===t.contentType?r.setRequestHeader&&r.setRequestHeader("Content-type","application/json; charset=UTF-8"):r.setRequestHeader&&r.setRequestHeader("Content-type","application/x-www-form-urlencoded"))}catch(t){e.printLog(t)}r.send(t.data||null)},this.xhr=function(e){return e?void 0!==window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?new XMLHttpRequest:null:void 0!==window.XMLHttpRequest?new XMLHttpRequest:null},this.sendBeacon=function(e){return"object"==typeof navigator&&"function"==typeof navigator.sendBeacon?(navigator.sendBeacon(e.url,new URLSearchParams(JSON.stringify(e.data||{}))),Promise.resolve({message:"发送成功!"})):Promise.reject({message:"不支持sendBeacon,发送失败!"})}}return e.prototype.printLog=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(this.isObject(e[0])&&(e[0]=this.formatJsonString(e[0])),"object"==typeof console&&console.log)try{return console.log.apply(console,e)}catch(t){console.log(e[0])}},e.prototype.getSystemsInfo=function(){var e=navigator.userAgent,t=[],n={language:navigator.language},r=e.match(/MicroMessenger\/([\d\.]+)/i),o=r&&r[1]?r[1]:null,i=e.match(/(ipod).*\s([\d_]+)/i),a=e.match(/(ipad).*\s([\d_]+)/i),s=e.match(/(iphone)\sos\s([\d_]+)/i),c=e.match(/(android)\s([\d\.]+)/i),u=e.match(/(Mac OS X)\s([\d_]+)/i);t=[],c?t.push("Android "+c[2]):s?t.push("iPhone, iOS "+s[2].replace(/_/g,".")):a?t.push("iPad, iOS "+a[2].replace(/_/g,".")):i?t.push("iPod, iOS "+i[2].replace(/_/g,".")):u&&t.push("Mac, MacOS "+u[2].replace(/_/g,".")),o&&t.push("WeChat "+o),n.platform=this.getPlatformType(),n.client=t.length?t.join(", "):"Unknown";var d=e.toLowerCase().match(/ nettype\/([^ ]+)/g);return d&&d[0]&&(t=[(d=d[0].split("/"))[1]],n.network=t.length?t.join(", "):"Unknown"),n.ua=e,setTimeout((function(){var e=window.performance||window.msPerformance||window.webkitPerformance;if(e&&e.timing){var t=e.timing;t.navigationStart&&(n.navigationStart=t.navigationStart),t.navigationStart&&t.domainLookupStart&&(n.navigation=t.domainLookupStart-t.navigationStart+"ms"),t.domainLookupEnd&&t.domainLookupStart&&(n.dns=t.domainLookupEnd-t.domainLookupStart+"ms"),t.connectEnd&&t.connectStart&&(t.connectEnd&&t.secureConnectionStart?n["tcp (ssl)"]=t.connectEnd-t.connectStart+"ms ("+(t.connectEnd-t.secureConnectionStart)+"ms)":n.tcp=t.connectEnd-t.connectStart+"ms"),t.responseStart&&t.requestStart&&(n.request=t.responseStart-t.requestStart+"ms"),t.responseEnd&&t.responseStart&&(n.response=t.responseEnd-t.responseStart+"ms"),t.domComplete&&t.domLoading&&(t.domContentLoadedEventStart&&t.domLoading?n["domComplete (domLoaded)"]=t.domComplete-t.domLoading+"ms ("+(t.domContentLoadedEventStart-t.domLoading)+"ms)":n.domComplete=t.domComplete-t.domLoading+"ms"),t.loadEventEnd&&t.loadEventStart&&(n.loadEvent=t.loadEventEnd-t.loadEventStart+"ms"),t.navigationStart&&t.loadEventEnd&&(n["total (DOM)"]=t.loadEventEnd-t.navigationStart+"ms ("+(t.domComplete-t.navigationStart)+"ms)")}}),0),n},e.prototype.isObject=function(e){return null!=e&&"[object Object]"==toString.call(e)},e.prototype.isUndefined=function(e){return void 0===e},e.prototype.isString=function(e){return"[object String]"==toString.call(e)},e.prototype.isDate=function(e){return"[object Date]"==toString.call(e)},e.prototype.isBoolean=function(e){return"[object Boolean]"==toString.call(e)},e.prototype.isNumber=function(e){return"[object Number]"==toString.call(e)&&/[\d\.]+/.test(String(e))},e.prototype.isElement=function(e){return!(!e||1!==e.nodeType)},e.prototype.isFunction=function(e){if(!e)return!1;var t=toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t},e.prototype.isJSONString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},e.prototype._decodeURIComponent=function(e){var t=e;try{t=decodeURIComponent(e)}catch(n){t=e}return t},e.prototype.getMainHost=function(){var e="mh_"+Math.random(),t=new RegExp("(^|;)\\s*"+e+"=12345"),n=new Date(0),r=document.domain.split("."),o=[];for(o.unshift(r.pop());r.length;){o.unshift(r.pop());var i=o.join("."),a=e+"=12345;domain=."+i;if(document.cookie=a,t.test(document.cookie))return document.cookie=a+";expires="+n,i}},e}()));export default n;
15
+ var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};var t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},n=new(function(n){function r(){var e=n.call(this)||this;return e.userInfo=null,e.currentUrl="",e.pageKey="",e.eventDescMap={PageView:"Web 浏览页面",WebClick:"Web 元素点击",PageRetained:"Web 页面浏览时长",CustomTrack:"Web 自定义代码上报"},e.init=function(t){e.preset(t);var n=window.location.pathname;e.currentUrl=window.location.href,e.pageKey=n.replace(/\//g,"_").substr(1),e.systemsInfo=e.getSystemsInfo(t.platform),e.setCookie("retainedStartTime",e.getTimeStamp())},e.preset=function(t){t instanceof Object&&e.each(t,(function(t,n){e.initConfig.hasOwnProperty(n)&&(e.initConfig[n]=t)})),/^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-\(\)]*[\w@?^=%&/~+#-\(\)])?$/.test(e.initConfig.serverUrl)||(e.printLog("当前 server_url 为空或不正确,只在控制台打印日志,network 中不会发数据,请配置正确的 server_url!"),e.initConfig.showLog=!0),e.initConfig.autoTrack?e.listener():e.unlistener()},e.login=function(t){e.isObject(t)&&(e.userInfo=t)},e.track=function(t){var n=t.desc,r=t.partkey,i=t.business,o=t.header,a=e.getParams({desc:n,event:"CustomTrack",itemKey:e.getItemKey(r),privateParamMap:{business:i}});return e.sendData(a,o)},e.listener=function(){e.initConfig.isTrackSinglePage&&(e.rewriteHistory(),e.addSinglePageEvent(e.onPageViewCallback)),e.each(["load","beforeunload"],(function(t){e.addEventListener(window,t,e.onPageViewCallback)})),e.addEventListener(window,"click",e.onClickCallback)},e.unlistener=function(){if(e.initConfig.isTrackSinglePage){var t=window.history.pushState?"popstate":"hashchange";e.each(["pushState","replaceState",t],(function(t){e.removeEventListener(window,t,e.onPageViewCallback)}))}e.each(["load","beforeunload"],(function(t){e.removeEventListener(window,t,e.onPageViewCallback)})),e.removeEventListener(window,"click",e.onClickCallback)},e.onClickCallback=function(t){var n,r;if(null===(r=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.dataset)||void 0===r?void 0:r.partKey){var i=[t.pageX,t.pageY],o=t.target.id,a=t.target.className,s={id:o,nodeName:t.target.nodeName,className:a,position:i},c=e.getParams({event:"WebClick",desc:e.eventDescMap.WebClick,itemKey:e.getItemKey(t.target.dataset.partKey),privateParamMap:{targetEle:s,pointerType:t.pointerType,currentUrl:e.currentUrl,elementSelector:e.getDomSelector(t.target)}});return e.sendData(c)}},e.onPageViewCallback=function(t){var n,r,i=window.location.origin,o=e.getParams({event:"PageView",desc:e.eventDescMap.PageView,privateParamMap:{currentUrl:e.currentUrl,targetUrl:(null===(n=t.arguments)||void 0===n?void 0:n[2])?i+(null===(r=t.arguments)||void 0===r?void 0:r[2]):null}});e.currentUrl=window.location.href,e.pageKey=window.location.pathname.replace(/\//g,"_").substring(1),e.sendRetained(t.type),e.sendData(o)},e.getParams=function(n){var r=n.event,i=n.desc,o=n.privateParamMap,a=void 0===o?{}:o,s=n.itemKey,c=e.initConfig.business,u=window.innerWidth,l=window.innerHeight,d=window.screen.width,p=window.screen.height;return{desc:i,event:r,itemKey:s||e.getItemKey(),requestTime:e.getTimeStamp(),deviceId:e.getDistinctId(),privateParamMap:t(t({},a),{pageWidth:u,pageHeight:l,screenWidth:d,screenHeight:p,sdkVersion:e.sdkVersion,systemsInfo:e.systemsInfo,urlParams:e.getQueryValue(),userInfo:e.userInfo,currentUrl:a.currentUrl||e.currentUrl,business:t(t({},c||{}),a.business||{})})}},e.sendData=function(t,n){var r=e.initConfig,i=r.serverUrl,o=r.sendTimeout,a=r.contentType,s=r.showLog,c=r.header;return s&&e.printLog(t),!0!==e.isSupportBeaconSend()||n||c?new Promise((function(r,s){e.ajax({header:n||c,url:i,type:"POST",data:JSON.stringify(t),contentType:a,credentials:!1,timeout:o,cors:!0,success:function(e){return r(e)},error:function(e){return s(e)}})})):e.sendBeacon({contentType:a,url:i,data:t})},e.sendRetained=function(n){var r=e.getParams({event:"PageRetained",desc:e.eventDescMap.PageRetained});if(["beforeunload","pushState","replaceState","hashchange","popstate"].indexOf(n)>=0){var i=e.getCookie("retainedStartTime"),o=i?+i:e.getTimeStamp(),a=t(t({},r),{privateParamMap:t(t({},r.privateParamMap),{retainedDuration:Math.max(r.requestTime-o,0)})});e.sendData(a),e.setCookie("retainedStartTime",e.getTimeStamp())}},e.getItemKey=function(t){return[e.initConfig.appKey,e.pageKey,t?t.toString():void 0].filter((function(e){return!!e})).reduce((function(e,t){return e+(e.length?".":"")+t}),"")},e.sdkVersion="1.1.0",e.initConfig={appKey:"",platform:void 0,showLog:!1,serverUrl:"",autoTrack:!1,sendTimeout:3e3,isTrackSinglePage:!1,contentType:"application/json",business:{},header:void 0},e.systemsInfo={},e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,n),r.prototype.addSinglePageEvent=function(e){var t=this,n=window.history.pushState?"popstate":"hashchange";this.each(["pushState","replaceState",n],(function(n){t.addEventListener(window,n,e)}))},r}(function(){function e(){var e=this;this.getSystemsInfo=function(e){var t=navigator.userAgent,n="other",r=[],i={language:navigator.language},o=t.match(/MicroMessenger\/([\d\.]+)/i),a=o&&o[1]?o[1]:null,s=t.match(/(ipod).*\s([\d_]+)/i),c=t.match(/(ipad).*\s([\d_]+)/i),u=t.match(/(iphone)\sos\s([\d_]+)/i),l=t.match(/(android)\s([\d\.]+)/i),d=t.match(/(Windows NT)\s([\d\.]+)/i),p=t.match(/(Mac OS X)\s([\d_]+)/i);r=[],l?(r.push("Android "+l[2]),n="h5"):u?(r.push("iPhone, iOS "+u[2].replace(/_/g,".")),n="h5"):c?(r.push("iPad, iOS "+c[2].replace(/_/g,".")),n="ipad"):s?(r.push("iPod, iOS "+s[2].replace(/_/g,".")),n="h5"):d?(r.push("Windows "+d[2].replace(/_/g,".")),n="pc"):p&&(r.push("Mac, MacOS "+p[2].replace(/_/g,".")),n="pc"),a&&r.push("WeChat "+a),i.client=r.length?r.join(", "):"Unknown",i.platform=e||n;var g=t.toLowerCase().match(/ nettype\/([^ ]+)/g);return g&&g[0]&&(r=[(g=g[0].split("/"))[1]],i.network=r.length?r.join(", "):"Unknown"),i.ua=t,i},this.addEventListener=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,(function(t){return n.call(e,t)}),!1)},this.removeEventListener=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n):e.detachEvent&&e.detachEvent("on"+t,(function(t){return n.call(e,t)}),!0)},this.rewriteHistory=function(){var e=window.history,t=function(e){var t=window.history,n=t[e],r=new Event(e);return function(){var e=n.apply(t,arguments);return r.arguments=arguments,window.dispatchEvent(r),e}};window.history.pushState&&(e.pushState=t("pushState"),e.replaceState=t("replaceState"))},this.isArray=Array.isArray||function(e){return"[object Array]"===toString.call(e)},this.formatJsonString=function(e){try{return JSON.stringify(e,null," ")}catch(t){return JSON.stringify(e)}},this.nativeForEach=Array.prototype.forEach,this.slice=Array.prototype.slice,this.hasOwnProperty=Object.prototype.hasOwnProperty,this.breaker={},this.each=function(t,n,r){if(null==t)return!1;if(e.nativeForEach&&t.forEach===e.nativeForEach)t.forEach(n,r);else if(e.isArray(t)&&t.length===+t.length){for(var i=0,o=t.length;i<o;i++)if(i in t&&n.call(r,t[i],i,t)===e.breaker)return!1}else for(var a in t)if(e.hasOwnProperty.call(t,a)&&n.call(r,t[a],a,t)===e.breaker)return!1},this.getDomIndex=function(e){if(!e.parentNode)return-1;for(var t=0,n=e.tagName,r=e.parentNode.children,i=0;i<r.length;i++)if(r[i].tagName===n){if(e===r[i])return t;t++}return-1},this.selector=function(t){var n=t.parentNode&&9==t.parentNode.nodeType?-1:e.getDomIndex(t);return t.getAttribute&&t.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(t.getAttribute("id"))?"#"+t.getAttribute("id"):t.tagName.toLowerCase()+(~n?":nth-of-type("+(n+1)+")":"")},this.getDomSelector=function(t,n){if(!t||!t.parentNode||!t.parentNode.children)return!1;n=n&&n.join?n:[];var r=t.nodeName.toLowerCase();return t&&"body"!==r&&1==t.nodeType?(n.unshift(e.selector(t)),t.getAttribute&&t.getAttribute("id")&&/^[A-Za-z][-A-Za-z0-9_:.]*$/.test(t.getAttribute("id"))?n.join(" > "):e.getDomSelector(t.parentNode,n)):(n.unshift("body"),n.join(" > "))},this.getCookie=function(e){for(var t=e+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){for(var i=n[r];" "==i.charAt(0);)i=i.substring(1,i.length);if(0==i.indexOf(t))return this._decodeURIComponent(i.substring(t.length,i.length))}return null},this.setCookie=function(e,t,n){var r,i="";n=null==n?73e3:n;var o=this.getMainHost();if(r=o?"; domain="+o:"",0!==n){var a=new Date;"s"===String(n).slice(-1)?a.setTime(a.getTime()+1e3*Number(String(n).slice(0,-1))):a.setTime(a.getTime()+24*n*60*60*1e3),i="; expires="+a.toUTCString()}function s(e){return e||!1}var c="",u="",l="";e&&(c=s(e)),t&&(u=s(t)),r&&(l=s(r)),c&&u&&(document.cookie=c+"="+encodeURIComponent(u)+i+"; path=/"+l)},this.removeCookie=function(t){e.setCookie(t,"",-1)},this.getTimeStamp=function(){return(new Date).getTime()},this.uuid=function(){return"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},this.getDistinctId=function(){var t=e.getCookie("distinctId");return t||(t=e.uuid(),e.setCookie("distinctId",t),t)},this.getQueryValue=function(){for(var e=decodeURI(window.location.href).match(new RegExp("[?&][^?&]+=[^?&]+","g"))||[],t={},n=0;n<e.length;n++){var r=e[n].replace(/\?|\&/,"").split("=");t[r[0]]=r[1]}return t},this.ajax=function(t){function n(e){if(!e)return"";try{return JSON.parse(e)}catch(e){return{}}}t.timeout=t.timeout||3e4,t.credentials=void 0===t.credentials||t.credentials;var r=e.xhr(t.cors);if(!r)return!1;t.type||(t.type=t.data?"POST":"GET");var i,o=t.success,a=t.error;t.success=function(e){o(e),i&&(clearTimeout(i),i=null)},t.error=function(e){a(e),i&&(clearTimeout(i),i=null)},i=setTimeout((function(){!function(){try{e.isObject(r)&&r.abort&&r.abort()}catch(t){e.printLog(t)}i&&(clearTimeout(i),i=null,t.error&&t.error(),r.onreadystatechange=null,r.onload=null,r.onerror=null)}()}),t.timeout),r.onreadystatechange=function(){try{4==r.readyState&&(r.status>=200&&r.status<300||304==r.status?t.success(n(r.responseText)):t.error(n(r.responseText),r.status),r.onreadystatechange=null,r.onload=null)}catch(e){r.onreadystatechange=null,r.onload=null}},r.open(t.type,t.url,!0);try{t.credentials&&(r.withCredentials=!0),e.isObject(t.header)&&e.each(t.header,(function(e,t){r.setRequestHeader&&r.setRequestHeader(t,e)})),t.data&&(t.cors||r.setRequestHeader&&r.setRequestHeader("X-Requested-With","XMLHttpRequest"),"application/json"===t.contentType?r.setRequestHeader&&r.setRequestHeader("Content-type","application/json; charset=UTF-8"):r.setRequestHeader&&r.setRequestHeader("Content-type","application/x-www-form-urlencoded"))}catch(t){e.printLog(t)}r.send(t.data||null)},this.xhr=function(e){return e?void 0!==window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?new XMLHttpRequest:null:void 0!==window.XMLHttpRequest?new XMLHttpRequest:null},this.getUA=function(){var e,t={},n=navigator.userAgent.toLowerCase();return(e=n.match(/opera.([\d.]+)/))?t.opera=Number(e[1].split(".")[0]):(e=n.match(/msie ([\d.]+)/))?t.ie=Number(e[1].split(".")[0]):(e=n.match(/edge.([\d.]+)/))?t.edge=Number(e[1].split(".")[0]):(e=n.match(/firefox\/([\d.]+)/))?t.firefox=Number(e[1].split(".")[0]):(e=n.match(/chrome\/([\d.]+)/))?t.chrome=Number(e[1].split(".")[0]):(e=n.match(/version\/([\d.]+).*safari/))?t.safari=Number(e[1].match(/^\d*.\d*/)):(e=n.match(/trident\/([\d.]+)/))&&(t.ie=11),t},this.isSupportBeaconSend=function(){var t=!1;if("object"!=typeof navigator||"function"!=typeof navigator.sendBeacon)return t;var n=e.getUA(),r=navigator.userAgent.toLowerCase();if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)){var i=(r.match(/os [\d._]*/gi)+"").replace(/[^0-9|_.]/gi,"").replace(/_/gi,".").split(".");void 0===n.safari&&(n.safari=i[0]),i[0]&&+i[0]<13?(n.chrome>41||n.firefox>30||n.opera>25||n.safari>12)&&(t=!0):(n.chrome>41||n.firefox>30||n.opera>25||n.safari>11.3)&&(t=!0)}else(n.chrome>38||n.edge>13||n.firefox>30||n.opera>25||n.safari>11)&&(t=!0);return t},this.sendBeacon=function(t){if(!0===e.isSupportBeaconSend()){var n={type:t.contentType},r=new Blob([JSON.stringify(t.data)],n);return navigator.sendBeacon(t.url,r)?Promise.resolve({success:!0}):Promise.reject({success:!1})}return Promise.reject({message:"不支持sendBeacon,发送失败!",success:!1})}}return e.prototype.printLog=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(this.isObject(e[0])&&(e[0]=this.formatJsonString(e[0])),"object"==typeof console&&console.log)try{return console.log.apply(console,e)}catch(t){console.log(e[0])}},e.prototype.isObject=function(e){return null!=e&&"[object Object]"==toString.call(e)},e.prototype.isUndefined=function(e){return void 0===e},e.prototype.isString=function(e){return"[object String]"==toString.call(e)},e.prototype.isDate=function(e){return"[object Date]"==toString.call(e)},e.prototype.isBoolean=function(e){return"[object Boolean]"==toString.call(e)},e.prototype.isNumber=function(e){return"[object Number]"==toString.call(e)&&/[\d\.]+/.test(String(e))},e.prototype.isElement=function(e){return!(!e||1!==e.nodeType)},e.prototype.isFunction=function(e){if(!e)return!1;var t=toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t},e.prototype.isJSONString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},e.prototype._decodeURIComponent=function(e){var t=e;try{t=decodeURIComponent(e)}catch(n){t=e}return t},e.prototype.getMainHost=function(){var e="mh_"+Math.random(),t=new RegExp("(^|;)\\s*"+e+"=12345"),n=new Date(0),r=document.domain.split("."),i=[];for(i.unshift(r.pop());r.length;){i.unshift(r.pop());var o=i.join("."),a=e+"=12345;domain=."+o;if(document.cookie=a,t.test(document.cookie))return document.cookie=a+";expires="+n,o}},e}()));export default n;
16
16
  //# sourceMappingURL=index.esm.js.map