@cloudcare/rum-uniapp 2.2.4 → 2.2.6

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.
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildEnv = void 0;
7
7
  var buildEnv = exports.buildEnv = {
8
- sdkVersion: '2.2.4',
8
+ sdkVersion: '2.2.6',
9
9
  sdkName: 'df_uniapp_rum_sdk'
10
10
  };
@@ -11,10 +11,10 @@ var _lifeCycle = require("../core/lifeCycle");
11
11
  var _dataMap = require("./dataMap");
12
12
  // https://en.wikipedia.org/wiki/UTF-8
13
13
  var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/;
14
- var CUSTOM_KEYS = 'custom_keys';
14
+ var CUSTOM_KEYS = "custom_keys";
15
15
  function addBatchPrecision(url) {
16
16
  if (!url) return url;
17
- return url + (url.indexOf('?') === -1 ? '?' : '&') + 'precision=ms';
17
+ return url + (url.indexOf("?") === -1 ? "?" : "&") + "precision=ms";
18
18
  }
19
19
  var httpRequest = function httpRequest(endpointUrl, bytesLimit) {
20
20
  this.endpointUrl = endpointUrl;
@@ -24,10 +24,12 @@ httpRequest.prototype = {
24
24
  send: function send(data) {
25
25
  var url = addBatchPrecision(this.endpointUrl);
26
26
  _sdk.sdk.request({
27
- method: 'POST',
27
+ method: "POST",
28
28
  header: {
29
- 'content-type': 'text/plain;charset=UTF-8'
29
+ "content-type": "text/plain;charset=UTF-8"
30
+ // "x-client-timestamp": new Date().getTime().toString(),
30
31
  },
32
+
31
33
  url: url,
32
34
  data: data
33
35
  });
@@ -36,7 +38,7 @@ httpRequest.prototype = {
36
38
  var HttpRequest = exports.HttpRequest = httpRequest;
37
39
  var processedMessageByDataMap = exports.processedMessageByDataMap = function processedMessageByDataMap(message) {
38
40
  if (!message || !message.type) return {
39
- rowStr: '',
41
+ rowStr: "",
40
42
  rowData: undefined
41
43
  };
42
44
  var rowData = {
@@ -44,24 +46,24 @@ var processedMessageByDataMap = exports.processedMessageByDataMap = function pro
44
46
  fields: {}
45
47
  };
46
48
  var hasFileds = false;
47
- var rowStr = '';
49
+ var rowStr = "";
48
50
  (0, _utils.each)(_dataMap.dataMap, function (value, key) {
49
51
  if (value.type === message.type) {
50
52
  if (value.alias_key) {
51
- rowStr += value.alias_key + ',';
53
+ rowStr += value.alias_key + ",";
52
54
  } else {
53
- rowStr += key + ',';
55
+ rowStr += key + ",";
54
56
  }
55
57
  rowData.measurement = key;
56
58
  var tagsStr = [];
57
59
  var tags = (0, _utils.extend)({}, _dataMap.commonTags, value.tags);
58
- var filterFileds = ['date', 'type', CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
60
+ var filterFileds = ["date", "type", CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
59
61
  (0, _utils.each)(tags, function (value_path, _key) {
60
62
  var _value = (0, _utils.findByPath)(message, value_path);
61
63
  filterFileds.push(_key);
62
64
  if (_value || (0, _utils.isNumber)(_value)) {
63
65
  rowData.tags[_key] = (0, _utils.escapeJsonValue)(_value);
64
- tagsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowData)(_value));
66
+ tagsStr.push((0, _utils.escapeRowData)(_key) + "=" + (0, _utils.escapeRowData)(_value));
65
67
  }
66
68
  });
67
69
  var fields = (0, _utils.extend)({}, _dataMap.commonFields, value.fields);
@@ -74,14 +76,14 @@ var processedMessageByDataMap = exports.processedMessageByDataMap = function pro
74
76
  filterFileds.push(_key);
75
77
  if (_valueData || (0, _utils.isNumber)(_valueData)) {
76
78
  rowData.fields[_key] = _valueData; // 这里不需要转译
77
- fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_valueData));
79
+ fieldsStr.push((0, _utils.escapeRowData)(_key) + "=" + (0, _utils.escapeRowField)(_valueData));
78
80
  }
79
81
  } else if ((0, _utils.isString)(_value)) {
80
82
  var _valueData = (0, _utils.findByPath)(message, _value);
81
83
  filterFileds.push(_key);
82
84
  if (_valueData || (0, _utils.isNumber)(_valueData)) {
83
85
  rowData.fields[_key] = _valueData; // 这里不需要转译
84
- fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_valueData));
86
+ fieldsStr.push((0, _utils.escapeRowData)(_key) + "=" + (0, _utils.escapeRowField)(_valueData));
85
87
  }
86
88
  }
87
89
  });
@@ -95,29 +97,29 @@ var processedMessageByDataMap = exports.processedMessageByDataMap = function pro
95
97
  if (_value || (0, _utils.isNumber)(_value)) {
96
98
  _tagKeys.push(_key);
97
99
  rowData.fields[_key] = _value; // 这里不需要转译
98
- fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_value));
100
+ fieldsStr.push((0, _utils.escapeRowData)(_key) + "=" + (0, _utils.escapeRowField)(_value));
99
101
  }
