@cloudcare/rum-uniapp 2.2.4 → 2.2.5

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.5',
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,9 +24,10 @@ 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
  },
31
32
  url: url,
32
33
  data: data
@@ -36,7 +37,7 @@ httpRequest.prototype = {
36
37
  var HttpRequest = exports.HttpRequest = httpRequest;
37
38
  var processedMessageByDataMap = exports.processedMessageByDataMap = function processedMessageByDataMap(message) {
38
39
  if (!message || !message.type) return {
39
- rowStr: '',
40
+ rowStr: "",
40
41
  rowData: undefined
41
42
  };
42
43
  var rowData = {
@@ -44,24 +45,24 @@ var processedMessageByDataMap = exports.processedMessageByDataMap = function pro
44
45
  fields: {}
45
46
  };
46
47
  var hasFileds = false;
47
- var rowStr = '';
48
+ var rowStr = "";
48
49
  (0, _utils.each)(_dataMap.dataMap, function (value, key) {
49
50
  if (value.type === message.type) {
50
51
  if (value.alias_key) {
51
- rowStr += value.alias_key + ',';
52
+ rowStr += value.alias_key + ",";
52
53
  } else {
53
- rowStr += key + ',';
54
+ rowStr += key + ",";
54
55
  }
55
56
  rowData.measurement = key;
56
57
  var tagsStr = [];
57
58
  var tags = (0, _utils.extend)({}, _dataMap.commonTags, value.tags);
58
- var filterFileds = ['date', 'type', CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
59
+ var filterFileds = ["date", "type", CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
59
60
  (0, _utils.each)(tags, function (value_path, _key) {
60
61
  var _value = (0, _utils.findByPath)(message, value_path);
61
62
  filterFileds.push(_key);
62
63
  if (_value || (0, _utils.isNumber)(_value)) {
63
64
  rowData.tags[_key] = (0, _utils.escapeJsonValue)(_value);
64
- tagsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowData)(_value));
65
+ tagsStr.push((0, _utils.escapeRowData)(_key) + "=" + (0, _utils.escapeRowData)(_value));
65
66
  }
66
67
  });
67
68
  var fields = (0, _utils.extend)({}, _dataMap.commonFields, value.fields);
@@ -74,14 +75,14 @@ var processedMessageByDataMap = exports.processedMessageByDataMap = function pro
74
75
  filterFileds.push(_key);
75
76
  if (_valueData || (0, _utils.isNumber)(_valueData)) {
76
77
  rowData.fields[_key] = _valueData; // 这里不需要转译
77
- fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_valueData));
78
+ fieldsStr.push((0, _utils.escapeRowData)(_key) + "=" + (0, _utils.escapeRowField)(_valueData));
78
79
  }
79
80
  } else if ((0, _utils.isString)(_value)) {
80
81
  var _valueData = (0, _utils.findByPath)(message, _value);
81
82
  filterFileds.push(_key);
82
83
  if (_valueData || (0, _utils.isNumber)(_valueData)) {
83
84
  rowData.fields[_key] = _valueData; // 这里不需要转译
84
- fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_valueData));
85
+ fieldsStr.push((0, _utils.escapeRowData)(_key) + "=" + (0, _utils.escapeRowField)(_valueData));
85
86
  }
86
87
  }
87
88
  });
@@ -95,29 +96,29 @@ var processedMessageByDataMap = exports.processedMessageByDataMap = function pro
95
96
  if (_value || (0, _utils.isNumber)(_value)) {
96
97
  _tagKeys.push(_key);
97
98
  rowData.fields[_key] = _value; // 这里不需要转译
98
- fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_value));
99
+ fieldsStr.push((0, _utils.escapeRowData)(_key) + "=" + (0, _utils.escapeRowField)(_value));
99
100
  }
100
101
  });
101
102
  if (_tagKeys.length) {
102
103
  rowData.fields[CUSTOM_KEYS] = (0, _utils.escapeRowField)(_tagKeys);
103
- fieldsStr.push((0, _utils.escapeRowData)(CUSTOM_KEYS) + '=' + (0, _utils.escapeRowField)(_tagKeys));
104
+ fieldsStr.push((0, _utils.escapeRowData)(CUSTOM_KEYS) + "=" + (0, _utils.escapeRowField)(_tagKeys));
104
105
  }
