@cloudcare/rum-uniapp 2.2.7 → 2.2.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.
@@ -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.7',
8
+ sdkVersion: '2.2.8',
9
9
  sdkName: 'df_uniapp_rum_sdk'
10
10
  };
@@ -40,11 +40,11 @@ function proxyXhr(userConfiguration) {
40
40
  _sdk.sdk.request = function () {
41
41
  var _this = this;
42
42
  var dataflux_xhr = {
43
- method: arguments[0].method || 'GET',
43
+ method: arguments[0].method || "GET",
44
44
  startTime: 0,
45
45
  url: arguments[0].url,
46
46
  type: _enums.RequestType.XHR,
47
- responseType: arguments[0].responseType || 'text',
47
+ responseType: arguments[0].responseType || "text",
48
48
  option: arguments[0]
49
49
  };
50
50
  dataflux_xhr.startTime = (0, _utils.now)();
@@ -52,7 +52,7 @@ function proxyXhr(userConfiguration) {
52
52
  if (originalSuccess) {
53
53
  arguments[0].success = function () {
54
54
  reportXhr(arguments[0]);
55
- if (typeof originalSuccess === 'function') {
55
+ if (typeof originalSuccess === "function") {
56
56
  originalSuccess.apply(_this, arguments);
57
57
  }
58
58
  };
@@ -61,11 +61,20 @@ function proxyXhr(userConfiguration) {
61
61
  if (originalFail) {
62
62
  arguments[0].fail = function () {
63
63
  reportXhr(arguments[0]);
64
- if (typeof originalFail === 'function') {
64
+ if (typeof originalFail === "function") {
65
65
  originalFail.apply(_this, arguments);
66
66
  }
67
67
  };
68
68
  }
69
+ var originalComplete = arguments[0].complete;
70
+ if (originalComplete) {
71
+ arguments[0].complete = function () {
72
+ reportXhr(arguments[0]);
73
+ if (typeof originalComplete === "function") {
74
+ originalComplete.apply(_this, arguments);
75
+ }
76
+ };
77
+ }
69
78
  var hasBeenReported = false;
70
79
  var reportXhr = function reportXhr(res) {
71
80
  if (hasBeenReported) {
@@ -87,7 +96,7 @@ function proxyXhr(userConfiguration) {
87
96
  var result = originalXhrRequest.call(this, dataflux_xhr.option);
88
97
  // 判断结果是否为promise
89
98
  var isPromise = function isPromise(obj) {
90
- return !!obj && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
99
+ return !!obj && (_typeof(obj) === "object" || typeof obj === "function") && typeof obj.then === "function";
91
100
  };
92
101
  if (isPromise(result) && userConfiguration.isVue2) {
93
102
  // vue2 版本,success, fail 都在then返回
@@ -86,6 +86,9 @@ function startParentContexts(lifeCycle) {
86
86
  if (startTime === undefined) {
87
87
  return currentContext ? buildContext() : undefined;
88
88
  }
89
+ if (currentContext && previousContexts.length == 0) {
90
+ return buildContext();
91
+ }
89
92
  if (currentContext && startTime >= currentContext.startTime) {
90
93
  return buildContext();
91
94
  }
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.2.7',
2
+ sdkVersion: '2.2.8',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -1,6 +1,6 @@
1
- import { sdk } from './sdk';
2
- import { now } from '../helper/utils';
3
- import { RequestType } from '../helper/enums';
1
+ import { sdk } from "./sdk";
2
+ import { now } from "../helper/utils";
3
+ import { RequestType } from "../helper/enums";
4
4
  var xhrProxySingleton;
5
5
  var beforeSendCallbacks = [];
6
6
  var onRequestCompleteCallbacks = [];
@@ -32,11 +32,11 @@ function proxyXhr(userConfiguration) {
32
32
  sdk.request = function () {
33
33
  var _this = this;
34
34
  var dataflux_xhr = {
35
- method: arguments[0].method || 'GET',
35
+ method: arguments[0].method || "GET",
36
36
  startTime: 0,
37
37
  url: arguments[0].url,
38
38
  type: RequestType.XHR,
39
- responseType: arguments[0].responseType || 'text',
39
+ responseType: arguments[0].responseType || "text",
40
40
  option: arguments[0]
41
41
  };
42
42
  dataflux_xhr.startTime = now();
@@ -44,7 +44,7 @@ function proxyXhr(userConfiguration) {
44
44
  if (originalSuccess) {
45
45
  arguments[0].success = function () {
46
46
  reportXhr(arguments[0]);
47
- if (typeof originalSuccess === 'function') {
47
+ if (typeof originalSuccess === "function") {
48
48
  originalSuccess.apply(_this, arguments);
49
49
  }
50
50
  };
@@ -53,11 +53,20 @@ function proxyXhr(userConfiguration) {
53
53
  if (originalFail) {
54
54
  arguments[0].fail = function () {
55
55
  reportXhr(arguments[0]);
56
- if (typeof originalFail === 'function') {
56
+ if (typeof originalFail === "function") {
57
57
  originalFail.apply(_this, arguments);
58
58
  }
59
59
  };
60
60
  }
61
+ var originalComplete = arguments[0].complete;
62
+ if (originalComplete) {
63
+ arguments[0].complete = function () {
64
+ reportXhr(arguments[0]);
65
+ if (typeof originalComplete === "function") {
66
+ originalComplete.apply(_this, arguments);
67
+ }
68
+ };
69
+ }
61
70
  var hasBeenReported = false;
62
71
  var reportXhr = function reportXhr(res) {
63
72
  if (hasBeenReported) {
@@ -79,7 +88,7 @@ function proxyXhr(userConfiguration) {
79
88
  var result = originalXhrRequest.call(this, dataflux_xhr.option);
80
89
  // 判断结果是否为promise
81
90
  var isPromise = function isPromise(obj) {
82
- return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
91
+ return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
83
92
  };
84
93
  if (isPromise(result) && userConfiguration.isVue2) {
85
94
  // vue2 版本,success, fail 都在then返回
@@ -1,6 +1,6 @@
1
- import { ONE_MINUTE, ONE_HOUR } from '../helper/enums';
2
- import { each, now } from '../helper/utils';
3
- import { LifeCycleEventType } from '../core/lifeCycle';
1
+ import { ONE_MINUTE, ONE_HOUR } from "../helper/enums";
2
+ import { each, now } from "../helper/utils";
3
+ import { LifeCycleEventType } from "../core/lifeCycle";
4
4
  export var VIEW_CONTEXT_TIME_OUT_DELAY = 4 * ONE_HOUR;
5
5
  export var CLEAR_OLD_CONTEXTS_INTERVAL = ONE_MINUTE;
6
6
  export function startParentContexts(lifeCycle) {
@@ -79,6 +79,9 @@ export function startParentContexts(lifeCycle) {
79
79
  if (startTime === undefined) {
80
80
  return currentContext ? buildContext() : undefined;
81
81
  }
82
+ if (currentContext && previousContexts.length == 0) {
83
+ return buildContext();
84
+ }
82
85
  if (currentContext && startTime >= currentContext.startTime) {
83
86
  return buildContext();
84
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/rum-uniapp",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",