@cloudcare/rum-uniapp 2.1.8 → 2.1.9

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,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildEnv = void 0;
7
7
  var buildEnv = {
8
- sdkVersion: '2.1.8',
8
+ sdkVersion: '2.1.9',
9
9
  sdkName: 'df_uniapp_rum_sdk'
10
10
  };
11
11
  exports.buildEnv = buildEnv;
@@ -89,6 +89,8 @@ var dataMap = {
89
89
  error: {
90
90
  type: _enums.RumEventType.ERROR,
91
91
  tags: {
92
+ trace_id: '_dd.trace_id',
93
+ span_id: '_dd.span_id',
92
94
  error_source: 'error.source',
93
95
  error_type: 'error.type',
94
96
  resource_url: 'error.resource.url',
@@ -134,7 +134,9 @@ function trackNetworkError(configuration, errorObservable) {
134
134
  resource: {
135
135
  method: request.method,
136
136
  statusCode: request.status,
137
- url: request.url
137
+ url: request.url,
138
+ traceId: request.traceId,
139
+ spanId: request.spanId
138
140
  },
139
141
  type: _errorTools.ErrorSource.NETWORK,
140
142
  source: _errorTools.ErrorSource.NETWORK,
@@ -58,8 +58,10 @@ function doStartErrorCollection(lifeCycle) {
58
58
 
59
59
  function processError(error) {
60
60
  var resource = error.resource;
61
+ var tracingInfo;
61
62
 
62
63
  if (resource) {
64
+ tracingInfo = computeRequestTracingInfo(resource);
63
65
  var urlObj = (0, _utils.urlParse)(error.resource.url).getParse();
64
66
  resource = {
65
67
  method: error.resource.method,
@@ -72,7 +74,7 @@ function processError(error) {
72
74
  };
73
75
  }
74
76
 
75
- var rawRumEvent = {
77
+ var rawRumEvent = (0, _utils.extend2Lev)({
76
78
  date: error.startTime,
77
79
  error: {
78
80
  message: error.message,
@@ -83,9 +85,24 @@ function processError(error) {
83
85
  starttime: error.startTime
84
86
  },
85
87
  type: _enums.RumEventType.ERROR
86
- };
88
+ }, tracingInfo);
87
89
  return {
88
90
  rawRumEvent: rawRumEvent,
89
91
  startTime: error.startTime
90
92
  };
93
+ }
94
+
95
+ function computeRequestTracingInfo(request) {
96
+ var hasBeenTraced = request.traceId && request.spanId;
97
+
98
+ if (!hasBeenTraced) {
99
+ return undefined;
100
+ }
101
+
102
+ return {
103
+ _dd: {
104
+ spanId: request.spanId,
105
+ traceId: request.traceId
106
+ }
107
+ };
91
108
  }
@@ -41,7 +41,7 @@ DDtraceTracer.prototype = {
41
41
  makeTracingHeaders: function makeTracingHeaders() {
42
42
  return {
43
43
  'x-datadog-origin': 'rum',
44
- // 'x-datadog-parent-id': spanId.toDecimalString(),
44
+ 'x-datadog-parent-id': this.getSpanId(),
45
45
  'x-datadog-sampled': '1',
46
46
  'x-datadog-sampling-priority': '1',
47
47
  'x-datadog-trace-id': this.getTraceId()
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.1.8',
2
+ sdkVersion: '2.1.9',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -80,6 +80,8 @@ export var dataMap = {
80
80
  error: {
81
81
  type: RumEventType.ERROR,
82
82
  tags: {
83
+ trace_id: '_dd.trace_id',
84
+ span_id: '_dd.span_id',
83
85
  error_source: 'error.source',
84
86
  error_type: 'error.type',
85
87
  resource_url: 'error.resource.url',
@@ -105,7 +105,9 @@ export function trackNetworkError(configuration, errorObservable) {
105
105
  resource: {
106
106
  method: request.method,
107
107
  statusCode: request.status,
108
- url: request.url
108
+ url: request.url,
109
+ traceId: request.traceId,
110
+ spanId: request.spanId
109
111
  },
110
112
  type: ErrorSource.NETWORK,
111
113
  source: ErrorSource.NETWORK,
@@ -1,7 +1,7 @@
1
1
  import { startAutomaticErrorCollection } from '../../core/errorCollection';
2
2
  import { RumEventType } from '../../helper/enums';
3
3
  import { LifeCycleEventType } from '../../core/lifeCycle';
4
- import { urlParse, replaceNumberCharByPath, getStatusGroup } from '../../helper/utils';
4
+ import { urlParse, replaceNumberCharByPath, getStatusGroup, extend2Lev } from '../../helper/utils';
5
5
  export function startErrorCollection(lifeCycle, configuration) {
6
6
  // return doStartErrorCollection(
7
7
  // lifeCycle,
@@ -44,8 +44,10 @@ export function doStartErrorCollection(lifeCycle) {
44
44
 
45
45
  function processError(error) {
46
46
  var resource = error.resource;
47
+ var tracingInfo;
47
48
 
48
49
  if (resource) {
50
+ tracingInfo = computeRequestTracingInfo(resource);
49
51
  var urlObj = urlParse(error.resource.url).getParse();
50
52
  resource = {
51
53
  method: error.resource.method,
@@ -58,7 +60,7 @@ function processError(error) {
58
60
  };
59
61
  }
60
62
 
61
- var rawRumEvent = {
63
+ var rawRumEvent = extend2Lev({
62
64
  date: error.startTime,
63
65
  error: {
64
66
  message: error.message,
@@ -69,9 +71,24 @@ function processError(error) {
69
71
  starttime: error.startTime
70
72
  },
71
73
  type: RumEventType.ERROR
72
- };
74
+ }, tracingInfo);
73
75
  return {
74
76
  rawRumEvent: rawRumEvent,
75
77
  startTime: error.startTime
76
78
  };
79
+ }
80
+
81
+ function computeRequestTracingInfo(request) {
82
+ var hasBeenTraced = request.traceId && request.spanId;
83
+
84
+ if (!hasBeenTraced) {
85
+ return undefined;
86
+ }
87
+
88
+ return {
89
+ _dd: {
90
+ spanId: request.spanId,
91
+ traceId: request.traceId
92
+ }
93
+ };
77
94
  }
@@ -33,7 +33,7 @@ DDtraceTracer.prototype = {
33
33
  makeTracingHeaders: function makeTracingHeaders() {
34
34
  return {
35
35
  'x-datadog-origin': 'rum',
36
- // 'x-datadog-parent-id': spanId.toDecimalString(),
36
+ 'x-datadog-parent-id': this.getSpanId(),
37
37
  'x-datadog-sampled': '1',
38
38
  'x-datadog-sampling-priority': '1',
39
39
  'x-datadog-trace-id': this.getTraceId()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/rum-uniapp",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",