105
106
  }
106
107
  if (tagsStr.length) {
107
- rowStr += tagsStr.join(',');
108
+ rowStr += tagsStr.join(",");
108
109
  }
109
110
  if (fieldsStr.length) {
110
- rowStr += ' ';
111
- rowStr += fieldsStr.join(',');
111
+ rowStr += " ";
112
+ rowStr += fieldsStr.join(",");
112
113
  hasFileds = true;
113
114
  }
114
- rowStr = rowStr + ' ' + message.date;
115
+ rowStr = rowStr + " " + message.date;
115
116
  rowData.time = (0, _utils.toServerDuration)(message.date); // 这里不需要转译
116
117
  }
117
118
  });
118
119
 
119
120
  return {
120
- rowStr: hasFileds ? rowStr : '',
121
+ rowStr: hasFileds ? rowStr : "",
121
122
  rowData: hasFileds ? rowData : undefined
122
123
  };
123
124
  };
@@ -145,7 +146,7 @@ batch.prototype = {
145
146
  flush: function flush() {
146
147
  if (this.bufferMessageCount !== 0) {
147
148
  var messages = this.pushOnlyBuffer.concat((0, _utils.values)(this.upsertBuffer));
148
- this.request.send(messages.join('\n'), this.bufferBytesSize);
149
+ this.request.send(messages.join("\n"), this.bufferBytesSize);
149
150
  this.pushOnlyBuffer = [];
150
151
  this.upsertBuffer = {};
151
152
  this.bufferBytesSize = 0;
@@ -157,9 +158,9 @@ batch.prototype = {
157
158
  },
158
159
  addOrUpdate: function addOrUpdate(message, key) {
159
160
  var process = this.process(message);
160
- if (!process.processedMessage || process.processedMessage === '') return;
161
+ if (!process.processedMessage || process.processedMessage === "") return;
161
162
  if (process.messageBytesSize >= this.maxMessageSize) {
162
- console.warn('Discarded a message whose size was bigger than the maximum allowed size' + this.maxMessageSize + 'KB.');
163
+ console.warn("Discarded a message whose size was bigger than the maximum allowed size" + this.maxMessageSize + "KB.");
163
164
  return;
164
165
  }
165
166
  if (this.hasMessageFor(key)) {
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.2.4',
2
+ sdkVersion: '2.2.5',
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,9 +19,10 @@ 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
  },
26
27
  url,
27
28
  data
@@ -31,7 +32,7 @@ httpRequest.prototype = {
31
32
  export var HttpRequest = httpRequest;
32
33
  export var processedMessageByDataMap = function processedMessageByDataMap(message) {
33
34
  if (!message || !message.type) return {
34
- rowStr: '',
35
+ rowStr: "",
35
36
  rowData: undefined
36
37
  };
37
38
  var rowData = {
@@ -39,24 +40,24 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
39
40
  fields: {}
40
41
  };
41
42
  var hasFileds = false;
42
- var rowStr = '';
43
+ var rowStr = "";
43
44
  each(dataMap, function (value, key) {
44
45
  if (value.type === message.type) {
45
46
  if (value.alias_key) {
46
- rowStr += value.alias_key + ',';
47
+ rowStr += value.alias_key + ",";
47
48
  } else {
48
- rowStr += key + ',';
49
+ rowStr += key + ",";
49
50
  }
50
51
  rowData.measurement = key;
51
52
  var tagsStr = [];
52
53
  var tags = extend({}, commonTags, value.tags);
53
- var filterFileds = ['date', 'type', CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
54
+ var filterFileds = ["date", "type", CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
54
55
  each(tags, function (value_path, _key) {
55
56
  var _value = findByPath(message, value_path);
56
57
  filterFileds.push(_key);
57
58
  if (_value || isNumber(_value)) {
58
59
  rowData.tags[_key] = escapeJsonValue(_value);
59
- tagsStr.push(escapeRowData(_key) + '=' + escapeRowData(_value));
60
+ tagsStr.push(escapeRowData(_key) + "=" + escapeRowData(_value));
60
61
  }
61
62
  });
62
63
  var fields = extend({}, commonFields, value.fields);
@@ -69,14 +70,14 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
69
70
  filterFileds.push(_key);
70
71
  if (_valueData || isNumber(_valueData)) {
71
72
  rowData.fields[_key] = _valueData; // 这里不需要转译
72
- fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_valueData));
73
+ fieldsStr.push(escapeRowData(_key) + "=" + escapeRowField(_valueData));
73
74
  }
74
75
  } else if (isString(_value)) {
75
76
  var _valueData = findByPath(message, _value);
76
77
  filterFileds.push(_key);
77
78
  if (_valueData || isNumber(_valueData)) {
78
79
  rowData.fields[_key] = _valueData; // 这里不需要转译
79
- fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_valueData));
80
+ fieldsStr.push(escapeRowData(_key) + "=" + escapeRowField(_valueData));
80
81
  }
81
82
  }
82
83
  });
@@ -90,29 +91,29 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
90
91
  if (_value || isNumber(_value)) {
91
92
  _tagKeys.push(_key);
92
93
  rowData.fields[_key] = _value; // 这里不需要转译
93
- fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_value));
94
+ fieldsStr.push(escapeRowData(_key) + "=" + escapeRowField(_value));
94
95
  }
95
96
  });
