@cloudcare/rum-uniapp 2.2.11 → 2.2.12

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.11',
8
+ sdkVersion: '2.2.12',
9
9
  sdkName: 'df_uniapp_rum_sdk'
10
10
  };
@@ -39,40 +39,24 @@ function proxyDownload(userConfiguration) {
39
39
  originalDownloadRequest = _sdk.sdk.downloadFile;
40
40
  _sdk.sdk.downloadFile = function () {
41
41
  var _this = this;
42
+ var requestOptions = arguments[0];
42
43
  var dataflux_xhr = {
43
44
  method: 'GET',
44
45
  startTime: 0,
45
- url: arguments[0].url,
46
+ url: requestOptions.url,
46
47
  type: _enums.RequestType.DOWNLOAD,
47
48
  responseType: 'file'
48
49
  };
49
50
  dataflux_xhr.startTime = (0, _utils.now)();
50
- var originalSuccess = arguments[0].success;
51
- arguments[0].success = function () {
52
- reportXhr(arguments[0]);
53
- if (typeof originalSuccess === 'function') {
54
- originalSuccess.apply(_this, arguments);
55
- }
56
- };
57
- var originalFail = arguments[0].fail;
58
- arguments[0].fail = function () {
59
- reportXhr(arguments[0]);
60
- if (typeof originalFail === 'function') {
61
- originalFail.apply(_this, arguments);
62
- }
63
- };
64
- var originalComplete = arguments[0].complete;
65
- arguments[0].complete = function () {
66
- reportXhr(arguments[0]);
67
- if (typeof originalComplete === 'function') {
68
- originalComplete.apply(_this, arguments);
69
- }
70
- };
51
+ var originalSuccess = requestOptions.success;
52
+ var originalFail = requestOptions.fail;
53
+ var originalComplete = requestOptions.complete;
71
54
  var hasBeenReported = false;
72
55
  var reportXhr = function reportXhr(res) {
73
56
  if (hasBeenReported) {
74
57
  return;
75
58
  }
59
+ res = res || {};
76
60
  hasBeenReported = true;
77
61
  dataflux_xhr.duration = (0, _utils.now)() - dataflux_xhr.startTime;
78
62
  dataflux_xhr.response = JSON.stringify({
@@ -83,39 +67,66 @@ function proxyDownload(userConfiguration) {
83
67
  dataflux_xhr.profile = res.profile;
84
68
  dataflux_xhr.status = res.statusCode || res.status || 0;
85
69
  onRequestCompleteCallbacks.forEach(function (callback) {
86
- callback(dataflux_xhr);
70
+ try {
71
+ callback(dataflux_xhr);
72
+ } catch (e) {}
87
73
  });
88
74
  };
75
+ var safeReportXhr = function safeReportXhr(res) {
76
+ try {
77
+ reportXhr(res);
78
+ } catch (e) {}
79
+ };
80
+ // Only wrap callbacks supplied by the caller. Adding new callbacks can change
81
+ // uni-app request behavior, especially the Promise result shape in Vue2.
82
+ if (typeof originalSuccess === 'function') {
83
+ requestOptions.success = function () {
84
+ safeReportXhr(arguments[0]);
85
+ originalSuccess.apply(_this, arguments);
86
+ };
87
+ }
88
+ if (typeof originalFail === 'function') {
89
+ requestOptions.fail = function () {
90
+ safeReportXhr(arguments[0]);
91
+ originalFail.apply(_this, arguments);
92
+ };
93
+ }
94
+ if (typeof originalComplete === 'function') {
95
+ requestOptions.complete = function () {
96
+ safeReportXhr(arguments[0]);
97
+ originalComplete.apply(_this, arguments);
98
+ };
99
+ }
89
100
  beforeSendCallbacks.forEach(function (callback) {
90
- callback(dataflux_xhr);
101
+ try {
102
+ callback(dataflux_xhr);
103
+ } catch (e) {}
91
104
  });
92
105
  var result = originalDownloadRequest.apply(this, arguments);
93
106
  // 判断结果是否为promise
94
107
  var isPromise = function isPromise(obj) {
95
108
  return !!obj && (_typeof(obj) === "object" || typeof obj === "function") && typeof obj.then === "function";
96
109
  };
97
- if (isPromise(result) && userConfiguration.isVue2) {
98
- // vue2 版本,success, fail 都在then返回
99
- return result.then(function (res) {
100
- if (res[0]) {
101
- reportXhr(res[0]);
102
- } else {
103
- reportXhr(res[1]);
104
- }
105
- return res;
106
- });
107
- } else if (isPromise(result) && !userConfiguration.isVue2) {
108
- return new Promise(function (resolve, reject) {
110
+ if (isPromise(result)) {
111
+ try {
109
112
  result.then(function (res) {
110
- reportXhr(res);
111
- resolve(res);
112
- })["catch"](function (err) {
113
- reportXhr(err);
114
- reject(err);
113
+ if (userConfiguration.isVue2) {
114
+ // vue2 版本,success, fail 都在then返回
115
+ if (res && res[0]) {
116
+ safeReportXhr(res[0]);
117
+ } else if (res && res[1]) {
118
+ safeReportXhr(res[1]);
119
+ } else {
120
+ safeReportXhr(res);
121
+ }
122
+ } else {
123
+ safeReportXhr(res);
124
+ }
125
+ }, function (err) {
126
+ safeReportXhr(err);
115
127
  });
116
- });
117
- } else {
118
- return result;
128
+ } catch (e) {}
119
129
  }
130
+ return result;
120
131
  };
121
132
  }
@@ -39,41 +39,25 @@ function proxyXhr(userConfiguration) {
39
39
  originalXhrRequest = _sdk.sdk.request;
40
40
  _sdk.sdk.request = function () {
41
41
  var _this = this;
42
+ var requestOptions = arguments[0];
42
43
  var dataflux_xhr = {
43
- method: arguments[0].method || "GET",
44
+ method: requestOptions.method || "GET",
44
45
  startTime: 0,
45
- url: arguments[0].url,
46
+ url: requestOptions.url,
46
47
  type: _enums.RequestType.XHR,
47
- responseType: arguments[0].responseType || "text",
48
- option: arguments[0]
48
+ responseType: requestOptions.responseType || "text",
49
+ option: requestOptions
49
50
  };
50
51
  dataflux_xhr.startTime = (0, _utils.now)();
51
- var originalSuccess = arguments[0].success;
52
- arguments[0].success = function () {
53
- reportXhr(arguments[0]);
54
- if (typeof originalSuccess === "function") {
55
- originalSuccess.apply(_this, arguments);
56
- }
57
- };
58
- var originalFail = arguments[0].fail;
59
- arguments[0].fail = function () {
60
- reportXhr(arguments[0]);
61
- if (typeof originalFail === "function") {
62
- originalFail.apply(_this, arguments);
63
- }
64
- };
65
- var originalComplete = arguments[0].complete;
66
- arguments[0].complete = function () {
67
- reportXhr(arguments[0]);
68
- if (typeof originalComplete === "function") {
69
- originalComplete.apply(_this, arguments);
70
- }
71
- };
52
+ var originalSuccess = requestOptions.success;
53
+ var originalFail = requestOptions.fail;
54
+ var originalComplete = requestOptions.complete;
72
55
  var hasBeenReported = false;
73
56
  var reportXhr = function reportXhr(res) {
74
57
  if (hasBeenReported) {
75
58
  return;
76
59
  }
60
+ res = res || {};
77
61
  hasBeenReported = true;
78
62
  dataflux_xhr.duration = (0, _utils.now)() - dataflux_xhr.startTime;
79
63
  dataflux_xhr.response = res.data && JSON.stringify(res.data) || {};
@@ -81,39 +65,66 @@ function proxyXhr(userConfiguration) {
81
65
  dataflux_xhr.profile = res.profile;
82
66
  dataflux_xhr.status = res.statusCode || res.status || 0;
83
67
  onRequestCompleteCallbacks.forEach(function (callback) {
84
- callback(dataflux_xhr);
68
+ try {
69
+ callback(dataflux_xhr);
70
+ } catch (e) {}
85
71
  });
86
72
  };
73
+ var safeReportXhr = function safeReportXhr(res) {
74
+ try {
75
+ reportXhr(res);
76
+ } catch (e) {}
77
+ };
78
+ // Only wrap callbacks supplied by the caller. Adding new callbacks can change
79
+ // uni-app request behavior, especially the Promise result shape in Vue2.
80
+ if (typeof originalSuccess === "function") {
81
+ requestOptions.success = function () {
82
+ safeReportXhr(arguments[0]);
83
+ originalSuccess.apply(_this, arguments);
84
+ };
85
+ }
86
+ if (typeof originalFail === "function") {
87
+ requestOptions.fail = function () {
88
+ safeReportXhr(arguments[0]);
89
+ originalFail.apply(_this, arguments);
90
+ };
91
+ }
92
+ if (typeof originalComplete === "function") {
93
+ requestOptions.complete = function () {
94
+ safeReportXhr(arguments[0]);
95
+ originalComplete.apply(_this, arguments);
96
+ };
97
+ }
87
98
  beforeSendCallbacks.forEach(function (callback) {
88
- callback(dataflux_xhr);
99
+ try {
100
+ callback(dataflux_xhr);
101
+ } catch (e) {}
89
102
  });
90
103
  var result = originalXhrRequest.call(this, dataflux_xhr.option);
91
104
  // 判断结果是否为promise
92
105
  var isPromise = function isPromise(obj) {
93
106
  return !!obj && (_typeof(obj) === "object" || typeof obj === "function") && typeof obj.then === "function";
94
107
  };
95
- if (isPromise(result) && userConfiguration.isVue2) {
96
- // vue2 版本,success, fail 都在then返回
97
- return result.then(function (res) {
98
- if (res[0]) {
99
- reportXhr(res[0]);
100
- } else {
101
- reportXhr(res[1]);
102
- }
103
- return res;
104
- });
105
- } else if (isPromise(result) && !userConfiguration.isVue2) {
106
- return new Promise(function (resolve, reject) {
108
+ if (isPromise(result)) {
109
+ try {
107
110
  result.then(function (res) {
108
- reportXhr(res);
109
- resolve(res);
110
- })["catch"](function (err) {
111
- reportXhr(err);
112
- reject(err);
111
+ if (userConfiguration.isVue2) {
112
+ // vue2 版本,success, fail 都在then返回
113
+ if (res && res[0]) {
114
+ safeReportXhr(res[0]);
115
+ } else if (res && res[1]) {
116
+ safeReportXhr(res[1]);
117
+ } else {
118
+ safeReportXhr(res);
119
+ }
120
+ } else {
121
+ safeReportXhr(res);
122
+ }
123
+ }, function (err) {
124
+ safeReportXhr(err);
113
125
  });
114
- });
115
- } else {
116
- return result;
126
+ } catch (e) {}
117
127
  }
128
+ return result;
118
129
  };
119
130
  }
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.2.11',
2
+ sdkVersion: '2.2.12',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -31,40 +31,24 @@ function proxyDownload(userConfiguration) {
31
31
  originalDownloadRequest = sdk.downloadFile;
32
32
  sdk.downloadFile = function () {
33
33
  var _this = this;
34
+ var requestOptions = arguments[0];
34
35
  var dataflux_xhr = {
35
36
  method: 'GET',
36
37
  startTime: 0,
37
- url: arguments[0].url,
38
+ url: requestOptions.url,
38
39
  type: RequestType.DOWNLOAD,
39
40
  responseType: 'file'
40
41
  };
41
42
  dataflux_xhr.startTime = now();
42
- var originalSuccess = arguments[0].success;
43
- arguments[0].success = function () {
44
- reportXhr(arguments[0]);
45
- if (typeof originalSuccess === 'function') {
46
- originalSuccess.apply(_this, arguments);
47
- }
48
- };
49
- var originalFail = arguments[0].fail;
50
- arguments[0].fail = function () {
51
- reportXhr(arguments[0]);
52
- if (typeof originalFail === 'function') {
53
- originalFail.apply(_this, arguments);
54
- }
55
- };
56
- var originalComplete = arguments[0].complete;
57
- arguments[0].complete = function () {
58
- reportXhr(arguments[0]);
59
- if (typeof originalComplete === 'function') {
60
- originalComplete.apply(_this, arguments);
61
- }
62
- };
43
+ var originalSuccess = requestOptions.success;
44
+ var originalFail = requestOptions.fail;
45
+ var originalComplete = requestOptions.complete;
63
46
  var hasBeenReported = false;
64
47
  var reportXhr = function reportXhr(res) {
65
48
  if (hasBeenReported) {
66
49
  return;
67
50
  }
51
+ res = res || {};
68
52
  hasBeenReported = true;
69
53
  dataflux_xhr.duration = now() - dataflux_xhr.startTime;
70
54
  dataflux_xhr.response = JSON.stringify({
@@ -75,39 +59,66 @@ function proxyDownload(userConfiguration) {
75
59
  dataflux_xhr.profile = res.profile;
76
60
  dataflux_xhr.status = res.statusCode || res.status || 0;
77
61
  onRequestCompleteCallbacks.forEach(function (callback) {
78
- callback(dataflux_xhr);
62
+ try {
63
+ callback(dataflux_xhr);
64
+ } catch (e) {}
79
65
  });
80
66
  };
67
+ var safeReportXhr = function safeReportXhr(res) {
68
+ try {
69
+ reportXhr(res);
70
+ } catch (e) {}
71
+ };
72
+ // Only wrap callbacks supplied by the caller. Adding new callbacks can change
73
+ // uni-app request behavior, especially the Promise result shape in Vue2.
74
+ if (typeof originalSuccess === 'function') {
75
+ requestOptions.success = function () {
76
+ safeReportXhr(arguments[0]);
77
+ originalSuccess.apply(_this, arguments);
78
+ };
79
+ }
80
+ if (typeof originalFail === 'function') {
81
+ requestOptions.fail = function () {
82
+ safeReportXhr(arguments[0]);
83
+ originalFail.apply(_this, arguments);
84
+ };
85
+ }
86
+ if (typeof originalComplete === 'function') {
87
+ requestOptions.complete = function () {
88
+ safeReportXhr(arguments[0]);
89
+ originalComplete.apply(_this, arguments);
90
+ };
91
+ }
81
92
  beforeSendCallbacks.forEach(function (callback) {
82
- callback(dataflux_xhr);
93
+ try {
94
+ callback(dataflux_xhr);
95
+ } catch (e) {}
83
96
  });
84
97
  var result = originalDownloadRequest.apply(this, arguments);
85
98
  // 判断结果是否为promise
86
99
  var isPromise = function isPromise(obj) {
87
100
  return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
88
101
  };
89
- if (isPromise(result) && userConfiguration.isVue2) {
90
- // vue2 版本,success, fail 都在then返回
91
- return result.then(function (res) {
92
- if (res[0]) {
93
- reportXhr(res[0]);
94
- } else {
95
- reportXhr(res[1]);
96
- }
97
- return res;
98
- });
99
- } else if (isPromise(result) && !userConfiguration.isVue2) {
100
- return new Promise(function (resolve, reject) {
102
+ if (isPromise(result)) {
103
+ try {
101
104
  result.then(function (res) {
102
- reportXhr(res);
103
- resolve(res);
104
- }).catch(function (err) {
105
- reportXhr(err);
106
- reject(err);
105
+ if (userConfiguration.isVue2) {
106
+ // vue2 版本,success, fail 都在then返回
107
+ if (res && res[0]) {
108
+ safeReportXhr(res[0]);
109
+ } else if (res && res[1]) {
110
+ safeReportXhr(res[1]);
111
+ } else {
112
+ safeReportXhr(res);
113
+ }
114
+ } else {
115
+ safeReportXhr(res);
116
+ }
117
+ }, function (err) {
118
+ safeReportXhr(err);
107
119
  });
108
- });
109
- } else {
110
- return result;
120
+ } catch (e) {}
111
121
  }
122
+ return result;
112
123
  };
113
124
  }
@@ -31,41 +31,25 @@ function proxyXhr(userConfiguration) {
31
31
  originalXhrRequest = sdk.request;
32
32
  sdk.request = function () {
33
33
  var _this = this;
34
+ var requestOptions = arguments[0];
34
35
  var dataflux_xhr = {
35
- method: arguments[0].method || "GET",
36
+ method: requestOptions.method || "GET",
36
37
  startTime: 0,
37
- url: arguments[0].url,
38
+ url: requestOptions.url,
38
39
  type: RequestType.XHR,
39
- responseType: arguments[0].responseType || "text",
40
- option: arguments[0]
40
+ responseType: requestOptions.responseType || "text",
41
+ option: requestOptions
41
42
  };
42
43
  dataflux_xhr.startTime = now();
43
- var originalSuccess = arguments[0].success;
44
- arguments[0].success = function () {
45
- reportXhr(arguments[0]);
46
- if (typeof originalSuccess === "function") {
47
- originalSuccess.apply(_this, arguments);
48
- }
49
- };
50
- var originalFail = arguments[0].fail;
51
- arguments[0].fail = function () {
52
- reportXhr(arguments[0]);
53
- if (typeof originalFail === "function") {
54
- originalFail.apply(_this, arguments);
55
- }
56
- };
57
- var originalComplete = arguments[0].complete;
58
- arguments[0].complete = function () {
59
- reportXhr(arguments[0]);
60
- if (typeof originalComplete === "function") {
61
- originalComplete.apply(_this, arguments);
62
- }
63
- };
44
+ var originalSuccess = requestOptions.success;
45
+ var originalFail = requestOptions.fail;
46
+ var originalComplete = requestOptions.complete;
64
47
  var hasBeenReported = false;
65
48
  var reportXhr = function reportXhr(res) {
66
49
  if (hasBeenReported) {
67
50
  return;
68
51
  }
52
+ res = res || {};
69
53
  hasBeenReported = true;
70
54
  dataflux_xhr.duration = now() - dataflux_xhr.startTime;
71
55
  dataflux_xhr.response = res.data && JSON.stringify(res.data) || {};
@@ -73,39 +57,66 @@ function proxyXhr(userConfiguration) {
73
57
  dataflux_xhr.profile = res.profile;
74
58
  dataflux_xhr.status = res.statusCode || res.status || 0;
75
59
  onRequestCompleteCallbacks.forEach(function (callback) {
76
- callback(dataflux_xhr);
60
+ try {
61
+ callback(dataflux_xhr);
62
+ } catch (e) {}
77
63
  });
78
64
  };
65
+ var safeReportXhr = function safeReportXhr(res) {
66
+ try {
67
+ reportXhr(res);
68
+ } catch (e) {}
69
+ };
70
+ // Only wrap callbacks supplied by the caller. Adding new callbacks can change
71
+ // uni-app request behavior, especially the Promise result shape in Vue2.
72
+ if (typeof originalSuccess === "function") {
73
+ requestOptions.success = function () {
74
+ safeReportXhr(arguments[0]);
75
+ originalSuccess.apply(_this, arguments);
76
+ };
77
+ }
78
+ if (typeof originalFail === "function") {
79
+ requestOptions.fail = function () {
80
+ safeReportXhr(arguments[0]);
81
+ originalFail.apply(_this, arguments);
82
+ };
83
+ }
84
+ if (typeof originalComplete === "function") {
85
+ requestOptions.complete = function () {
86
+ safeReportXhr(arguments[0]);
87
+ originalComplete.apply(_this, arguments);
88
+ };
89
+ }
79
90
  beforeSendCallbacks.forEach(function (callback) {
80
- callback(dataflux_xhr);
91
+ try {
92
+ callback(dataflux_xhr);
93
+ } catch (e) {}
81
94
  });
82
95
  var result = originalXhrRequest.call(this, dataflux_xhr.option);
83
96
  // 判断结果是否为promise
84
97
  var isPromise = function isPromise(obj) {
85
98
  return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
86
99
  };
87
- if (isPromise(result) && userConfiguration.isVue2) {
88
- // vue2 版本,success, fail 都在then返回
89
- return result.then(function (res) {
90
- if (res[0]) {
91
- reportXhr(res[0]);
92
- } else {
93
- reportXhr(res[1]);
94
- }
95
- return res;
96
- });
97
- } else if (isPromise(result) && !userConfiguration.isVue2) {
98
- return new Promise(function (resolve, reject) {
100
+ if (isPromise(result)) {
101
+ try {
99
102
  result.then(function (res) {
100
- reportXhr(res);
101
- resolve(res);
102
- }).catch(function (err) {
103
- reportXhr(err);
104
- reject(err);
103
+ if (userConfiguration.isVue2) {
104
+ // vue2 版本,success, fail 都在then返回
105
+ if (res && res[0]) {
106
+ safeReportXhr(res[0]);
107
+ } else if (res && res[1]) {
108
+ safeReportXhr(res[1]);
109
+ } else {
110
+ safeReportXhr(res);
111
+ }
112
+ } else {
113
+ safeReportXhr(res);
114
+ }
115
+ }, function (err) {
116
+ safeReportXhr(err);
105
117
  });
106
- });
107
- } else {
108
- return result;
118
+ } catch (e) {}
109
119
  }
120
+ return result;
110
121
  };
111
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/rum-uniapp",
3
- "version": "2.2.11",
3
+ "version": "2.2.12",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",