100
102
  });
101
103
  if (_tagKeys.length) {
102
104
  rowData.fields[CUSTOM_KEYS] = (0, _utils.escapeRowField)(_tagKeys);
103
- fieldsStr.push((0, _utils.escapeRowData)(CUSTOM_KEYS) + '=' + (0, _utils.escapeRowField)(_tagKeys));
105
+ fieldsStr.push((0, _utils.escapeRowData)(CUSTOM_KEYS) + "=" + (0, _utils.escapeRowField)(_tagKeys));
104
106
  }
105
107
  }
106
108
  if (tagsStr.length) {
107
- rowStr += tagsStr.join(',');
109
+ rowStr += tagsStr.join(",");
108
110
  }
109
111
  if (fieldsStr.length) {
110
- rowStr += ' ';
111
- rowStr += fieldsStr.join(',');
112
+ rowStr += " ";
113
+ rowStr += fieldsStr.join(",");
112
114
  hasFileds = true;
113
115
  }
114
- rowStr = rowStr + ' ' + message.date;
116
+ rowStr = rowStr + " " + message.date;
115
117
  rowData.time = (0, _utils.toServerDuration)(message.date); // 这里不需要转译
116
118
  }
117
119
  });
118
120
 
119
121
  return {
120
- rowStr: hasFileds ? rowStr : '',
122
+ rowStr: hasFileds ? rowStr : "",
121
123
  rowData: hasFileds ? rowData : undefined
122
124
  };
123
125
  };
