@cloudcare/rum-uniapp 2.2.10 → 2.2.11

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.10',
8
+ sdkVersion: '2.2.11',
9
9
  sdkName: 'df_uniapp_rum_sdk'
10
10
  };
@@ -87,10 +87,10 @@ function commonInit(userConfiguration, buildEnv) {
87
87
  if ('isVue2' in userConfiguration) {
88
88
  transportConfiguration.isVue2 = userConfiguration.isVue2;
89
89
  }
90
- if ('isIntakeUrl' in userConfiguration && (0, _utils.isFunction)(userConfiguration.isIntakeUrl) && (0, _utils.isBoolean)(userConfiguration.isIntakeUrl())) {
90
+ if ('isIntakeUrl' in userConfiguration && (0, _utils.isFunction)(userConfiguration.isIntakeUrl)) {
91
91
  transportConfiguration.isIntakeUrl = userConfiguration.isIntakeUrl;
92
92
  }
93
- return (0, _utils.extend2Lev)(DEFAULT_CONFIGURATION, transportConfiguration);
93
+ return (0, _utils.extend2Lev)({}, DEFAULT_CONFIGURATION, transportConfiguration);
94
94
  }
95
95
  function hasTraceType(traceType) {
96
96
  if (traceType && (0, _utils.values)(_enums.TraceType).indexOf(traceType) > -1) return true;
@@ -72,6 +72,7 @@ var dataMap = exports.dataMap = {
72
72
  resource: {
73
73
  type: _enums.RumEventType.RESOURCE,
74
74
  tags: {
75
+ resource_id: 'resource.id',
75
76
  trace_id: '_dd.trace_id',
76
77
  span_id: '_dd.span_id',
77
78
  resource_type: 'resource.type',
@@ -99,6 +100,7 @@ var dataMap = exports.dataMap = {
99
100
  error: {
100
101
  type: _enums.RumEventType.ERROR,
101
102
  tags: {
103
+ error_id: 'error.id',
102
104
  trace_id: '_dd.trace_id',
103
105
  span_id: '_dd.span_id',
104
106
  error_source: 'error.source',
@@ -48,23 +48,26 @@ function proxyDownload(userConfiguration) {
48
48
  };
49
49
  dataflux_xhr.startTime = (0, _utils.now)();
50
50
  var originalSuccess = arguments[0].success;
51
- if (typeof originalSuccess === 'function') {
52
- arguments[0].success = function () {
53
- reportXhr(arguments[0]);
54
- if (originalSuccess) {
55
- originalSuccess.apply(_this, arguments);
56
- }
57
- };
58
- }
51
+ arguments[0].success = function () {
52
+ reportXhr(arguments[0]);
53
+ if (typeof originalSuccess === 'function') {
54
+ originalSuccess.apply(_this, arguments);
55
+ }
56
+ };
59
57
  var originalFail = arguments[0].fail;
60
- if (typeof originalFail === 'function') {
61
- arguments[0].fail = function () {
62
- reportXhr(arguments[0]);
63
- if (originalFail) {
64
- originalFail.apply(_this, arguments);
65
- }
66
- };
67
- }
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
+ };
68
71
  var hasBeenReported = false;
69
72
  var reportXhr = function reportXhr(res) {
70
73
  if (hasBeenReported) {
@@ -49,32 +49,26 @@ function proxyXhr(userConfiguration) {
49
49
  };
50
50
  dataflux_xhr.startTime = (0, _utils.now)();
51
51
  var originalSuccess = arguments[0].success;
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
- }
52
+ arguments[0].success = function () {
53
+ reportXhr(arguments[0]);
54
+ if (typeof originalSuccess === "function") {
55
+ originalSuccess.apply(_this, arguments);
56
+ }
57
+ };
60
58
  var originalFail = arguments[0].fail;
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
- }
59
+ arguments[0].fail = function () {
60
+ reportXhr(arguments[0]);
61
+ if (typeof originalFail === "function") {
62
+ originalFail.apply(_this, arguments);
63
+ }
64
+ };
69
65
  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
- }
66
+ arguments[0].complete = function () {
67
+ reportXhr(arguments[0]);
68
+ if (typeof originalComplete === "function") {
69
+ originalComplete.apply(_this, arguments);
70
+ }
71
+ };
78
72
  var hasBeenReported = false;
79
73
  var reportXhr = function reportXhr(res) {
80
74
  if (hasBeenReported) {
@@ -59,7 +59,7 @@ function startPerformanceObservable(lifeCycle) {
59
59
  });
60
60
  if (typeof launchEntity !== 'undefined') {
61
61
  lifeCycle.notify(_lifeCycle.LifeCycleEventType.APP_UPDATE, {
62
- startTime: launchEntity.startTime,
62
+ startTime: computeEntryStartTime(startTime, launchEntity),
63
63
  name: '启动',
64
64
  type: 'launch',
65
65
  id: (0, _utils.UUID)(),
@@ -71,7 +71,7 @@ function startPerformanceObservable(lifeCycle) {
71
71
  });
72
72
  if (typeof scriptentity !== 'undefined') {
73
73
  lifeCycle.notify(_lifeCycle.LifeCycleEventType.APP_UPDATE, {
74
- startTime: scriptentity.startTime,
74
+ startTime: computeEntryStartTime(startTime, scriptentity),
75
75
  name: '脚本注入',
76
76
  type: 'script_insert',
77
77
  id: (0, _utils.UUID)(),
@@ -88,7 +88,7 @@ function startPerformanceObservable(lifeCycle) {
88
88
  codeDownloadDuration = launchEntity.duration - firstEntity.duration - scriptentity.duration;
89
89
  // 资源下载耗时
90
90
  lifeCycle.notify(_lifeCycle.LifeCycleEventType.APP_UPDATE, {
91
- startTime: launchEntity.startTime,
91
+ startTime: computeEntryStartTime(startTime, launchEntity),
92
92
  name: '小程序包下载',
93
93
  type: 'package_download',
94
94
  id: (0, _utils.UUID)(),
@@ -101,4 +101,13 @@ function startPerformanceObservable(lifeCycle) {
101
101
  return {
102
102
  stop: subscribe.unsubscribe
103
103
  };
104
+ }
105
+ function computeEntryStartTime(appStartTime, entry) {
106
+ if (!(0, _utils.isNumber)(appStartTime)) {
107
+ return (0, _utils.now)();
108
+ }
109
+ if (!entry || !(0, _utils.isNumber)(entry.startTime)) {
110
+ return appStartTime;
111
+ }
112
+ return appStartTime + entry.startTime;
104
113
  }
@@ -60,6 +60,7 @@ function processError(error) {
60
60
  var rawRumEvent = (0, _utils.extend2Lev)({
61
61
  date: error.startTime,
62
62
  error: {
63
+ id: (0, _utils.UUID)(),
63
64
  message: error.message,
64
65
  resource: resource,
65
66
  source: error.source,
@@ -24,6 +24,7 @@ function processRequest(request) {
24
24
  var resourceEvent = (0, _utils.extend2Lev)({
25
25
  date: startTime,
26
26
  resource: {
27
+ id: (0, _utils.UUID)(),
27
28
  type: type,
28
29
  duration: (0, _utils.msToNs)(request.duration),
29
30
  method: request.method,
@@ -51,9 +52,6 @@ function computeRequestTracingInfo(request) {
51
52
  _dd: {
52
53
  spanId: request.spanId,
53
54
  traceId: request.traceId
54
- },
55
- resource: {
56
- id: (0, _utils.UUID)()
57
55
  }
58
56
  };
59
57
  }
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.2.10',
2
+ sdkVersion: '2.2.11',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -1,4 +1,4 @@
1
- import { extend2Lev, urlParse, values, isFunction, isBoolean } from '../helper/utils';
1
+ import { extend2Lev, urlParse, values, isFunction } from '../helper/utils';
2
2
  import { ONE_KILO_BYTE, ONE_SECOND, TraceType } from '../helper/enums';
3
3
  import { catchUserErrors } from '../helper/catchUserErrors';
4
4
  var TRIM_REGIX = /^\s+|\s+$/g;
@@ -79,10 +79,10 @@ export function commonInit(userConfiguration, buildEnv) {
79
79
  if ('isVue2' in userConfiguration) {
80
80
  transportConfiguration.isVue2 = userConfiguration.isVue2;
81
81
  }
82
- if ('isIntakeUrl' in userConfiguration && isFunction(userConfiguration.isIntakeUrl) && isBoolean(userConfiguration.isIntakeUrl())) {
82
+ if ('isIntakeUrl' in userConfiguration && isFunction(userConfiguration.isIntakeUrl)) {
83
83
  transportConfiguration.isIntakeUrl = userConfiguration.isIntakeUrl;
84
84
  }
85
- return extend2Lev(DEFAULT_CONFIGURATION, transportConfiguration);
85
+ return extend2Lev({}, DEFAULT_CONFIGURATION, transportConfiguration);
86
86
  }
87
87
  function hasTraceType(traceType) {
88
88
  if (traceType && values(TraceType).indexOf(traceType) > -1) return true;
@@ -66,6 +66,7 @@ export var dataMap = {
66
66
  resource: {
67
67
  type: RumEventType.RESOURCE,
68
68
  tags: {
69
+ resource_id: 'resource.id',
69
70
  trace_id: '_dd.trace_id',
70
71
  span_id: '_dd.span_id',
71
72
  resource_type: 'resource.type',
@@ -93,6 +94,7 @@ export var dataMap = {
93
94
  error: {
94
95
  type: RumEventType.ERROR,
95
96
  tags: {
97
+ error_id: 'error.id',
96
98
  trace_id: '_dd.trace_id',
97
99
  span_id: '_dd.span_id',
98
100
  error_source: 'error.source',
@@ -40,23 +40,26 @@ function proxyDownload(userConfiguration) {
40
40
  };
41
41
  dataflux_xhr.startTime = now();
42
42
  var originalSuccess = arguments[0].success;
43
- if (typeof originalSuccess === 'function') {
44
- arguments[0].success = function () {
45
- reportXhr(arguments[0]);
46
- if (originalSuccess) {
47
- originalSuccess.apply(_this, arguments);
48
- }
49
- };
50
- }
43
+ arguments[0].success = function () {
44
+ reportXhr(arguments[0]);
45
+ if (typeof originalSuccess === 'function') {
46
+ originalSuccess.apply(_this, arguments);
47
+ }
48
+ };
51
49
  var originalFail = arguments[0].fail;
52
- if (typeof originalFail === 'function') {
53
- arguments[0].fail = function () {
54
- reportXhr(arguments[0]);
55
- if (originalFail) {
56
- originalFail.apply(_this, arguments);
57
- }
58
- };
59
- }
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
+ };
60
63
  var hasBeenReported = false;
61
64
  var reportXhr = function reportXhr(res) {
62
65
  if (hasBeenReported) {
@@ -41,32 +41,26 @@ function proxyXhr(userConfiguration) {
41
41
  };
42
42
  dataflux_xhr.startTime = now();
43
43
  var originalSuccess = arguments[0].success;
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
- }
44
+ arguments[0].success = function () {
45
+ reportXhr(arguments[0]);
46
+ if (typeof originalSuccess === "function") {
47
+ originalSuccess.apply(_this, arguments);
48
+ }
49
+ };
52
50
  var originalFail = arguments[0].fail;
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
- }
51
+ arguments[0].fail = function () {
52
+ reportXhr(arguments[0]);
53
+ if (typeof originalFail === "function") {
54
+ originalFail.apply(_this, arguments);
55
+ }
56
+ };
61
57
  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
- }
58
+ arguments[0].complete = function () {
59
+ reportXhr(arguments[0]);
60
+ if (typeof originalComplete === "function") {
61
+ originalComplete.apply(_this, arguments);
62
+ }
63
+ };
70
64
  var hasBeenReported = false;
71
65
  var reportXhr = function reportXhr(res) {
72
66
  if (hasBeenReported) {
@@ -1,4 +1,4 @@
1
- import { now, areInOrder, UUID } from '../../helper/utils';
1
+ import { now, areInOrder, UUID, isNumber } from '../../helper/utils';
2
2
  import { LifeCycleEventType } from '../../core/lifeCycle';
3
3
 
4
4
  // 劫持原小程序App方法
@@ -50,7 +50,7 @@ function startPerformanceObservable(lifeCycle) {
50
50
  var launchEntity = entitys.find(entity => entity.entryType === 'navigation' && entity.navigationType === 'appLaunch');
51
51
  if (typeof launchEntity !== 'undefined') {
52
52
  lifeCycle.notify(LifeCycleEventType.APP_UPDATE, {
53
- startTime: launchEntity.startTime,
53
+ startTime: computeEntryStartTime(startTime, launchEntity),
54
54
  name: '启动',
55
55
  type: 'launch',
56
56
  id: UUID(),
@@ -60,7 +60,7 @@ function startPerformanceObservable(lifeCycle) {
60
60
  var scriptentity = entitys.find(entity => entity.entryType === 'script' && entity.name === 'evaluateScript');
61
61
  if (typeof scriptentity !== 'undefined') {
62
62
  lifeCycle.notify(LifeCycleEventType.APP_UPDATE, {
63
- startTime: scriptentity.startTime,
63
+ startTime: computeEntryStartTime(startTime, scriptentity),
64
64
  name: '脚本注入',
65
65
  type: 'script_insert',
66
66
  id: UUID(),
@@ -75,7 +75,7 @@ function startPerformanceObservable(lifeCycle) {
75
75
  codeDownloadDuration = launchEntity.duration - firstEntity.duration - scriptentity.duration;
76
76
  // 资源下载耗时
77
77
  lifeCycle.notify(LifeCycleEventType.APP_UPDATE, {
78
- startTime: launchEntity.startTime,
78
+ startTime: computeEntryStartTime(startTime, launchEntity),
79
79
  name: '小程序包下载',
80
80
  type: 'package_download',
81
81
  id: UUID(),
@@ -88,4 +88,13 @@ function startPerformanceObservable(lifeCycle) {
88
88
  return {
89
89
  stop: subscribe.unsubscribe
90
90
  };
91
+ }
92
+ function computeEntryStartTime(appStartTime, entry) {
93
+ if (!isNumber(appStartTime)) {
94
+ return now();
95
+ }
96
+ if (!entry || !isNumber(entry.startTime)) {
97
+ return appStartTime;
98
+ }
99
+ return appStartTime + entry.startTime;
91
100
  }
@@ -2,7 +2,7 @@ import { startAutomaticErrorCollection } from '../../core/errorCollection';
2
2
  import { RumEventType } from '../../helper/enums';
3
3
  import { LifeCycleEventType } from '../../core/lifeCycle';
4
4
  import { ErrorSource, formatUnknownError } from '../../core/errorTools';
5
- import { urlParse, replaceNumberCharByPath, getStatusGroup, extend2Lev, extend } from '../../helper/utils';
5
+ import { urlParse, replaceNumberCharByPath, getStatusGroup, extend2Lev, extend, UUID } from '../../helper/utils';
6
6
  import { computeStackTrace } from '../../helper/tracekit';
7
7
  export function startErrorCollection(lifeCycle, configuration) {
8
8
  startAutomaticErrorCollection(configuration).subscribe(function (error) {
@@ -53,6 +53,7 @@ function processError(error) {
53
53
  var rawRumEvent = extend2Lev({
54
54
  date: error.startTime,
55
55
  error: {
56
+ id: UUID(),
56
57
  message: error.message,
57
58
  resource: resource,
58
59
  source: error.source,
@@ -18,6 +18,7 @@ function processRequest(request) {
18
18
  var resourceEvent = extend2Lev({
19
19
  date: startTime,
20
20
  resource: {
21
+ id: UUID(),
21
22
  type: type,
22
23
  duration: msToNs(request.duration),
23
24
  method: request.method,
@@ -45,9 +46,6 @@ function computeRequestTracingInfo(request) {
45
46
  _dd: {
46
47
  spanId: request.spanId,
47
48
  traceId: request.traceId
48
- },
49
- resource: {
50
- id: UUID()
51
49
  }
52
50
  };
53
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/rum-uniapp",
3
- "version": "2.2.10",
3
+ "version": "2.2.11",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",