96
97
  if (_tagKeys.length) {
97
98
  rowData.fields[CUSTOM_KEYS] = escapeRowField(_tagKeys);
98
- fieldsStr.push(escapeRowData(CUSTOM_KEYS) + '=' + escapeRowField(_tagKeys));
99
+ fieldsStr.push(escapeRowData(CUSTOM_KEYS) + "=" + escapeRowField(_tagKeys));
99
100
  }
100
101
  }
101
102
  if (tagsStr.length) {
102
- rowStr += tagsStr.join(',');
103
+ rowStr += tagsStr.join(",");
103
104
  }
104
105
  if (fieldsStr.length) {
105
- rowStr += ' ';
106
- rowStr += fieldsStr.join(',');
106
+ rowStr += " ";
107
+ rowStr += fieldsStr.join(",");
107
108
  hasFileds = true;
108
109
  }
109
- rowStr = rowStr + ' ' + message.date;
110
+ rowStr = rowStr + " " + message.date;
110
111
  rowData.time = toServerDuration(message.date); // 这里不需要转译
111
112
  }
112
113
  });
113
114
 
114
115
  return {
115
- rowStr: hasFileds ? rowStr : '',
116
+ rowStr: hasFileds ? rowStr : "",
116
117
  rowData: hasFileds ? rowData : undefined
117
118
  };
118
119
  };
@@ -140,7 +141,7 @@ batch.prototype = {
140
141
  flush: function flush() {
141
142
  if (this.bufferMessageCount !== 0) {
142
143
  var messages = this.pushOnlyBuffer.concat(values(this.upsertBuffer));
143
- this.request.send(messages.join('\n'), this.bufferBytesSize);
144
+ this.request.send(messages.join("\n"), this.bufferBytesSize);
144
145
  this.pushOnlyBuffer = [];
145
146
  this.upsertBuffer = {};
146
147
  this.bufferBytesSize = 0;
@@ -152,9 +153,9 @@ batch.prototype = {
152
153
  },
153
154
  addOrUpdate: function addOrUpdate(message, key) {
154
155
  var process = this.process(message);
155
- if (!process.processedMessage || process.processedMessage === '') return;
156
+ if (!process.processedMessage || process.processedMessage === "") return;
156
157
  if (process.messageBytesSize >= this.maxMessageSize) {
157
- console.warn('Discarded a message whose size was bigger than the maximum allowed size' + this.maxMessageSize + 'KB.');
158
+ console.warn("Discarded a message whose size was bigger than the maximum allowed size" + this.maxMessageSize + "KB.");
158
159
  return;
159
160
  }
160
161
  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.5",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",