@cloudcare/rum-uniapp 2.2.3 → 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.
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/core/baseInfo.js +68 -16
- package/cjs/core/dataMap.js +14 -5
- package/cjs/core/transport.js +23 -22
- package/cjs/core/xhrProxy.js +17 -13
- package/cjs/rumEventsCollection/action/trackActions.js +6 -2
- package/esm/boot/buildEnv.js +1 -1
- package/esm/core/baseInfo.js +68 -16
- package/esm/core/dataMap.js +14 -5
- package/esm/core/transport.js +28 -27
- package/esm/core/xhrProxy.js +17 -13
- package/esm/rumEventsCollection/action/trackActions.js +6 -2
- package/package.json +1 -1
package/cjs/boot/buildEnv.js
CHANGED
package/cjs/core/baseInfo.js
CHANGED
|
@@ -8,6 +8,7 @@ var _sdk = require("../core/sdk");
|
|
|
8
8
|
var _utils = require("../helper/utils");
|
|
9
9
|
var _enums = require("../helper/enums");
|
|
10
10
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
12
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
13
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
13
14
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -23,28 +24,79 @@ var BaseInfo = /*#__PURE__*/function () {
|
|
|
23
24
|
key: "getDeviceInfo",
|
|
24
25
|
value: function getDeviceInfo() {
|
|
25
26
|
try {
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
// 设备信息
|
|
28
|
+
var deviceInfo = {};
|
|
29
|
+
if (_sdk.sdk.getDeviceInfo) {
|
|
30
|
+
deviceInfo = _sdk.sdk.getDeviceInfo();
|
|
31
|
+
} else {
|
|
32
|
+
var systemInfo = _sdk.sdk.getSystemInfoSync();
|
|
33
|
+
deviceInfo = _defineProperty({
|
|
34
|
+
deviceBrand: systemInfo.deviceBrand,
|
|
35
|
+
deviceId: systemInfo.deviceId,
|
|
36
|
+
deviceModel: systemInfo.deviceModel,
|
|
37
|
+
deviceType: systemInfo.deviceType,
|
|
38
|
+
deviceOrientation: systemInfo.deviceOrientation,
|
|
39
|
+
devicePixelRatio: systemInfo.devicePixelRatio,
|
|
40
|
+
system: systemInfo.system
|
|
41
|
+
}, "devicePixelRatio", systemInfo.devicePixelRatio);
|
|
42
|
+
}
|
|
43
|
+
var appBaseInfo = {};
|
|
44
|
+
if (_sdk.sdk.getAppBaseInfo) {
|
|
45
|
+
appBaseInfo = _sdk.sdk.getAppBaseInfo();
|
|
31
46
|
} else {
|
|
32
|
-
|
|
47
|
+
var _systemInfo = _sdk.sdk.getSystemInfoSync();
|
|
48
|
+
appBaseInfo = {
|
|
49
|
+
appId: _systemInfo.appId,
|
|
50
|
+
appName: _systemInfo.appName,
|
|
51
|
+
appVersion: _systemInfo.appVersion,
|
|
52
|
+
appVersionCode: _systemInfo.appVersionCode,
|
|
53
|
+
appLanguage: _systemInfo.appLanguage,
|
|
54
|
+
appWgtVersion: _systemInfo.appWgtVersion,
|
|
55
|
+
hostName: _systemInfo.hostName,
|
|
56
|
+
hostVersion: _systemInfo.hostVersion,
|
|
57
|
+
hostLanguage: _systemInfo.hostLanguage
|
|
58
|
+
};
|
|
33
59
|
}
|
|
60
|
+
var windowInfo = {};
|
|
61
|
+
if (_sdk.sdk.getWindowInfo) {
|
|
62
|
+
windowInfo = _sdk.sdk.getWindowInfo();
|
|
63
|
+
} else {
|
|
64
|
+
var _systemInfo2 = _sdk.sdk.getSystemInfoSync();
|
|
65
|
+
windowInfo = {
|
|
66
|
+
screenWidth: _systemInfo2.screenWidth,
|
|
67
|
+
screenHeight: _systemInfo2.screenHeight,
|
|
68
|
+
statusBarHeight: _systemInfo2.statusBarHeight,
|
|
69
|
+
windowWidth: _systemInfo2.windowWidth,
|
|
70
|
+
windowHeight: _systemInfo2.windowHeight,
|
|
71
|
+
windowTop: _systemInfo2.windowTop,
|
|
72
|
+
windowBottom: _systemInfo2.windowBottom,
|
|
73
|
+
screenTop: _systemInfo2.screenTop
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
var osInfo = deviceInfo.system.split(' ');
|
|
77
|
+
var osVersion = osInfo.length > 1 && osInfo[1];
|
|
34
78
|
var osVersionMajor = osVersion && osVersion.split('.').length && osVersion.split('.')[0];
|
|
35
79
|
this.deviceInfo = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
80
|
+
deviceUuid: deviceInfo.deviceId,
|
|
81
|
+
deviceId: deviceInfo.deviceId,
|
|
82
|
+
brand: deviceInfo.deviceBrand,
|
|
83
|
+
model: deviceInfo.deviceModel,
|
|
84
|
+
type: deviceInfo.deviceType,
|
|
85
|
+
pixelRatio: deviceInfo.devicePixelRatio,
|
|
86
|
+
orientation: deviceInfo.deviceOrientation,
|
|
87
|
+
os: osInfo.length > 0 && osInfo[0],
|
|
39
88
|
osVersion: osVersion,
|
|
40
89
|
osVersionMajor: osVersionMajor,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
90
|
+
appVersion: appBaseInfo.appVersion,
|
|
91
|
+
appId: appBaseInfo.appId,
|
|
92
|
+
appName: appBaseInfo.appName,
|
|
93
|
+
appVersionCode: appBaseInfo.appVersionCode,
|
|
94
|
+
appLanguage: appBaseInfo.appLanguage,
|
|
95
|
+
appWgtVersion: appBaseInfo.appWgtVersion,
|
|
96
|
+
platform: appBaseInfo.hostName,
|
|
97
|
+
platformVersion: appBaseInfo.hostVersion,
|
|
98
|
+
platformLanguage: appBaseInfo.hostLanguage,
|
|
99
|
+
screenSize: "".concat(windowInfo.screenWidth, "*").concat(windowInfo.screenHeight, " ")
|
|
48
100
|
};
|
|
49
101
|
} catch (e) {
|
|
50
102
|
this.deviceInfo = {};
|
package/cjs/core/dataMap.js
CHANGED
|
@@ -19,18 +19,27 @@ var commonTags = exports.commonTags = {
|
|
|
19
19
|
session_id: 'session.id',
|
|
20
20
|
session_type: 'session.type',
|
|
21
21
|
is_signin: 'user.is_signin',
|
|
22
|
+
platform: 'device.platform',
|
|
23
|
+
platform_version: 'device.platform_version',
|
|
24
|
+
platform_language: 'device.platform_language',
|
|
25
|
+
device_uuid: 'device.device_uuid',
|
|
26
|
+
device_id: 'device.device_id',
|
|
22
27
|
device: 'device.brand',
|
|
28
|
+
brand: 'device.brand',
|
|
23
29
|
model: 'device.model',
|
|
24
|
-
|
|
30
|
+
device_type: 'device.type',
|
|
31
|
+
pixel_ratio: 'device.pixel_ratio',
|
|
32
|
+
orientation: 'device.orientation',
|
|
25
33
|
os: 'device.os',
|
|
26
|
-
app: 'device.app',
|
|
27
34
|
os_version: 'device.os_version',
|
|
28
35
|
os_version_major: 'device.os_version_major',
|
|
36
|
+
device_app_version: 'device.app_version',
|
|
37
|
+
device_app_id: 'device.app_id',
|
|
38
|
+
device_app_version_code: 'device.app_version_code',
|
|
39
|
+
device_app_language: 'device.app_language',
|
|
40
|
+
device_app_wgt_version: 'device.app_wgt_version',
|
|
29
41
|
screen_size: 'device.screen_size',
|
|
30
42
|
network_type: 'device.network_type',
|
|
31
|
-
platform: 'device.platform',
|
|
32
|
-
platform_version: 'device.platform_version',
|
|
33
|
-
app_framework_version: 'device.framework_version',
|
|
34
43
|
view_id: 'page.id',
|
|
35
44
|
view_name: 'page.route',
|
|
36
45
|
view_referer: 'page.referer'
|
package/cjs/core/transport.js
CHANGED
|
@@ -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 =
|
|
14
|
+
var CUSTOM_KEYS = "custom_keys";
|
|
15
15
|
function addBatchPrecision(url) {
|
|
16
16
|
if (!url) return url;
|
|
17
|
-
return url + (url.indexOf(
|
|
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:
|
|
27
|
+
method: "POST",
|
|
28
28
|
header: {
|
|
29
|
-
|
|
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 = [
|
|
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) +
|
|
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) +
|
|
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) +
|
|
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) +
|
|
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) +
|
|
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 +
|
|
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(
|
|
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 ===
|
|
161
|
+
if (!process.processedMessage || process.processedMessage === "") return;
|
|
161
162
|
if (process.messageBytesSize >= this.maxMessageSize) {
|
|
162
|
-
console.warn(
|
|
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)) {
|
package/cjs/core/xhrProxy.js
CHANGED
|
@@ -49,19 +49,23 @@ function proxyXhr(userConfiguration) {
|
|
|
49
49
|
};
|
|
50
50
|
dataflux_xhr.startTime = (0, _utils.now)();
|
|
51
51
|
var originalSuccess = arguments[0].success;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
if (originalSuccess) {
|
|
53
|
+
arguments[0].success = function () {
|
|
54
|
+
reportXhr(arguments[0]);
|
|
55
|
+
if (typeof originalSuccess === 'function') {
|
|
56
|
+
originalSuccess.apply(_this, arguments);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
58
60
|
var originalFail = arguments[0].fail;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
if (originalFail) {
|
|
62
|
+
arguments[0].fail = function () {
|
|
63
|
+
reportXhr(arguments[0]);
|
|
64
|
+
if (typeof originalFail === 'function') {
|
|
65
|
+
originalFail.apply(_this, arguments);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
65
69
|
var hasBeenReported = false;
|
|
66
70
|
var reportXhr = function reportXhr(res) {
|
|
67
71
|
if (hasBeenReported) {
|
|
@@ -69,7 +73,7 @@ function proxyXhr(userConfiguration) {
|
|
|
69
73
|
}
|
|
70
74
|
hasBeenReported = true;
|
|
71
75
|
dataflux_xhr.duration = (0, _utils.now)() - dataflux_xhr.startTime;
|
|
72
|
-
dataflux_xhr.response = JSON.stringify(res.data);
|
|
76
|
+
dataflux_xhr.response = res.data && JSON.stringify(res.data) || {};
|
|
73
77
|
dataflux_xhr.header = res.header || {};
|
|
74
78
|
dataflux_xhr.profile = res.profile;
|
|
75
79
|
dataflux_xhr.status = res.statusCode || res.status || 0;
|
|
@@ -28,7 +28,9 @@ function trackActions(lifeCycle, Vue) {
|
|
|
28
28
|
Page = function Page(page) {
|
|
29
29
|
try {
|
|
30
30
|
hookClick(page);
|
|
31
|
-
} catch (error) {
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('error===', error);
|
|
33
|
+
}
|
|
32
34
|
return originPage(page);
|
|
33
35
|
};
|
|
34
36
|
var originComponent = Component;
|
|
@@ -38,7 +40,9 @@ function trackActions(lifeCycle, Vue) {
|
|
|
38
40
|
component.methods.onLoad = function () {
|
|
39
41
|
try {
|
|
40
42
|
hookClick(this);
|
|
41
|
-
} catch (error) {
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('error===', error);
|
|
45
|
+
}
|
|
42
46
|
return originOnLoad.apply(this, arguments);
|
|
43
47
|
};
|
|
44
48
|
}
|
package/esm/boot/buildEnv.js
CHANGED
package/esm/core/baseInfo.js
CHANGED
|
@@ -8,28 +8,80 @@ class BaseInfo {
|
|
|
8
8
|
}
|
|
9
9
|
getDeviceInfo() {
|
|
10
10
|
try {
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
// 设备信息
|
|
12
|
+
var deviceInfo = {};
|
|
13
|
+
if (sdk.getDeviceInfo) {
|
|
14
|
+
deviceInfo = sdk.getDeviceInfo();
|
|
15
|
+
} else {
|
|
16
|
+
var systemInfo = sdk.getSystemInfoSync();
|
|
17
|
+
deviceInfo = {
|
|
18
|
+
deviceBrand: systemInfo.deviceBrand,
|
|
19
|
+
deviceId: systemInfo.deviceId,
|
|
20
|
+
deviceModel: systemInfo.deviceModel,
|
|
21
|
+
deviceType: systemInfo.deviceType,
|
|
22
|
+
deviceOrientation: systemInfo.deviceOrientation,
|
|
23
|
+
devicePixelRatio: systemInfo.devicePixelRatio,
|
|
24
|
+
system: systemInfo.system,
|
|
25
|
+
devicePixelRatio: systemInfo.devicePixelRatio
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var appBaseInfo = {};
|
|
29
|
+
if (sdk.getAppBaseInfo) {
|
|
30
|
+
appBaseInfo = sdk.getAppBaseInfo();
|
|
16
31
|
} else {
|
|
17
|
-
|
|
32
|
+
var _systemInfo = sdk.getSystemInfoSync();
|
|
33
|
+
appBaseInfo = {
|
|
34
|
+
appId: _systemInfo.appId,
|
|
35
|
+
appName: _systemInfo.appName,
|
|
36
|
+
appVersion: _systemInfo.appVersion,
|
|
37
|
+
appVersionCode: _systemInfo.appVersionCode,
|
|
38
|
+
appLanguage: _systemInfo.appLanguage,
|
|
39
|
+
appWgtVersion: _systemInfo.appWgtVersion,
|
|
40
|
+
hostName: _systemInfo.hostName,
|
|
41
|
+
hostVersion: _systemInfo.hostVersion,
|
|
42
|
+
hostLanguage: _systemInfo.hostLanguage
|
|
43
|
+
};
|
|
18
44
|
}
|
|
45
|
+
var windowInfo = {};
|
|
46
|
+
if (sdk.getWindowInfo) {
|
|
47
|
+
windowInfo = sdk.getWindowInfo();
|
|
48
|
+
} else {
|
|
49
|
+
var _systemInfo2 = sdk.getSystemInfoSync();
|
|
50
|
+
windowInfo = {
|
|
51
|
+
screenWidth: _systemInfo2.screenWidth,
|
|
52
|
+
screenHeight: _systemInfo2.screenHeight,
|
|
53
|
+
statusBarHeight: _systemInfo2.statusBarHeight,
|
|
54
|
+
windowWidth: _systemInfo2.windowWidth,
|
|
55
|
+
windowHeight: _systemInfo2.windowHeight,
|
|
56
|
+
windowTop: _systemInfo2.windowTop,
|
|
57
|
+
windowBottom: _systemInfo2.windowBottom,
|
|
58
|
+
screenTop: _systemInfo2.screenTop
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var osInfo = deviceInfo.system.split(' ');
|
|
62
|
+
var osVersion = osInfo.length > 1 && osInfo[1];
|
|
19
63
|
var osVersionMajor = osVersion && osVersion.split('.').length && osVersion.split('.')[0];
|
|
20
64
|
this.deviceInfo = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
65
|
+
deviceUuid: deviceInfo.deviceId,
|
|
66
|
+
deviceId: deviceInfo.deviceId,
|
|
67
|
+
brand: deviceInfo.deviceBrand,
|
|
68
|
+
model: deviceInfo.deviceModel,
|
|
69
|
+
type: deviceInfo.deviceType,
|
|
70
|
+
pixelRatio: deviceInfo.devicePixelRatio,
|
|
71
|
+
orientation: deviceInfo.deviceOrientation,
|
|
72
|
+
os: osInfo.length > 0 && osInfo[0],
|
|
24
73
|
osVersion: osVersion,
|
|
25
74
|
osVersionMajor: osVersionMajor,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
75
|
+
appVersion: appBaseInfo.appVersion,
|
|
76
|
+
appId: appBaseInfo.appId,
|
|
77
|
+
appName: appBaseInfo.appName,
|
|
78
|
+
appVersionCode: appBaseInfo.appVersionCode,
|
|
79
|
+
appLanguage: appBaseInfo.appLanguage,
|
|
80
|
+
appWgtVersion: appBaseInfo.appWgtVersion,
|
|
81
|
+
platform: appBaseInfo.hostName,
|
|
82
|
+
platformVersion: appBaseInfo.hostVersion,
|
|
83
|
+
platformLanguage: appBaseInfo.hostLanguage,
|
|
84
|
+
screenSize: "".concat(windowInfo.screenWidth, "*").concat(windowInfo.screenHeight, " ")
|
|
33
85
|
};
|
|
34
86
|
} catch (e) {
|
|
35
87
|
this.deviceInfo = {};
|
package/esm/core/dataMap.js
CHANGED
|
@@ -13,18 +13,27 @@ export var commonTags = {
|
|
|
13
13
|
session_id: 'session.id',
|
|
14
14
|
session_type: 'session.type',
|
|
15
15
|
is_signin: 'user.is_signin',
|
|
16
|
+
platform: 'device.platform',
|
|
17
|
+
platform_version: 'device.platform_version',
|
|
18
|
+
platform_language: 'device.platform_language',
|
|
19
|
+
device_uuid: 'device.device_uuid',
|
|
20
|
+
device_id: 'device.device_id',
|
|
16
21
|
device: 'device.brand',
|
|
22
|
+
brand: 'device.brand',
|
|
17
23
|
model: 'device.model',
|
|
18
|
-
|
|
24
|
+
device_type: 'device.type',
|
|
25
|
+
pixel_ratio: 'device.pixel_ratio',
|
|
26
|
+
orientation: 'device.orientation',
|
|
19
27
|
os: 'device.os',
|
|
20
|
-
app: 'device.app',
|
|
21
28
|
os_version: 'device.os_version',
|
|
22
29
|
os_version_major: 'device.os_version_major',
|
|
30
|
+
device_app_version: 'device.app_version',
|
|
31
|
+
device_app_id: 'device.app_id',
|
|
32
|
+
device_app_version_code: 'device.app_version_code',
|
|
33
|
+
device_app_language: 'device.app_language',
|
|
34
|
+
device_app_wgt_version: 'device.app_wgt_version',
|
|
23
35
|
screen_size: 'device.screen_size',
|
|
24
36
|
network_type: 'device.network_type',
|
|
25
|
-
platform: 'device.platform',
|
|
26
|
-
platform_version: 'device.platform_version',
|
|
27
|
-
app_framework_version: 'device.framework_version',
|
|
28
37
|
view_id: 'page.id',
|
|
29
38
|
view_name: 'page.route',
|
|
30
39
|
view_referer: 'page.referer'
|
package/esm/core/transport.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { findByPath, escapeRowData, isNumber, each, isString, values, extend, isObject, isEmptyObject, isArray, escapeRowField, escapeJsonValue, toServerDuration } from
|
|
2
|
-
import { sdk } from
|
|
3
|
-
import { computeBytesCount } from
|
|
4
|
-
import { LifeCycleEventType } from
|
|
5
|
-
import { commonTags, dataMap, commonFields } from
|
|
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 =
|
|
9
|
+
var CUSTOM_KEYS = "custom_keys";
|
|
10
10
|
function addBatchPrecision(url) {
|
|
11
11
|
if (!url) return url;
|
|
12
|
-
return url + (url.indexOf(
|
|
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:
|
|
22
|
+
method: "POST",
|
|
23
23
|
header: {
|
|
24
|
-
|
|
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 = [
|
|
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) +
|
|
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) +
|
|
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) +
|
|
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) +
|
|
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) +
|
|
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 +
|
|
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(
|
|
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 ===
|
|
156
|
+
if (!process.processedMessage || process.processedMessage === "") return;
|
|
156
157
|
if (process.messageBytesSize >= this.maxMessageSize) {
|
|
157
|
-
console.warn(
|
|
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/esm/core/xhrProxy.js
CHANGED
|
@@ -41,19 +41,23 @@ function proxyXhr(userConfiguration) {
|
|
|
41
41
|
};
|
|
42
42
|
dataflux_xhr.startTime = now();
|
|
43
43
|
var originalSuccess = arguments[0].success;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
if (originalSuccess) {
|
|
45
|
+
arguments[0].success = function () {
|
|
46
|
+
reportXhr(arguments[0]);
|
|
47
|
+
if (typeof originalSuccess === 'function') {
|
|
48
|
+
originalSuccess.apply(_this, arguments);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
50
52
|
var originalFail = arguments[0].fail;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
if (originalFail) {
|
|
54
|
+
arguments[0].fail = function () {
|
|
55
|
+
reportXhr(arguments[0]);
|
|
56
|
+
if (typeof originalFail === 'function') {
|
|
57
|
+
originalFail.apply(_this, arguments);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
57
61
|
var hasBeenReported = false;
|
|
58
62
|
var reportXhr = function reportXhr(res) {
|
|
59
63
|
if (hasBeenReported) {
|
|
@@ -61,7 +65,7 @@ function proxyXhr(userConfiguration) {
|
|
|
61
65
|
}
|
|
62
66
|
hasBeenReported = true;
|
|
63
67
|
dataflux_xhr.duration = now() - dataflux_xhr.startTime;
|
|
64
|
-
dataflux_xhr.response = JSON.stringify(res.data);
|
|
68
|
+
dataflux_xhr.response = res.data && JSON.stringify(res.data) || {};
|
|
65
69
|
dataflux_xhr.header = res.header || {};
|
|
66
70
|
dataflux_xhr.profile = res.profile;
|
|
67
71
|
dataflux_xhr.status = res.statusCode || res.status || 0;
|
|
@@ -22,7 +22,9 @@ export function trackActions(lifeCycle, Vue) {
|
|
|
22
22
|
Page = function Page(page) {
|
|
23
23
|
try {
|
|
24
24
|
hookClick(page);
|
|
25
|
-
} catch (error) {
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('error===', error);
|
|
27
|
+
}
|
|
26
28
|
return originPage(page);
|
|
27
29
|
};
|
|
28
30
|
var originComponent = Component;
|
|
@@ -32,7 +34,9 @@ export function trackActions(lifeCycle, Vue) {
|
|
|
32
34
|
component.methods.onLoad = function () {
|
|
33
35
|
try {
|
|
34
36
|
hookClick(this);
|
|
35
|
-
} catch (error) {
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error('error===', error);
|
|
39
|
+
}
|
|
36
40
|
return originOnLoad.apply(this, arguments);
|
|
37
41
|
};
|
|
38
42
|
}
|