@@ -145,7 +147,7 @@ batch.prototype = {
145
147
  flush: function flush() {
146
148
  if (this.bufferMessageCount !== 0) {
147
149
  var messages = this.pushOnlyBuffer.concat((0, _utils.values)(this.upsertBuffer));
148
- this.request.send(messages.join('\n'), this.bufferBytesSize);
150
+ this.request.send(messages.join("\n"), this.bufferBytesSize);
149
151
  this.pushOnlyBuffer = [];
150
152
  this.upsertBuffer = {};
151
153
  this.bufferBytesSize = 0;
@@ -157,9 +159,9 @@ batch.prototype = {
157
159
  },
158
160
  addOrUpdate: function addOrUpdate(message, key) {
159
161
  var process = this.process(message);
160
- if (!process.processedMessage || process.processedMessage === '') return;
162
+ if (!process.processedMessage || process.processedMessage === "") return;
161
163
  if (process.messageBytesSize >= this.maxMessageSize) {
162
- console.warn('Discarded a message whose size was bigger than the maximum allowed size' + this.maxMessageSize + 'KB.');
164
+ console.warn("Discarded a message whose size was bigger than the maximum allowed size" + this.maxMessageSize + "KB.");
163
165
  return;
164
166
  }
165
167
  if (this.hasMessageFor(key)) {
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.2.4',
2
+ sdkVersion: '2.2.6',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -1,15 +1,15 @@
1
- import { findByPath, escapeRowData, isNumber, each, isString, values, extend, isObject, isEmptyObject, isArray, escapeRowField, escapeJsonValue, toServerDuration } from '../helper/utils';
2
- import { sdk } from '../core/sdk';
3
- import { computeBytesCount } from '../helper/byteUtils';
4
- import { LifeCycleEventType } from '../core/lifeCycle';
5
- import { commonTags, dataMap, commonFields } from './dataMap';
1
+ import { findByPath, escapeRowData, isNumber, each, isString, values, extend, isObject, isEmptyObject, isArray, escapeRowField, escapeJsonValue, toServerDuration } from "../helper/utils";
2
+ import { sdk } from "../core/sdk";
3
+ import { computeBytesCount } from "../helper/byteUtils";
4
+ import { LifeCycleEventType } from "../core/lifeCycle";
5
+ import { commonTags, dataMap, commonFields } from "./dataMap";
6
6
 
7
7
  // https://en.wikipedia.org/wiki/UTF-8
8
8
  var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/;
9
- var CUSTOM_KEYS = 'custom_keys';
9
+ var CUSTOM_KEYS = "custom_keys";
10
10
  function addBatchPrecision(url) {
11
11
  if (!url) return url;
12
- return url + (url.indexOf('?') === -1 ? '?' : '&') + 'precision=ms';
12
+ return url + (url.indexOf("?") === -1 ? "?" : "&") + "precision=ms";
13
13
  }
14
14
  var httpRequest = function httpRequest(endpointUrl, bytesLimit) {
15
15
  this.endpointUrl = endpointUrl;
@@ -19,10 +19,12 @@ httpRequest.prototype = {
19
19
  send: function send(data) {
20
20
  var url = addBatchPrecision(this.endpointUrl);
21
21
  sdk.request({
22
- method: 'POST',
22
+ method: "POST",
23
23
  header: {
24
- 'content-type': 'text/plain;charset=UTF-8'
24
+ "content-type": "text/plain;charset=UTF-8"
25
+ // "x-client-timestamp": new Date().getTime().toString(),
25
26
  },
27
+
26
28
  url,
27
29
  data
28
30
  });
@@ -31,7 +33,7 @@ httpRequest.prototype = {
31
33
  export var HttpRequest = httpRequest;
32
34
  export var processedMessageByDataMap = function processedMessageByDataMap(message) {
33
35
  if (!message || !message.type) return {
34
- rowStr: '',
36
+ rowStr: "",
35
37
  rowData: undefined
36
38
  };
37
39
  var rowData = {
@@ -39,24 +41,24 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
39
41
  fields: {}
40
42
  };
41
43
  var hasFileds = false;
42
- var rowStr = '';
44
+ var rowStr = "";
43
45
  each(dataMap, function (value, key) {
44
46
  if (value.type === message.type) {
45
47
  if (value.alias_key) {
46
- rowStr += value.alias_key + ',';
48
+ rowStr += value.alias_key + ",";
47
49
  } else {
48
- rowStr += key + ',';
50
+ rowStr += key + ",";
49
51
  }
50
52
  rowData.measurement = key;
51
53
  var tagsStr = [];
52
54
  var tags = extend({}, commonTags, value.tags);
53
- var filterFileds = ['date', 'type', CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
55
+ var filterFileds = ["date", "type", CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
54
56
  each(tags, function (value_path, _key) {
55
57
  var _value = findByPath(message, value_path);
56
58
  filterFileds.push(_key);
57
59
  if (_value || isNumber(_value)) {
58
60
  rowData.tags[_key] = escapeJsonValue(_value);
59
- tagsStr.push(escapeRowData(_key) + '=' + escapeRowData(_value));
61
+ tagsStr.push(escapeRowData(_key) + "=" + escapeRowData(_value));
60
62
  }
61
63
  });
62
64
  var fields = extend({}, commonFields, value.fields);
@@ -69,14 +71,14 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
69
71
  filterFileds.push(_key);
70
72
  if (_valueData || isNumber(_valueData)) {
71
73
  rowData.fields[_key] = _valueData; // 这里不需要转译
72
- fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_valueData));
74
+ fieldsStr.push(escapeRowData(_key) + "=" + escapeRowField(_valueData));
73
75
  }
74
76
  } else if (isString(_value)) {
75
77
  var _valueData = findByPath(message, _value);
76
78
  filterFileds.push(_key);
77
79
  if (_valueData || isNumber(_valueData)) {
78
80
  rowData.fields[_key] = _valueData; // 这里不需要转译
79
- fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_valueData));
81
+ fieldsStr.push(escapeRowData(_key) + "=" + escapeRowField(_valueData));
80
82
  }
81
83
  }
82
84
  });
@@ -90,29 +92,29 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
90
92
  if (_value || isNumber(_value)) {
91
93
  _tagKeys.push(_key);
92
94
  rowData.fields[_key] = _value; // 这里不需要转译
93
- fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_value));
95
+ fieldsStr.push(escapeRowData(_key) + "=" + escapeRowField(_value));
94
96
  }
95
97
  });
96
98
  if (_tagKeys.length) {
97
99
  rowData.fields[CUSTOM_KEYS] = escapeRowField(_tagKeys);
98
- fieldsStr.push(escapeRowData(CUSTOM_KEYS) + '=' + escapeRowField(_tagKeys));
100
+ fieldsStr.push(escapeRowData(CUSTOM_KEYS) + "=" + escapeRowField(_tagKeys));
99
101
  }
100
102
  }
101
103
  if (tagsStr.length) {
102
- rowStr += tagsStr.join(',');
104
+ rowStr += tagsStr.join(",");
103
105
  }
104
106
  if (fieldsStr.length) {
105
- rowStr += ' ';
106
- rowStr += fieldsStr.join(',');
107
+ rowStr += " ";
108
+ rowStr += fieldsStr.join(",");
107
109
  hasFileds = true;
108
110
  }
109
- rowStr = rowStr + ' ' + message.date;
111
+ rowStr = rowStr + " " + message.date;
110
112
  rowData.time = toServerDuration(message.date); // 这里不需要转译
111
113
  }
112
114
  });
