spy-client 2.1.12 → 2.1.15

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
@@ -871,13 +871,16 @@ export interface NavigatorInfoMetric {
871
871
 
872
872
  ## 自定义构建
873
873
 
874
+ #### node版本
875
+ node版本 = 16
876
+
874
877
  #### clone准备
875
878
  如果觉得spy-client太大,只想要部分模块,比如禁用 longtask,可以拉取源码,自行编译
876
879
 
877
880
  ```
878
881
  git clone https://github.com/kaivean/spy-client.git
879
882
 
880
- cd spy-log
883
+ cd spy-client
881
884
  npm install
882
885
  ```
883
886
 
@@ -2,7 +2,7 @@
2
2
  * @file 资源、JS、白屏监控的基础
3
3
  * @author kaivean
4
4
  */
5
- import { SpyHeadConf } from '../lib/spyHeadInterface';
5
+ import { SpyHeadConf, SpyHeadUpdateConf } from '../lib/spyHeadInterface';
6
6
  interface SendObj {
7
7
  type?: 'perf' | 'except' | 'dist' | 'count';
8
8
  group: string;
@@ -19,7 +19,8 @@ declare const _default: {
19
19
  observerDestroy(): void;
20
20
  entryMap: any;
21
21
  init(conf: SpyHeadConf): void;
22
+ update(conf: SpyHeadUpdateConf): void;
22
23
  addError(obj: SendObj): void;
23
- send(obj: SendObj, isSend?: boolean | undefined, logServer?: string | undefined): void;
24
+ send(obj: SendObj, isSend?: boolean, logServer?: string): void;
24
25
  };
25
26
  export default _default;
@@ -32,11 +32,11 @@ export declare class Module {
32
32
  export interface FIDMetric {
33
33
  fid: number;
34
34
  }
35
- export declare type FIDCB = (metric: FIDMetric) => void;
35
+ export type FIDCB = (metric: FIDMetric) => void;
36
36
  export interface LCPMetric {
37
37
  lcp: number;
38
38
  }
39
- export declare type LCPCB = (metric: LCPMetric) => void;
39
+ export type LCPCB = (metric: LCPMetric) => void;
40
40
  export declare enum ResType {
41
41
  JS = "js",
42
42
  CSS = "css",
@@ -78,7 +78,7 @@ export interface ResourceHostMetric {
78
78
  hostCacheRate: number;
79
79
  };
80
80
  }
81
- export declare type ResourceCB = (metric: ResourceMetric, hostMetric: ResourceHostMetric) => void;
81
+ export type ResourceCB = (metric: ResourceMetric, hostMetric: ResourceHostMetric) => void;
82
82
  export interface ResourceErrorInfo {
83
83
  msg: string;
84
84
  xpath: string;
@@ -86,7 +86,7 @@ export interface ResourceErrorInfo {
86
86
  type: string;
87
87
  dur?: number;
88
88
  }
89
- export declare type ResourceErrorCB = (info: ResourceErrorInfo) => void;
89
+ export type ResourceErrorCB = (info: ResourceErrorInfo) => void;
90
90
  export interface TimingMetric {
91
91
  dns: number;
92
92
  tcp: number;
@@ -101,11 +101,11 @@ export interface TimingMetric {
101
101
  t7FirstPaint?: number;
102
102
  t7FirstScreen?: number;
103
103
  }
104
- export declare type TimingCB = (metric: TimingMetric) => void;
104
+ export type TimingCB = (metric: TimingMetric) => void;
105
105
  export interface TTIMetric {
106
106
  tti: number;
107
107
  }
108
- export declare type TTICB = (metric: TTIMetric) => void;
108
+ export type TTICB = (metric: TTIMetric) => void;
109
109
  export interface TTIOption {
110
110
  interval?: number;
111
111
  filterRequest?: (entry: PerformanceEntry) => boolean;
@@ -113,14 +113,14 @@ export interface TTIOption {
113
113
  export interface LayoutShiftMetric {
114
114
  layoutShift: number;
115
115
  }
116
- export declare type LayoutShiftCB = (metric: LayoutShiftMetric) => void;
116
+ export type LayoutShiftCB = (metric: LayoutShiftMetric) => void;
117
117
  export interface MemoryMetric {
118
118
  usedJSHeapSize: number;
119
119
  totalJSHeapSize: number;
120
120
  jsHeapSizeLimit: number;
121
121
  usedJSHeapRate: number;
122
122
  }
123
- export declare type MemoryCB = (metric: MemoryMetric) => void;
123
+ export type MemoryCB = (metric: MemoryMetric) => void;
124
124
  export interface NavigatorInfoMetric {
125
125
  downlink?: number;
126
126
  effectiveType?: '2g' | '3g' | '4g' | 'slow-2g';
@@ -129,7 +129,7 @@ export interface NavigatorInfoMetric {
129
129
  deviceMemory?: number;
130
130
  hardwareConcurrency?: number;
131
131
  }
132
- export declare type NavigatorInfoCB = (metric: NavigatorInfoMetric) => void;
132
+ export type NavigatorInfoCB = (metric: NavigatorInfoMetric) => void;
133
133
  export interface FSPLongtaskMetric {
134
134
  fspLongtaskTime: number;
135
135
  fspTBT: number;
@@ -137,7 +137,7 @@ export interface FSPLongtaskMetric {
137
137
  fspLongtaskRate: number;
138
138
  fspLongtaskNum: number;
139
139
  }
140
- export declare type FSPLongtaskCB = (metric: FSPLongtaskMetric) => void;
140
+ export type FSPLongtaskCB = (metric: FSPLongtaskMetric) => void;
141
141
  export interface LCPLongtaskMetric {
142
142
  lcpLongtaskTime: number;
143
143
  lcpTBT: number;
@@ -145,7 +145,7 @@ export interface LCPLongtaskMetric {
145
145
  lcpLongtaskRate: number;
146
146
  lcpLongtaskNum: number;
147
147
  }
148
- export declare type LCPLongtaskCB = (metric: LCPLongtaskMetric) => void;
148
+ export type LCPLongtaskCB = (metric: LCPLongtaskMetric) => void;
149
149
  export interface LoadLongtaskMetric {
150
150
  loadLongtaskTime: number;
151
151
  loadTBT: number;
@@ -153,7 +153,7 @@ export interface LoadLongtaskMetric {
153
153
  loadLongtaskRate: number;
154
154
  loadLongtaskNum: number;
155
155
  }
156
- export declare type LoadLongtaskCB = (metric: LoadLongtaskMetric) => void;
156
+ export type LoadLongtaskCB = (metric: LoadLongtaskMetric) => void;
157
157
  export interface PageLongtaskMetric {
158
158
  pageLongtaskTime: number;
159
159
  pageTBT: number;
@@ -164,7 +164,7 @@ export interface PageLongtaskMetric {
164
164
  pageIframeLongtaskRate: number;
165
165
  pageIframeLongtaskNum: number;
166
166
  }
167
- export declare type PageLongtaskCB = (metric: PageLongtaskMetric) => void;
167
+ export type PageLongtaskCB = (metric: PageLongtaskMetric) => void;
168
168
  export interface ResOption {
169
169
  ignorePaths?: string[];
170
170
  trigger?: 'load' | 'leave';
@@ -26,3 +26,11 @@ export interface SpyHeadConf {
26
26
  resourceError: ErrorConf;
27
27
  whiteScreenError: WhiteScreenErrorConf;
28
28
  }
29
+ export interface SpyHeadUpdateConf {
30
+ pid?: string;
31
+ lid?: string;
32
+ logServer?: string;
33
+ jsError?: ErrorConf;
34
+ resourceError?: ErrorConf;
35
+ whiteScreenError?: WhiteScreenErrorConf;
36
+ }
@@ -24,6 +24,10 @@ interface Option {
24
24
  * 日志服务器,默认是webb服务器,尾部需要加?
25
25
  */
26
26
  logServer?: string;
27
+ /**
28
+ * log ID
29
+ */
30
+ lid?: string;
27
31
  }
28
32
  interface ErrorInfo {
29
33
  /**
@@ -48,6 +52,10 @@ interface ErrorOption {
48
52
  * 抽样,默认是 1,取值从[0, 1],该抽样会覆盖实例初始化时的抽样配置
49
53
  */
50
54
  sample?: number;
55
+ /**
56
+ * log ID
57
+ */
58
+ lid?: string;
51
59
  /**
52
60
  * 业务拓展信息
53
61
  */
@@ -97,6 +105,12 @@ export default class SpyClient {
97
105
  [propName: string]: number;
98
106
  };
99
107
  clearAllMark(): void;
108
+ /**
109
+ * sendPost能以post请求发送,可以承接多个日志项,上报内容size可以提升,但没有前端校验
110
+ * send(data, true) 也能以post请求发送,但是会有严格校验
111
+ * 要求:发送的多条日志必须是同一个pid,同一类型type,同一分组group
112
+ * @param data 日志项或者日志项数组
113
+ */
100
114
  sendPost(data: any): void;
101
115
  protected request(url: string, data?: any): void;
102
116
  protected fetch(url: string, data: any): void;
@@ -31,7 +31,7 @@ var defaultLogServer = 'https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?';
31
31
  var ver = navigator && navigator.userAgent ? navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/) : '';
32
32
  var isLtIos14 = ver && ver[2] && (+ver[2] < 14);
33
33
  function err(msg) {
34
- console.error("[SpyClient_log]" + msg);
34
+ console.error("[SpyClient_log]".concat(msg));
35
35
  // throw new Error(msg);
36
36
  }
37
37
  function stringify(obj) {
@@ -136,7 +136,7 @@ var SpyClient = /** @class */ (function () {
136
136
  for (var _i = 0, _a = Object.keys(query.info); _i < _a.length; _i++) {
137
137
  var infoKey = _a[_i];
138
138
  if (!simpleReg.test(infoKey)) {
139
- err("info." + infoKey + " is unexpected. "
139
+ err("info.".concat(infoKey, " is unexpected. ")
140
140
  + 'Length must be not more than 30. '
141
141
  + 'Supported chars: a-zA-Z0-9-_');
142
142
  return false;
@@ -144,12 +144,12 @@ var SpyClient = /** @class */ (function () {
144
144
  var infoVal = query.info[infoKey];
145
145
  if (query.type === 'dist') {
146
146
  if (infoVal.length > 30) {
147
- err("info." + infoKey + " value length execeeds 30 when type == 'dist'");
147
+ err("info.".concat(infoKey, " value length execeeds 30 when type == 'dist'"));
148
148
  return false;
149
149
  }
150
150
  }
151
151
  else if (typeof infoVal !== 'number') {
152
- err("info." + infoKey + " value must be number");
152
+ err("info.".concat(infoKey, " value must be number"));
153
153
  return false;
154
154
  }
155
155
  }
@@ -158,14 +158,14 @@ var SpyClient = /** @class */ (function () {
158
158
  for (var _b = 0, _c = Object.keys(query.dim); _b < _c.length; _b++) {
159
159
  var dimKey = _c[_b];
160
160
  if (!simpleReg.test(dimKey)) {
161
- err("dim key [" + dimKey + "] is unexpected. "
161
+ err("dim key [".concat(dimKey, "] is unexpected. ")
162
162
  + 'Length must be not more than 30. '
163
163
  + 'Supported chars: a-zA-Z0-9-_');
164
164
  return false;
165
165
  }
166
166
  var dimVal = query.dim[dimKey];
167
167
  if (!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(dimVal)) {
168
- err("dim." + dimKey + " value [" + dimVal + "] is unexpected. "
168
+ err("dim.".concat(dimKey, " value [").concat(dimVal, "] is unexpected. ")
169
169
  + 'Length must be not more than 30. '
170
170
  + 'Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese');
171
171
  return false;
@@ -251,8 +251,12 @@ var SpyClient = /** @class */ (function () {
251
251
  SpyClient.prototype.clearAllMark = function () {
252
252
  this.markCache = {};
253
253
  };
254
- // send(data, true) 也能以post发送,但是会有严格校验
255
- // sendPost能以post发送,但没有校验
254
+ /**
255
+ * sendPost能以post请求发送,可以承接多个日志项,上报内容size可以提升,但没有前端校验
256
+ * send(data, true) 也能以post请求发送,但是会有严格校验
257
+ * 要求:发送的多条日志必须是同一个pid,同一类型type,同一分组group
258
+ * @param data 日志项或者日志项数组
259
+ */
256
260
  SpyClient.prototype.sendPost = function (data) {
257
261
  var logItems = isArray(data) ? data : [data];
258
262
  var first = logItems[0];
@@ -34,7 +34,7 @@ var SpyClient = (function () {
34
34
  var ver = navigator && navigator.userAgent ? navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/) : '';
35
35
  var isLtIos14 = ver && ver[2] && (+ver[2] < 14);
36
36
  function err(msg) {
37
- console.error("[SpyClient_log]" + msg);
37
+ console.error("[SpyClient_log]".concat(msg));
38
38
  // throw new Error(msg);
39
39
  }
40
40
  function stringify(obj) {
@@ -139,7 +139,7 @@ var SpyClient = (function () {
139
139
  for (var _i = 0, _a = Object.keys(query.info); _i < _a.length; _i++) {
140
140
  var infoKey = _a[_i];
141
141
  if (!simpleReg.test(infoKey)) {
142
- err("info." + infoKey + " is unexpected. "
142
+ err("info.".concat(infoKey, " is unexpected. ")
143
143
  + 'Length must be not more than 30. '
144
144
  + 'Supported chars: a-zA-Z0-9-_');
145
145
  return false;
@@ -147,12 +147,12 @@ var SpyClient = (function () {
147
147
  var infoVal = query.info[infoKey];
148
148
  if (query.type === 'dist') {
149
149
  if (infoVal.length > 30) {
150
- err("info." + infoKey + " value length execeeds 30 when type == 'dist'");
150
+ err("info.".concat(infoKey, " value length execeeds 30 when type == 'dist'"));
151
151
  return false;
152
152
  }
153
153
  }
154
154
  else if (typeof infoVal !== 'number') {
155
- err("info." + infoKey + " value must be number");
155
+ err("info.".concat(infoKey, " value must be number"));
156
156
  return false;
157
157
  }
158
158
  }
@@ -161,14 +161,14 @@ var SpyClient = (function () {
161
161
  for (var _b = 0, _c = Object.keys(query.dim); _b < _c.length; _b++) {
162
162
  var dimKey = _c[_b];
163
163
  if (!simpleReg.test(dimKey)) {
164
- err("dim key [" + dimKey + "] is unexpected. "
164
+ err("dim key [".concat(dimKey, "] is unexpected. ")
165
165
  + 'Length must be not more than 30. '
166
166
  + 'Supported chars: a-zA-Z0-9-_');
167
167
  return false;
168
168
  }
169
169
  var dimVal = query.dim[dimKey];
170
170
  if (!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(dimVal)) {
171
- err("dim." + dimKey + " value [" + dimVal + "] is unexpected. "
171
+ err("dim.".concat(dimKey, " value [").concat(dimVal, "] is unexpected. ")
172
172
  + 'Length must be not more than 30. '
173
173
  + 'Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese');
174
174
  return false;
@@ -254,8 +254,12 @@ var SpyClient = (function () {
254
254
  SpyClient.prototype.clearAllMark = function () {
255
255
  this.markCache = {};
256
256
  };
257
- // send(data, true) 也能以post发送,但是会有严格校验
258
- // sendPost能以post发送,但没有校验
257
+ /**
258
+ * sendPost能以post请求发送,可以承接多个日志项,上报内容size可以提升,但没有前端校验
259
+ * send(data, true) 也能以post请求发送,但是会有严格校验
260
+ * 要求:发送的多条日志必须是同一个pid,同一类型type,同一分组group
261
+ * @param data 日志项或者日志项数组
262
+ */
259
263
  SpyClient.prototype.sendPost = function (data) {
260
264
  var logItems = isArray(data) ? data : [data];
261
265
  var first = logItems[0];
@@ -301,4 +305,4 @@ var SpyClient = (function () {
301
305
 
302
306
  return SpyClient;
303
307
 
304
- }());
308
+ })();
@@ -1 +1 @@
1
- var SpyClient=function(){"use strict";function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(Object.assign||function(t){for(var e=void 0,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,t)}var t=navigator&&navigator.userAgent?navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/):"",n=t&&t[2]&&+t[2]<14;function u(t){console.error("[SpyClient_log]"+t)}function s(n){return Object.keys(n).map(function(t){var e=n[t];return void 0===e?e="":"string"!=typeof e&&(e=JSON.stringify(e)),encodeURIComponent(t)+"="+encodeURIComponent(e)}).join("&")}function p(t){return"[object Array]"===Object.prototype.toString.call(t)}function e(t){if(this.sample={},this.markCache={},!t.pid)throw new Error("pid is required");this.option={pid:t.pid,lid:t.lid,check:!1!==t.check,sample:t.sample,localCache:t.localCache,logServer:t.logServer||"https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?"}}return e.prototype.handle=function(t){if(this.check(t)){if(t=o({pid:this.option.pid,lid:this.option.lid,ts:Date.now(),group:"common"},t),this.option.localCache&&this.option.localCache.addLog(t),"number"==typeof t.sample){if(Math.random()>t.sample)return}else if("number"==typeof this.option.sample&&Math.random()>this.option.sample)return;return delete t.sample,t}},e.prototype.send=function(t,e){void 0===e&&(e=!1);for(var n=[],o=0,r=p(t)?t:[t];o<r.length;o++){var i=r[o];if((i=this.handle(i))&&(n.push(i),!e)){var a=this.option.logServer+s(i);this.request(a)}}e&&this.sendPost(n)},e.prototype.check=function(t){if(!this.option.check)return!0;var e=["perf","except","dist","count"];if(-1===e.indexOf(t.type))return u("type only is one of "+e.join(", ")),!1;if(t.group&&30<t.group.length)return u("group length execeeds 30"),!1;var n=/^[a-zA-Z0-9-_]{0,30}$/;if("except"===t.type){if("string"!=typeof t.info.msg||!t.info.msg.length)return u("info.msg field must be not empty and is String"),!1}else for(var o=0,r=Object.keys(t.info);o<r.length;o++){var i=r[o];if(!n.test(i))return u("info."+i+" is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var a=t.info[i];if("dist"===t.type){if(30<a.length)return u("info."+i+" value length execeeds 30 when type == 'dist'"),!1}else if("number"!=typeof a)return u("info."+i+" value must be number"),!1}if(t.dim)for(var s=0,p=Object.keys(t.dim);s<p.length;s++){var c=p[s];if(!n.test(c))return u("dim key ["+c+"] is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var h=t.dim[c];if(!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(h))return u("dim."+c+" value ["+h+"] is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese"),!1}return!0},e.prototype.sendPerf=function(t){this.send(o({type:"perf"},t))},e.prototype.sendExcept=function(t){this.send(o({type:"except"},t))},e.prototype.sendDist=function(t){this.send(o({type:"dist"},t))},e.prototype.sendCount=function(t){this.send(o({type:"count"},t))},e.prototype.sendExceptForError=function(t,e){var n=o({},e);n.info=o({},e.info||{},{msg:t.message,stack:t.stack}),this.sendExcept(n)},e.prototype.startMark=function(t){this.markCache[t]={start:Date.now()}},e.prototype.endMark=function(t){return this.markCache[t]?(this.markCache[t].total=Date.now()-this.markCache[t].start,this.markCache[t].total):0},e.prototype.clearMark=function(t){this.markCache[t]&&delete this.markCache[t]},e.prototype.getAllMark=function(){for(var t={},e=0,n=Object.keys(this.markCache);e<n.length;e++){var o=n[e];t[o]=this.markCache[o].total}return t},e.prototype.clearAllMark=function(){this.markCache={}},e.prototype.sendPost=function(t){var e=(p(t)?t:[t])[0],n={pid:e.pid,type:e.type,group:e.group},o=this.option.logServer+s(n);this.request(o,t)},e.prototype.request=function(t,e){!n&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(t,e?JSON.stringify(e):void 0)||(e?this.fetch(t,e):(new Image).src=t)},e.prototype.fetch=function(t,e){fetch?fetch(t,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}):u("Global fetch method doesn't exist")},e}();
1
+ var SpyClient=(()=>{function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,t)}var t=navigator&&navigator.userAgent?navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/):"",n=t&&t[2]&&+t[2]<14;function u(t){console.error("[SpyClient_log]".concat(t))}function a(n){return Object.keys(n).map(function(t){var e=n[t];return void 0===e?e="":"string"!=typeof e&&(e=JSON.stringify(e)),encodeURIComponent(t)+"="+encodeURIComponent(e)}).join("&")}function s(t){return"[object Array]"===Object.prototype.toString.call(t)}function e(t){if(this.sample={},this.markCache={},!t.pid)throw new Error("pid is required");this.option={pid:t.pid,lid:t.lid,check:!1!==t.check,sample:t.sample,localCache:t.localCache,logServer:t.logServer||"https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?"}}return e.prototype.handle=function(t){if(this.check(t)){if(t=o({pid:this.option.pid,lid:this.option.lid,ts:Date.now(),group:"common"},t),this.option.localCache&&this.option.localCache.addLog(t),"number"==typeof t.sample){if(Math.random()>t.sample)return}else if("number"==typeof this.option.sample&&Math.random()>this.option.sample)return;return delete t.sample,t}},e.prototype.send=function(t,e){void 0===e&&(e=!1);for(var n=[],o=0,r=s(t)?t:[t];o<r.length;o++){var i=r[o];(i=this.handle(i))&&(n.push(i),e||(i=this.option.logServer+a(i),this.request(i)))}e&&this.sendPost(n)},e.prototype.check=function(t){if(this.option.check){var e=["perf","except","dist","count"];if(-1===e.indexOf(t.type))return u("type only is one of "+e.join(", ")),!1;if(t.group&&30<t.group.length)return u("group length execeeds 30"),!1;var n=/^[a-zA-Z0-9-_]{0,30}$/;if("except"===t.type){if("string"!=typeof t.info.msg||!t.info.msg.length)return u("info.msg field must be not empty and is String"),!1}else for(var o=0,r=Object.keys(t.info);o<r.length;o++){var i=r[o];if(!n.test(i))return u("info.".concat(i," is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var a=t.info[i];if("dist"===t.type){if(30<a.length)return u("info.".concat(i," value length execeeds 30 when type == 'dist'")),!1}else if("number"!=typeof a)return u("info.".concat(i," value must be number")),!1}if(t.dim)for(var s=0,p=Object.keys(t.dim);s<p.length;s++){var c=p[s];if(!n.test(c))return u("dim key [".concat(c,"] is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var h=t.dim[c];if(!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(h))return u("dim.".concat(c," value [").concat(h,"] is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese"),!1}}return!0},e.prototype.sendPerf=function(t){this.send(o({type:"perf"},t))},e.prototype.sendExcept=function(t){this.send(o({type:"except"},t))},e.prototype.sendDist=function(t){this.send(o({type:"dist"},t))},e.prototype.sendCount=function(t){this.send(o({type:"count"},t))},e.prototype.sendExceptForError=function(t,e){var n=o({},e);n.info=o({},e.info||{},{msg:t.message,stack:t.stack}),this.sendExcept(n)},e.prototype.startMark=function(t){this.markCache[t]={start:Date.now()}},e.prototype.endMark=function(t){return this.markCache[t]?(this.markCache[t].total=Date.now()-this.markCache[t].start,this.markCache[t].total):0},e.prototype.clearMark=function(t){this.markCache[t]&&delete this.markCache[t]},e.prototype.getAllMark=function(){for(var t={},e=0,n=Object.keys(this.markCache);e<n.length;e++){var o=n[e];t[o]=this.markCache[o].total}return t},e.prototype.clearAllMark=function(){this.markCache={}},e.prototype.sendPost=function(t){var e=(s(t)?t:[t])[0],e={pid:e.pid,type:e.type,group:e.group},e=this.option.logServer+a(e);this.request(e,t)},e.prototype.request=function(t,e){!n&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(t,e?JSON.stringify(e):void 0)||(e?this.fetch(t,e):(new Image).src=t)},e.prototype.fetch=function(t,e){fetch?fetch(t,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}):u("Global fetch method doesn't exist")},e})();
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SpyClient = factory());
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * @file utils
@@ -37,7 +37,7 @@
37
37
  var ver = navigator && navigator.userAgent ? navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/) : '';
38
38
  var isLtIos14 = ver && ver[2] && (+ver[2] < 14);
39
39
  function err(msg) {
40
- console.error("[SpyClient_log]" + msg);
40
+ console.error("[SpyClient_log]".concat(msg));
41
41
  // throw new Error(msg);
42
42
  }
43
43
  function stringify(obj) {
@@ -142,7 +142,7 @@
142
142
  for (var _i = 0, _a = Object.keys(query.info); _i < _a.length; _i++) {
143
143
  var infoKey = _a[_i];
144
144
  if (!simpleReg.test(infoKey)) {
145
- err("info." + infoKey + " is unexpected. "
145
+ err("info.".concat(infoKey, " is unexpected. ")
146
146
  + 'Length must be not more than 30. '
147
147
  + 'Supported chars: a-zA-Z0-9-_');
148
148
  return false;
@@ -150,12 +150,12 @@
150
150
  var infoVal = query.info[infoKey];
151
151
  if (query.type === 'dist') {
152
152
  if (infoVal.length > 30) {
153
- err("info." + infoKey + " value length execeeds 30 when type == 'dist'");
153
+ err("info.".concat(infoKey, " value length execeeds 30 when type == 'dist'"));
154
154
  return false;
155
155
  }
156
156
  }
157
157
  else if (typeof infoVal !== 'number') {
158
- err("info." + infoKey + " value must be number");
158
+ err("info.".concat(infoKey, " value must be number"));
159
159
  return false;
160
160
  }
161
161
  }
@@ -164,14 +164,14 @@
164
164
  for (var _b = 0, _c = Object.keys(query.dim); _b < _c.length; _b++) {
165
165
  var dimKey = _c[_b];
166
166
  if (!simpleReg.test(dimKey)) {
167
- err("dim key [" + dimKey + "] is unexpected. "
167
+ err("dim key [".concat(dimKey, "] is unexpected. ")
168
168
  + 'Length must be not more than 30. '
169
169
  + 'Supported chars: a-zA-Z0-9-_');
170
170
  return false;
171
171
  }
172
172
  var dimVal = query.dim[dimKey];
173
173
  if (!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(dimVal)) {
174
- err("dim." + dimKey + " value [" + dimVal + "] is unexpected. "
174
+ err("dim.".concat(dimKey, " value [").concat(dimVal, "] is unexpected. ")
175
175
  + 'Length must be not more than 30. '
176
176
  + 'Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese');
177
177
  return false;
@@ -257,8 +257,12 @@
257
257
  SpyClient.prototype.clearAllMark = function () {
258
258
  this.markCache = {};
259
259
  };
260
- // send(data, true) 也能以post发送,但是会有严格校验
261
- // sendPost能以post发送,但没有校验
260
+ /**
261
+ * sendPost能以post请求发送,可以承接多个日志项,上报内容size可以提升,但没有前端校验
262
+ * send(data, true) 也能以post请求发送,但是会有严格校验
263
+ * 要求:发送的多条日志必须是同一个pid,同一类型type,同一分组group
264
+ * @param data 日志项或者日志项数组
265
+ */
262
266
  SpyClient.prototype.sendPost = function (data) {
263
267
  var logItems = isArray(data) ? data : [data];
264
268
  var first = logItems[0];
@@ -304,4 +308,4 @@
304
308
 
305
309
  return SpyClient;
306
310
 
307
- })));
311
+ }));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SpyClient=t()}(this,function(){"use strict";function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return(Object.assign||function(e){for(var t=void 0,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,e)}var e=navigator&&navigator.userAgent?navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/):"",n=e&&e[2]&&+e[2]<14;function f(e){console.error("[SpyClient_log]"+e)}function a(n){return Object.keys(n).map(function(e){var t=n[e];return void 0===t?t="":"string"!=typeof t&&(t=JSON.stringify(t)),encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&")}function p(e){return"[object Array]"===Object.prototype.toString.call(e)}function t(e){if(this.sample={},this.markCache={},!e.pid)throw new Error("pid is required");this.option={pid:e.pid,lid:e.lid,check:!1!==e.check,sample:e.sample,localCache:e.localCache,logServer:e.logServer||"https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?"}}return t.prototype.handle=function(e){if(this.check(e)){if(e=o({pid:this.option.pid,lid:this.option.lid,ts:Date.now(),group:"common"},e),this.option.localCache&&this.option.localCache.addLog(e),"number"==typeof e.sample){if(Math.random()>e.sample)return}else if("number"==typeof this.option.sample&&Math.random()>this.option.sample)return;return delete e.sample,e}},t.prototype.send=function(e,t){void 0===t&&(t=!1);for(var n=[],o=0,r=p(e)?e:[e];o<r.length;o++){var i=r[o];if((i=this.handle(i))&&(n.push(i),!t)){var s=this.option.logServer+a(i);this.request(s)}}t&&this.sendPost(n)},t.prototype.check=function(e){if(!this.option.check)return!0;var t=["perf","except","dist","count"];if(-1===t.indexOf(e.type))return f("type only is one of "+t.join(", ")),!1;if(e.group&&30<e.group.length)return f("group length execeeds 30"),!1;var n=/^[a-zA-Z0-9-_]{0,30}$/;if("except"===e.type){if("string"!=typeof e.info.msg||!e.info.msg.length)return f("info.msg field must be not empty and is String"),!1}else for(var o=0,r=Object.keys(e.info);o<r.length;o++){var i=r[o];if(!n.test(i))return f("info."+i+" is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var s=e.info[i];if("dist"===e.type){if(30<s.length)return f("info."+i+" value length execeeds 30 when type == 'dist'"),!1}else if("number"!=typeof s)return f("info."+i+" value must be number"),!1}if(e.dim)for(var a=0,p=Object.keys(e.dim);a<p.length;a++){var c=p[a];if(!n.test(c))return f("dim key ["+c+"] is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var h=e.dim[c];if(!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(h))return f("dim."+c+" value ["+h+"] is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese"),!1}return!0},t.prototype.sendPerf=function(e){this.send(o({type:"perf"},e))},t.prototype.sendExcept=function(e){this.send(o({type:"except"},e))},t.prototype.sendDist=function(e){this.send(o({type:"dist"},e))},t.prototype.sendCount=function(e){this.send(o({type:"count"},e))},t.prototype.sendExceptForError=function(e,t){var n=o({},t);n.info=o({},t.info||{},{msg:e.message,stack:e.stack}),this.sendExcept(n)},t.prototype.startMark=function(e){this.markCache[e]={start:Date.now()}},t.prototype.endMark=function(e){return this.markCache[e]?(this.markCache[e].total=Date.now()-this.markCache[e].start,this.markCache[e].total):0},t.prototype.clearMark=function(e){this.markCache[e]&&delete this.markCache[e]},t.prototype.getAllMark=function(){for(var e={},t=0,n=Object.keys(this.markCache);t<n.length;t++){var o=n[t];e[o]=this.markCache[o].total}return e},t.prototype.clearAllMark=function(){this.markCache={}},t.prototype.sendPost=function(e){var t=(p(e)?e:[e])[0],n={pid:t.pid,type:t.type,group:t.group},o=this.option.logServer+a(n);this.request(o,e)},t.prototype.request=function(e,t){!n&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(e,t?JSON.stringify(t):void 0)||(t?this.fetch(e,t):(new Image).src=e)},t.prototype.fetch=function(e,t){fetch?fetch(e,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}):f("Global fetch method doesn't exist")},t});
1
+ ((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).SpyClient=e()})(this,function(){function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,t)}var t=navigator&&navigator.userAgent?navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/):"",n=t&&t[2]&&+t[2]<14;function f(t){console.error("[SpyClient_log]".concat(t))}function a(n){return Object.keys(n).map(function(t){var e=n[t];return void 0===e?e="":"string"!=typeof e&&(e=JSON.stringify(e)),encodeURIComponent(t)+"="+encodeURIComponent(e)}).join("&")}function s(t){return"[object Array]"===Object.prototype.toString.call(t)}function e(t){if(this.sample={},this.markCache={},!t.pid)throw new Error("pid is required");this.option={pid:t.pid,lid:t.lid,check:!1!==t.check,sample:t.sample,localCache:t.localCache,logServer:t.logServer||"https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?"}}return e.prototype.handle=function(t){if(this.check(t)){if(t=o({pid:this.option.pid,lid:this.option.lid,ts:Date.now(),group:"common"},t),this.option.localCache&&this.option.localCache.addLog(t),"number"==typeof t.sample){if(Math.random()>t.sample)return}else if("number"==typeof this.option.sample&&Math.random()>this.option.sample)return;return delete t.sample,t}},e.prototype.send=function(t,e){void 0===e&&(e=!1);for(var n=[],o=0,r=s(t)?t:[t];o<r.length;o++){var i=r[o];(i=this.handle(i))&&(n.push(i),e||(i=this.option.logServer+a(i),this.request(i)))}e&&this.sendPost(n)},e.prototype.check=function(t){if(this.option.check){var e=["perf","except","dist","count"];if(-1===e.indexOf(t.type))return f("type only is one of "+e.join(", ")),!1;if(t.group&&30<t.group.length)return f("group length execeeds 30"),!1;var n=/^[a-zA-Z0-9-_]{0,30}$/;if("except"===t.type){if("string"!=typeof t.info.msg||!t.info.msg.length)return f("info.msg field must be not empty and is String"),!1}else for(var o=0,r=Object.keys(t.info);o<r.length;o++){var i=r[o];if(!n.test(i))return f("info.".concat(i," is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var a=t.info[i];if("dist"===t.type){if(30<a.length)return f("info.".concat(i," value length execeeds 30 when type == 'dist'")),!1}else if("number"!=typeof a)return f("info.".concat(i," value must be number")),!1}if(t.dim)for(var s=0,p=Object.keys(t.dim);s<p.length;s++){var c=p[s];if(!n.test(c))return f("dim key [".concat(c,"] is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var h=t.dim[c];if(!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(h))return f("dim.".concat(c," value [").concat(h,"] is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese"),!1}}return!0},e.prototype.sendPerf=function(t){this.send(o({type:"perf"},t))},e.prototype.sendExcept=function(t){this.send(o({type:"except"},t))},e.prototype.sendDist=function(t){this.send(o({type:"dist"},t))},e.prototype.sendCount=function(t){this.send(o({type:"count"},t))},e.prototype.sendExceptForError=function(t,e){var n=o({},e);n.info=o({},e.info||{},{msg:t.message,stack:t.stack}),this.sendExcept(n)},e.prototype.startMark=function(t){this.markCache[t]={start:Date.now()}},e.prototype.endMark=function(t){return this.markCache[t]?(this.markCache[t].total=Date.now()-this.markCache[t].start,this.markCache[t].total):0},e.prototype.clearMark=function(t){this.markCache[t]&&delete this.markCache[t]},e.prototype.getAllMark=function(){for(var t={},e=0,n=Object.keys(this.markCache);e<n.length;e++){var o=n[e];t[o]=this.markCache[o].total}return t},e.prototype.clearAllMark=function(){this.markCache={}},e.prototype.sendPost=function(t){var e=(s(t)?t:[t])[0],e={pid:e.pid,type:e.type,group:e.group},e=this.option.logServer+a(e);this.request(e,t)},e.prototype.request=function(t,e){!n&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(t,e?JSON.stringify(e):void 0)||(e?this.fetch(t,e):(new Image).src=t)},e.prototype.fetch=function(t,e){fetch?fetch(t,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}):f("Global fetch method doesn't exist")},e});
@@ -31,7 +31,7 @@ var defaultLogServer = 'https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?';
31
31
  var ver = navigator && navigator.userAgent ? navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/) : '';
32
32
  var isLtIos14 = ver && ver[2] && (+ver[2] < 14);
33
33
  function err(msg) {
34
- console.error("[SpyClient_log]" + msg);
34
+ console.error("[SpyClient_log]".concat(msg));
35
35
  // throw new Error(msg);
36
36
  }
37
37
  function stringify(obj) {
@@ -136,7 +136,7 @@ var SpyClient = /** @class */ (function () {
136
136
  for (var _i = 0, _a = Object.keys(query.info); _i < _a.length; _i++) {
137
137
  var infoKey = _a[_i];
138
138
  if (!simpleReg.test(infoKey)) {
139
- err("info." + infoKey + " is unexpected. "
139
+ err("info.".concat(infoKey, " is unexpected. ")
140
140
  + 'Length must be not more than 30. '
141
141
  + 'Supported chars: a-zA-Z0-9-_');
142
142
  return false;
@@ -144,12 +144,12 @@ var SpyClient = /** @class */ (function () {
144
144
  var infoVal = query.info[infoKey];
145
145
  if (query.type === 'dist') {
146
146
  if (infoVal.length > 30) {
147
- err("info." + infoKey + " value length execeeds 30 when type == 'dist'");
147
+ err("info.".concat(infoKey, " value length execeeds 30 when type == 'dist'"));
148
148
  return false;
149
149
  }
150
150
  }
151
151
  else if (typeof infoVal !== 'number') {
152
- err("info." + infoKey + " value must be number");
152
+ err("info.".concat(infoKey, " value must be number"));
153
153
  return false;
154
154
  }
155
155
  }
@@ -158,14 +158,14 @@ var SpyClient = /** @class */ (function () {
158
158
  for (var _b = 0, _c = Object.keys(query.dim); _b < _c.length; _b++) {
159
159
  var dimKey = _c[_b];
160
160
  if (!simpleReg.test(dimKey)) {
161
- err("dim key [" + dimKey + "] is unexpected. "
161
+ err("dim key [".concat(dimKey, "] is unexpected. ")
162
162
  + 'Length must be not more than 30. '
163
163
  + 'Supported chars: a-zA-Z0-9-_');
164
164
  return false;
165
165
  }
166
166
  var dimVal = query.dim[dimKey];
167
167
  if (!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(dimVal)) {
168
- err("dim." + dimKey + " value [" + dimVal + "] is unexpected. "
168
+ err("dim.".concat(dimKey, " value [").concat(dimVal, "] is unexpected. ")
169
169
  + 'Length must be not more than 30. '
170
170
  + 'Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese');
171
171
  return false;
@@ -251,8 +251,12 @@ var SpyClient = /** @class */ (function () {
251
251
  SpyClient.prototype.clearAllMark = function () {
252
252
  this.markCache = {};
253
253
  };
254
- // send(data, true) 也能以post发送,但是会有严格校验
255
- // sendPost能以post发送,但没有校验
254
+ /**
255
+ * sendPost能以post请求发送,可以承接多个日志项,上报内容size可以提升,但没有前端校验
256
+ * send(data, true) 也能以post请求发送,但是会有严格校验
257
+ * 要求:发送的多条日志必须是同一个pid,同一类型type,同一分组group
258
+ * @param data 日志项或者日志项数组
259
+ */
256
260
  SpyClient.prototype.sendPost = function (data) {
257
261
  var logItems = isArray(data) ? data : [data];
258
262
  var first = logItems[0];
@@ -1,16 +1,16 @@
1
1
  /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation. All rights reserved.
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
- this file except in compliance with the License. You may obtain a copy of the
5
- License at http://www.apache.org/licenses/LICENSE-2.0
2
+ Copyright (c) Microsoft Corporation.
6
3
 
7
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
- MERCHANTABLITY OR NON-INFRINGEMENT.
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
11
6
 
12
- See the Apache Version 2.0 License for specific language governing permissions
13
- and limitations under the License.
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
14
  ***************************************************************************** */
15
15
  /* global Reflect, Promise */
16
16
 
@@ -141,7 +141,7 @@ var defaultLogServer = 'https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?';
141
141
  var ver = navigator && navigator.userAgent ? navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?)_/) : '';
142
142
  var isLtIos14 = ver && ver[2] && (+ver[2] < 14);
143
143
  function err(msg) {
144
- console.error("[SpyClient_log]" + msg);
144
+ console.error("[SpyClient_log]".concat(msg));
145
145
  // throw new Error(msg);
146
146
  }
147
147
  function stringify(obj) {
@@ -246,7 +246,7 @@ var SpyClient$1 = /** @class */ (function () {
246
246
  for (var _i = 0, _a = Object.keys(query.info); _i < _a.length; _i++) {
247
247
  var infoKey = _a[_i];
248
248
  if (!simpleReg.test(infoKey)) {
249
- err("info." + infoKey + " is unexpected. "
249
+ err("info.".concat(infoKey, " is unexpected. ")
250
250
  + 'Length must be not more than 30. '
251
251
  + 'Supported chars: a-zA-Z0-9-_');
252
252
  return false;
@@ -254,12 +254,12 @@ var SpyClient$1 = /** @class */ (function () {
254
254
  var infoVal = query.info[infoKey];
255
255
  if (query.type === 'dist') {
256
256
  if (infoVal.length > 30) {
257
- err("info." + infoKey + " value length execeeds 30 when type == 'dist'");
257
+ err("info.".concat(infoKey, " value length execeeds 30 when type == 'dist'"));
258
258
  return false;
259
259
  }
260
260
  }
261
261
  else if (typeof infoVal !== 'number') {
262
- err("info." + infoKey + " value must be number");
262
+ err("info.".concat(infoKey, " value must be number"));
263
263
  return false;
264
264
  }
265
265
  }
@@ -268,14 +268,14 @@ var SpyClient$1 = /** @class */ (function () {
268
268
  for (var _b = 0, _c = Object.keys(query.dim); _b < _c.length; _b++) {
269
269
  var dimKey = _c[_b];
270
270
  if (!simpleReg.test(dimKey)) {
271
- err("dim key [" + dimKey + "] is unexpected. "
271
+ err("dim key [".concat(dimKey, "] is unexpected. ")
272
272
  + 'Length must be not more than 30. '
273
273
  + 'Supported chars: a-zA-Z0-9-_');
274
274
  return false;
275
275
  }
276
276
  var dimVal = query.dim[dimKey];
277
277
  if (!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(dimVal)) {
278
- err("dim." + dimKey + " value [" + dimVal + "] is unexpected. "
278
+ err("dim.".concat(dimKey, " value [").concat(dimVal, "] is unexpected. ")
279
279
  + 'Length must be not more than 30. '
280
280
  + 'Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese');
281
281
  return false;
@@ -361,8 +361,12 @@ var SpyClient$1 = /** @class */ (function () {
361
361
  SpyClient.prototype.clearAllMark = function () {
362
362
  this.markCache = {};
363
363
  };
364
- // send(data, true) 也能以post发送,但是会有严格校验
365
- // sendPost能以post发送,但没有校验
364
+ /**
365
+ * sendPost能以post请求发送,可以承接多个日志项,上报内容size可以提升,但没有前端校验
366
+ * send(data, true) 也能以post请求发送,但是会有严格校验
367
+ * 要求:发送的多条日志必须是同一个pid,同一类型type,同一分组group
368
+ * @param data 日志项或者日志项数组
369
+ */
366
370
  SpyClient.prototype.sendPost = function (data) {
367
371
  var logItems = isArray(data) ? data : [data];
368
372
  var first = logItems[0];