@cloudcare/rum-uniapp 2.1.5 → 2.1.8

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
@@ -42,6 +42,7 @@ datafluxRum.init({
42
42
  | `applicationId` | String | 是 | | 从 dataflux 创建的应用 ID |
43
43
  | `datakitOrigin` | String | 是 | | datakit 数据上报 Origin;`注意:需要在小程序管理后台加上request白名单` |
44
44
  | `env` | String | 否 | | 小程序 应用当前环境, 如 prod:线上环境;gray:灰度环境;pre:预发布环境 common:日常环境;local:本地环境; |
45
+ | `service` | String | 否 | | 小程序应用 服务名称,可 用于 apm 关联 tag |
45
46
  | `version` | String | 否 | | 小程序 应用的版本号 |
46
47
  | `sampleRate` | Number | 否 | `100` | 指标数据收集百分比: `100`表示全收集,`0`表示不收集 |
47
48
  | `traceType` $\color{#FF0000}{新增}$ | Enum | 否 | `ddtrace` | 与 APM 采集工具连接的请求header类型,目前兼容的类型包括:`ddtrace`、`zipkin`、`skywalking_v3`、`jaeger`、`zipkin_single_header`、`w3c_traceparent`。*注: opentelemetry 支持 `zipkin_single_header`,`w3c_traceparent`,`zipkin`三种类型* |
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildEnv = void 0;
7
7
  var buildEnv = {
8
- sdkVersion: '2.1.5',
8
+ sdkVersion: '2.1.8',
9
9
  sdkName: 'df_uniapp_rum_sdk'
10
10
  };
11
11
  exports.buildEnv = buildEnv;
@@ -46,7 +46,9 @@ var makeRum = function makeRum(startRumImpl) {
46
46
  isAlreadyInitialized = true;
47
47
  },
48
48
  initVue3: function initVue3(userConfiguration) {
49
- this.init({}, userConfiguration);
49
+ this.init({}, (0, _utils.extend)({
50
+ isVue2: false
51
+ }, userConfiguration));
50
52
  },
51
53
  getInternalContext: function getInternalContext(startTime) {
52
54
  return _getInternalContext(startTime);
@@ -37,8 +37,9 @@ var DEFAULT_CONFIGURATION = {
37
37
  trackInteractions: false,
38
38
  traceType: _enums.TraceType.DDTRACE,
39
39
  traceId128Bit: false,
40
- allowedTracingOrigins: [] // 新增
41
-
40
+ allowedTracingOrigins: [],
41
+ // 新增
42
+ isVue2: true
42
43
  };
43
44
  exports.DEFAULT_CONFIGURATION = DEFAULT_CONFIGURATION;
44
45
 
@@ -56,6 +57,7 @@ function commonInit(userConfiguration, buildEnv) {
56
57
  applicationId: userConfiguration.applicationId,
57
58
  env: userConfiguration.env || '',
58
59
  version: userConfiguration.version || '',
60
+ service: userConfiguration.service || '',
59
61
  sdkVersion: buildEnv.sdkVersion,
60
62
  sdkName: buildEnv.sdkName,
61
63
  datakitUrl: getDatakitUrlUrl(userConfiguration.datakitUrl || userConfiguration.datakitOrigin),
@@ -82,6 +84,10 @@ function commonInit(userConfiguration, buildEnv) {
82
84
  transportConfiguration.sampleRate = userConfiguration.sampleRate;
83
85
  }
84
86
 
87
+ if ('isVue2' in userConfiguration) {
88
+ transportConfiguration.isVue2 = userConfiguration.isVue2;
89
+ }
90
+
85
91
  return (0, _utils.extend2Lev)(DEFAULT_CONFIGURATION, transportConfiguration);
86
92
  }
87
93
 
@@ -14,6 +14,7 @@ var commonTags = {
14
14
  app_id: 'application.id',
15
15
  env: '_dd.env',
16
16
  version: '_dd.version',
17
+ service: '_dd.service',
17
18
  userid: 'user.id',
18
19
  user_email: 'user.email',
19
20
  user_name: 'user.name',
@@ -12,14 +12,16 @@ var _utils = require("../helper/utils");
12
12
 
13
13
  var _enums = require("../helper/enums");
14
14
 
15
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16
+
15
17
  var downloadProxySingleton;
16
18
  var beforeSendCallbacks = [];
17
19
  var onRequestCompleteCallbacks = [];
18
20
  var originalDownloadRequest;
19
21
 
20
- function startDownloadProxy() {
22
+ function startDownloadProxy(userConfiguration) {
21
23
  if (!downloadProxySingleton) {
22
- proxyDownload();
24
+ proxyDownload(userConfiguration);
23
25
  downloadProxySingleton = {
24
26
  beforeSend: function beforeSend(callback) {
25
27
  beforeSendCallbacks.push(callback);
@@ -42,7 +44,7 @@ function resetDownloadProxy() {
42
44
  }
43
45
  }
44
46
 
45
- function proxyDownload() {
47
+ function proxyDownload(userConfiguration) {
46
48
  originalDownloadRequest = _sdk.sdk.downloadFile;
47
49
 
48
50
  _sdk.sdk.downloadFile = function () {
@@ -58,23 +60,27 @@ function proxyDownload() {
58
60
  dataflux_xhr.startTime = (0, _utils.now)();
59
61
  var originalSuccess = arguments[0].success;
60
62
 
61
- arguments[0].success = function () {
62
- reportXhr(arguments[0]);
63
+ if (typeof originalSuccess === 'function') {
64
+ arguments[0].success = function () {
65
+ reportXhr(arguments[0]);
63
66
 
64
- if (originalSuccess) {
65
- originalSuccess.apply(_this, arguments);
66
- }
67
- };
67
+ if (originalSuccess) {
68
+ originalSuccess.apply(_this, arguments);
69
+ }
70
+ };
71
+ }
68
72
 
69
73
  var originalFail = arguments[0].fail;
70
74
 
71
- arguments[0].fail = function () {
72
- reportXhr(arguments[0]);
75
+ if (typeof originalFail === 'function') {
76
+ arguments[0].fail = function () {
77
+ reportXhr(arguments[0]);
73
78
 
74
- if (originalFail) {
75
- originalFail.apply(_this, arguments);
76
- }
77
- };
79
+ if (originalFail) {
80
+ originalFail.apply(_this, arguments);
81
+ }
82
+ };
83
+ }
78
84
 
79
85
  var hasBeenReported = false;
80
86
 
@@ -100,6 +106,35 @@ function proxyDownload() {
100
106
  beforeSendCallbacks.forEach(function (callback) {
101
107
  callback(dataflux_xhr);
102
108
  });
103
- return originalDownloadRequest.apply(this, arguments);
109
+ var result = originalDownloadRequest.apply(this, arguments); // 判断结果是否为promise
110
+
111
+ var isPromise = function isPromise(obj) {
112
+ return !!obj && (_typeof(obj) === "object" || typeof obj === "function") && typeof obj.then === "function";
113
+ };
114
+
115
+ if (isPromise(result) && userConfiguration.isVue2) {
116
+ // vue2 版本,success, fail 都在then返回
117
+ return result.then(function (res) {
118
+ if (res[0]) {
119
+ reportXhr(res[0]);
120
+ } else {
121
+ reportXhr(res[1]);
122
+ }
123
+
124
+ return res;
125
+ });
126
+ } else if (isPromise(result) && !userConfiguration.isVue2) {
127
+ return new Promise(function (resolve, reject) {
128
+ result.then(function (res) {
129
+ reportXhr(res);
130
+ resolve(res);
131
+ })["catch"](function (err) {
132
+ reportXhr(err);
133
+ reject(err);
134
+ });
135
+ });
136
+ } else {
137
+ return result;
138
+ }
104
139
  };
105
140
  }
@@ -120,10 +120,10 @@ function startAutomaticErrorCollection(configuration) {
120
120
  }
121
121
 
122
122
  function trackNetworkError(configuration, errorObservable) {
123
- (0, _xhrProxy.startXhrProxy)().onRequestComplete(function (context) {
123
+ (0, _xhrProxy.startXhrProxy)(configuration).onRequestComplete(function (context) {
124
124
  return handleCompleteRequest(context.type, context);
125
125
  });
126
- (0, _downloadProxy.startDownloadProxy)().onRequestComplete(function (context) {
126
+ (0, _downloadProxy.startDownloadProxy)(configuration).onRequestComplete(function (context) {
127
127
  return handleCompleteRequest(context.type, context);
128
128
  });
129
129
 
@@ -12,14 +12,16 @@ var _utils = require("../helper/utils");
12
12
 
13
13
  var _enums = require("../helper/enums");
14
14
 
15
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16
+
15
17
  var xhrProxySingleton;
16
18
  var beforeSendCallbacks = [];
17
19
  var onRequestCompleteCallbacks = [];
18
20
  var originalXhrRequest;
19
21
 
20
- function startXhrProxy() {
22
+ function startXhrProxy(userConfiguration) {
21
23
  if (!xhrProxySingleton) {
22
- proxyXhr();
24
+ proxyXhr(userConfiguration);
23
25
  xhrProxySingleton = {
24
26
  beforeSend: function beforeSend(callback) {
25
27
  beforeSendCallbacks.push(callback);
@@ -42,7 +44,7 @@ function resetXhrProxy() {
42
44
  }
43
45
  }
44
46
 
45
- function proxyXhr() {
47
+ function proxyXhr(userConfiguration) {
46
48
  originalXhrRequest = _sdk.sdk.request;
47
49
 
48
50
  _sdk.sdk.request = function () {
@@ -59,23 +61,27 @@ function proxyXhr() {
59
61
  dataflux_xhr.startTime = (0, _utils.now)();
60
62
  var originalSuccess = arguments[0].success;
61
63
 
62
- arguments[0].success = function () {
63
- reportXhr(arguments[0]);
64
+ if (typeof originalSuccess === 'function') {
65
+ arguments[0].success = function () {
66
+ reportXhr(arguments[0]);
64
67
 
65
- if (originalSuccess) {
66
- originalSuccess.apply(_this, arguments);
67
- }
68
- };
68
+ if (originalSuccess) {
69
+ originalSuccess.apply(_this, arguments);
70
+ }
71
+ };
72
+ }
69
73
 
70
74
  var originalFail = arguments[0].fail;
71
75
 
72
- arguments[0].fail = function () {
73
- reportXhr(arguments[0]);
76
+ if (typeof originalFail === 'function') {
77
+ arguments[0].fail = function () {
78
+ reportXhr(arguments[0]);
74
79
 
75
- if (originalFail) {
76
- originalFail.apply(_this, arguments);
77
- }
78
- };
80
+ if (originalFail) {
81
+ originalFail.apply(_this, arguments);
82
+ }
83
+ };
84
+ }
79
85
 
80
86
  var hasBeenReported = false;
81
87
 
@@ -98,6 +104,35 @@ function proxyXhr() {
98
104
  beforeSendCallbacks.forEach(function (callback) {
99
105
  callback(dataflux_xhr);
100
106
  });
101
- return originalXhrRequest.call(this, dataflux_xhr.option);
107
+ var result = originalXhrRequest.call(this, dataflux_xhr.option); // 判断结果是否为promise
108
+
109
+ var isPromise = function isPromise(obj) {
110
+ return !!obj && (_typeof(obj) === "object" || typeof obj === "function") && typeof obj.then === "function";
111
+ };
112
+
113
+ if (isPromise(result) && userConfiguration.isVue2) {
114
+ // vue2 版本,success, fail 都在then返回
115
+ return result.then(function (res) {
116
+ if (res[0]) {
117
+ reportXhr(res[0]);
118
+ } else {
119
+ reportXhr(res[1]);
120
+ }
121
+
122
+ return res;
123
+ });
124
+ } else if (isPromise(result) && !userConfiguration.isVue2) {
125
+ return new Promise(function (resolve, reject) {
126
+ result.then(function (res) {
127
+ reportXhr(res);
128
+ resolve(res);
129
+ })["catch"](function (err) {
130
+ reportXhr(err);
131
+ reject(err);
132
+ });
133
+ });
134
+ } else {
135
+ return result;
136
+ }
102
137
  };
103
138
  }
@@ -43,7 +43,8 @@ function startRumAssembly(applicationId, configuration, session, lifeCycle, pare
43
43
  sdkName: configuration.sdkName,
44
44
  sdkVersion: configuration.sdkVersion,
45
45
  env: configuration.env,
46
- version: configuration.version
46
+ version: configuration.version,
47
+ service: configuration.service
47
48
  },
48
49
  tags: configuration.tags,
49
50
  application: {
@@ -22,7 +22,6 @@ function proxyPage(pageOptions, lifeCycle) {
22
22
  startTime = (0, _utils.now)();
23
23
  ['onReady', 'onShow', 'onLoad', 'onUnload', 'onHide'].forEach(function (methodName) {
24
24
  var userDefinedMethod = pageOptions[methodName];
25
- if (typeof userDefinedMethod !== 'function') return;
26
25
 
27
26
  pageOptions[methodName] = function () {
28
27
  var mpType = this.mpType || this.$vm.mpType;
@@ -47,7 +47,7 @@ function getHeaderString(header) {
47
47
  }
48
48
 
49
49
  function trackXhr(lifeCycle, configuration, tracer) {
50
- var xhrProxy = (0, _xhrProxy.startXhrProxy)();
50
+ var xhrProxy = (0, _xhrProxy.startXhrProxy)(configuration);
51
51
  xhrProxy.beforeSend(function (context) {
52
52
  if ((0, _resourceUtils.isAllowedRequestUrl)(configuration, context.url)) {
53
53
  tracer.traceXhr(context);
@@ -79,7 +79,7 @@ function trackXhr(lifeCycle, configuration, tracer) {
79
79
  }
80
80
 
81
81
  function trackDownload(lifeCycle, configuration) {
82
- var dwonloadProxy = (0, _downloadProxy.startDownloadProxy)();
82
+ var dwonloadProxy = (0, _downloadProxy.startDownloadProxy)(configuration);
83
83
  dwonloadProxy.beforeSend(function (context) {
84
84
  if ((0, _resourceUtils.isAllowedRequestUrl)(configuration, context.url)) {
85
85
  context.requestIndex = getNextRequestIndex();
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.1.5',
2
+ sdkVersion: '2.1.8',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -1,4 +1,4 @@
1
- import { isPercentage, extend2Lev, now, createContextManager, defineGlobal, getGlobalObject, isString, isObject } from '../helper/utils';
1
+ import { isPercentage, extend2Lev, extend, now, createContextManager, defineGlobal, getGlobalObject, isString, isObject } from '../helper/utils';
2
2
  import { startRum } from './rum';
3
3
  import { ActionType } from '../helper/enums';
4
4
  export var makeRum = function makeRum(startRumImpl) {
@@ -34,7 +34,9 @@ export var makeRum = function makeRum(startRumImpl) {
34
34
  isAlreadyInitialized = true;
35
35
  },
36
36
  initVue3: function initVue3(userConfiguration) {
37
- this.init({}, userConfiguration);
37
+ this.init({}, extend({
38
+ isVue2: false
39
+ }, userConfiguration));
38
40
  },
39
41
  getInternalContext: function getInternalContext(startTime) {
40
42
  return _getInternalContext(startTime);
@@ -26,8 +26,9 @@ export var DEFAULT_CONFIGURATION = {
26
26
  trackInteractions: false,
27
27
  traceType: TraceType.DDTRACE,
28
28
  traceId128Bit: false,
29
- allowedTracingOrigins: [] // 新增
30
-
29
+ allowedTracingOrigins: [],
30
+ // 新增
31
+ isVue2: true
31
32
  };
32
33
 
33
34
  function trim(str) {
@@ -44,6 +45,7 @@ export function commonInit(userConfiguration, buildEnv) {
44
45
  applicationId: userConfiguration.applicationId,
45
46
  env: userConfiguration.env || '',
46
47
  version: userConfiguration.version || '',
48
+ service: userConfiguration.service || '',
47
49
  sdkVersion: buildEnv.sdkVersion,
48
50
  sdkName: buildEnv.sdkName,
49
51
  datakitUrl: getDatakitUrlUrl(userConfiguration.datakitUrl || userConfiguration.datakitOrigin),
@@ -70,6 +72,10 @@ export function commonInit(userConfiguration, buildEnv) {
70
72
  transportConfiguration.sampleRate = userConfiguration.sampleRate;
71
73
  }
72
74
 
75
+ if ('isVue2' in userConfiguration) {
76
+ transportConfiguration.isVue2 = userConfiguration.isVue2;
77
+ }
78
+
73
79
  return extend2Lev(DEFAULT_CONFIGURATION, transportConfiguration);
74
80
  }
75
81
 
@@ -6,6 +6,7 @@ export var commonTags = {
6
6
  app_id: 'application.id',
7
7
  env: '_dd.env',
8
8
  version: '_dd.version',
9
+ service: '_dd.service',
9
10
  userid: 'user.id',
10
11
  user_email: 'user.email',
11
12
  user_name: 'user.name',
@@ -5,9 +5,9 @@ var downloadProxySingleton;
5
5
  var beforeSendCallbacks = [];
6
6
  var onRequestCompleteCallbacks = [];
7
7
  var originalDownloadRequest;
8
- export function startDownloadProxy() {
8
+ export function startDownloadProxy(userConfiguration) {
9
9
  if (!downloadProxySingleton) {
10
- proxyDownload();
10
+ proxyDownload(userConfiguration);
11
11
  downloadProxySingleton = {
12
12
  beforeSend: function beforeSend(callback) {
13
13
  beforeSendCallbacks.push(callback);
@@ -29,7 +29,7 @@ export function resetDownloadProxy() {
29
29
  }
30
30
  }
31
31
 
32
- function proxyDownload() {
32
+ function proxyDownload(userConfiguration) {
33
33
  originalDownloadRequest = sdk.downloadFile;
34
34
 
35
35
  sdk.downloadFile = function () {
@@ -45,23 +45,27 @@ function proxyDownload() {
45
45
  dataflux_xhr.startTime = now();
46
46
  var originalSuccess = arguments[0].success;
47
47
 
48
- arguments[0].success = function () {
49
- reportXhr(arguments[0]);
48
+ if (typeof originalSuccess === 'function') {
49
+ arguments[0].success = function () {
50
+ reportXhr(arguments[0]);
50
51
 
51
- if (originalSuccess) {
52
- originalSuccess.apply(_this, arguments);
53
- }
54
- };
52
+ if (originalSuccess) {
53
+ originalSuccess.apply(_this, arguments);
54
+ }
55
+ };
56
+ }
55
57
 
56
58
  var originalFail = arguments[0].fail;
57
59
 
58
- arguments[0].fail = function () {
59
- reportXhr(arguments[0]);
60
+ if (typeof originalFail === 'function') {
61
+ arguments[0].fail = function () {
62
+ reportXhr(arguments[0]);
60
63
 
61
- if (originalFail) {
62
- originalFail.apply(_this, arguments);
63
- }
64
- };
64
+ if (originalFail) {
65
+ originalFail.apply(_this, arguments);
66
+ }
67
+ };
68
+ }
65
69
 
66
70
  var hasBeenReported = false;
67
71
 
@@ -87,6 +91,35 @@ function proxyDownload() {
87
91
  beforeSendCallbacks.forEach(function (callback) {
88
92
  callback(dataflux_xhr);
89
93
  });
90
- return originalDownloadRequest.apply(this, arguments);
94
+ var result = originalDownloadRequest.apply(this, arguments); // 判断结果是否为promise
95
+
96
+ var isPromise = function isPromise(obj) {
97
+ return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
98
+ };
99
+
100
+ if (isPromise(result) && userConfiguration.isVue2) {
101
+ // vue2 版本,success, fail 都在then返回
102
+ return result.then(function (res) {
103
+ if (res[0]) {
104
+ reportXhr(res[0]);
105
+ } else {
106
+ reportXhr(res[1]);
107
+ }
108
+
109
+ return res;
110
+ });
111
+ } else if (isPromise(result) && !userConfiguration.isVue2) {
112
+ return new Promise(function (resolve, reject) {
113
+ result.then(function (res) {
114
+ reportXhr(res);
115
+ resolve(res);
116
+ }).catch(function (err) {
117
+ reportXhr(err);
118
+ reject(err);
119
+ });
120
+ });
121
+ } else {
122
+ return result;
123
+ }
91
124
  };
92
125
  }
@@ -91,10 +91,10 @@ export function startAutomaticErrorCollection(configuration) {
91
91
  return errorObservable;
92
92
  }
93
93
  export function trackNetworkError(configuration, errorObservable) {
94
- startXhrProxy().onRequestComplete(function (context) {
94
+ startXhrProxy(configuration).onRequestComplete(function (context) {
95
95
  return handleCompleteRequest(context.type, context);
96
96
  });
97
- startDownloadProxy().onRequestComplete(function (context) {
97
+ startDownloadProxy(configuration).onRequestComplete(function (context) {
98
98
  return handleCompleteRequest(context.type, context);
99
99
  });
100
100
 
@@ -5,9 +5,9 @@ var xhrProxySingleton;
5
5
  var beforeSendCallbacks = [];
6
6
  var onRequestCompleteCallbacks = [];
7
7
  var originalXhrRequest;
8
- export function startXhrProxy() {
8
+ export function startXhrProxy(userConfiguration) {
9
9
  if (!xhrProxySingleton) {
10
- proxyXhr();
10
+ proxyXhr(userConfiguration);
11
11
  xhrProxySingleton = {
12
12
  beforeSend: function beforeSend(callback) {
13
13
  beforeSendCallbacks.push(callback);
@@ -29,7 +29,7 @@ export function resetXhrProxy() {
29
29
  }
30
30
  }
31
31
 
32
- function proxyXhr() {
32
+ function proxyXhr(userConfiguration) {
33
33
  originalXhrRequest = sdk.request;
34
34
 
35
35
  sdk.request = function () {
@@ -46,23 +46,27 @@ function proxyXhr() {
46
46
  dataflux_xhr.startTime = now();
47
47
  var originalSuccess = arguments[0].success;
48
48
 
49
- arguments[0].success = function () {
50
- reportXhr(arguments[0]);
49
+ if (typeof originalSuccess === 'function') {
50
+ arguments[0].success = function () {
51
+ reportXhr(arguments[0]);
51
52
 
52
- if (originalSuccess) {
53
- originalSuccess.apply(_this, arguments);
54
- }
55
- };
53
+ if (originalSuccess) {
54
+ originalSuccess.apply(_this, arguments);
55
+ }
56
+ };
57
+ }
56
58
 
57
59
  var originalFail = arguments[0].fail;
58
60
 
59
- arguments[0].fail = function () {
60
- reportXhr(arguments[0]);
61
+ if (typeof originalFail === 'function') {
62
+ arguments[0].fail = function () {
63
+ reportXhr(arguments[0]);
61
64
 
62
- if (originalFail) {
63
- originalFail.apply(_this, arguments);
64
- }
65
- };
65
+ if (originalFail) {
66
+ originalFail.apply(_this, arguments);
67
+ }
68
+ };
69
+ }
66
70
 
67
71
  var hasBeenReported = false;
68
72
 
@@ -85,6 +89,35 @@ function proxyXhr() {
85
89
  beforeSendCallbacks.forEach(function (callback) {
86
90
  callback(dataflux_xhr);
87
91
  });
88
- return originalXhrRequest.call(this, dataflux_xhr.option);
92
+ var result = originalXhrRequest.call(this, dataflux_xhr.option); // 判断结果是否为promise
93
+
94
+ var isPromise = function isPromise(obj) {
95
+ return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
96
+ };
97
+
98
+ if (isPromise(result) && userConfiguration.isVue2) {
99
+ // vue2 版本,success, fail 都在then返回
100
+ return result.then(function (res) {
101
+ if (res[0]) {
102
+ reportXhr(res[0]);
103
+ } else {
104
+ reportXhr(res[1]);
105
+ }
106
+
107
+ return res;
108
+ });
109
+ } else if (isPromise(result) && !userConfiguration.isVue2) {
110
+ return new Promise(function (resolve, reject) {
111
+ result.then(function (res) {
112
+ reportXhr(res);
113
+ resolve(res);
114
+ }).catch(function (err) {
115
+ reportXhr(err);
116
+ reject(err);
117
+ });
118
+ });
119
+ } else {
120
+ return result;
121
+ }
89
122
  };
90
123
  }
@@ -28,7 +28,8 @@ export function startRumAssembly(applicationId, configuration, session, lifeCycl
28
28
  sdkName: configuration.sdkName,
29
29
  sdkVersion: configuration.sdkVersion,
30
30
  env: configuration.env,
31
- version: configuration.version
31
+ version: configuration.version,
32
+ service: configuration.service
32
33
  },
33
34
  tags: configuration.tags,
34
35
  application: {
@@ -10,7 +10,6 @@ function proxyPage(pageOptions, lifeCycle) {
10
10
  startTime = now();
11
11
  ['onReady', 'onShow', 'onLoad', 'onUnload', 'onHide'].forEach(methodName => {
12
12
  var userDefinedMethod = pageOptions[methodName];
13
- if (typeof userDefinedMethod !== 'function') return;
14
13
 
15
14
  pageOptions[methodName] = function () {
16
15
  var mpType = this.mpType || this.$vm.mpType;
@@ -31,7 +31,7 @@ function getHeaderString(header) {
31
31
  }
32
32
 
33
33
  export function trackXhr(lifeCycle, configuration, tracer) {
34
- var xhrProxy = startXhrProxy();
34
+ var xhrProxy = startXhrProxy(configuration);
35
35
  xhrProxy.beforeSend(function (context) {
36
36
  if (isAllowedRequestUrl(configuration, context.url)) {
37
37
  tracer.traceXhr(context);
@@ -62,7 +62,7 @@ export function trackXhr(lifeCycle, configuration, tracer) {
62
62
  return xhrProxy;
63
63
  }
64
64
  export function trackDownload(lifeCycle, configuration) {
65
- var dwonloadProxy = startDownloadProxy();
65
+ var dwonloadProxy = startDownloadProxy(configuration);
66
66
  dwonloadProxy.beforeSend(function (context) {
67
67
  if (isAllowedRequestUrl(configuration, context.url)) {
68
68
  context.requestIndex = getNextRequestIndex();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/rum-uniapp",
3
- "version": "2.1.5",
3
+ "version": "2.1.8",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",