113
115
 
114
116
  return {
115
- rowStr: hasFileds ? rowStr : '',
117
+ rowStr: hasFileds ? rowStr : "",
116
118
  rowData: hasFileds ? rowData : undefined
117
119
  };
118
120
  };
@@ -140,7 +142,7 @@ batch.prototype = {
140
142
  flush: function flush() {
141
143
  if (this.bufferMessageCount !== 0) {
142
144
  var messages = this.pushOnlyBuffer.concat(values(this.upsertBuffer));
143
- this.request.send(messages.join('\n'), this.bufferBytesSize);
145
+ this.request.send(messages.join("\n"), this.bufferBytesSize);
144
146
  this.pushOnlyBuffer = [];
145
147
  this.upsertBuffer = {};
146
148
  this.bufferBytesSize = 0;
@@ -152,9 +154,9 @@ batch.prototype = {
152
154
  },
153
155
  addOrUpdate: function addOrUpdate(message, key) {
154
156
  var process = this.process(message);
155
- if (!process.processedMessage || process.processedMessage === '') return;
157
+ if (!process.processedMessage || process.processedMessage === "") return;
156
158
  if (process.messageBytesSize >= this.maxMessageSize) {
157
- console.warn('Discarded a message whose size was bigger than the maximum allowed size' + this.maxMessageSize + 'KB.');
159
+ console.warn("Discarded a message whose size was bigger than the maximum allowed size" + this.maxMessageSize + "KB.");
158
160
  return;
159
161
  }
160
162
  if (this.hasMessageFor(key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/rum-uniapp",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",