@cloudcare/rum-uniapp 2.2.2 → 2.2.3

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.2',
8
+ sdkVersion: '2.2.3',
9
9
  sdkName: 'df_uniapp_rum_sdk'
10
10
  };
@@ -66,7 +66,8 @@ function commonInit(userConfiguration, buildEnv) {
66
66
  sdkName: buildEnv.sdkName,
67
67
  datakitUrl: getDatakitEndPoint(userConfiguration),
68
68
  tags: userConfiguration.tags || [],
69
- injectTraceHeader: userConfiguration.injectTraceHeader && (0, _catchUserErrors.catchUserErrors)(userConfiguration.injectTraceHeader, 'injectTraceHeader threw an error:')
69
+ injectTraceHeader: userConfiguration.injectTraceHeader && (0, _catchUserErrors.catchUserErrors)(userConfiguration.injectTraceHeader, 'injectTraceHeader threw an error:'),
70
+ generateTraceId: userConfiguration.generateTraceId && (0, _catchUserErrors.catchUserErrors)(userConfiguration.generateTraceId, 'generateTraceId threw an error:')
70
71
  };
71
72
  if ('trackInteractions' in userConfiguration) {
72
73
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
@@ -15,12 +15,18 @@ function randomTraceId() {
15
15
  return n;
16
16
  }
17
17
  /**
18
- *
18
+ *
19
19
  * @param {*} configuration 配置信息
20
20
  */
21
21
  function DDtraceTracer(configuration) {
22
22
  this._spanId = randomTraceId();
23
23
  this._traceId = randomTraceId();
24
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
25
+ var customTraceId = configuration.generateTraceId();
26
+ if (typeof customTraceId === 'string') {
27
+ this.customTraceId = customTraceId;
28
+ }
29
+ }
24
30
  }
25
31
  DDtraceTracer.prototype = {
26
32
  isTracingSupported: function isTracingSupported() {
@@ -30,6 +36,7 @@ DDtraceTracer.prototype = {
30
36
  return this._spanId;
31
37
  },
32
38
  getTraceId: function getTraceId() {
39
+ if (this.customTraceId) return this.customTraceId;
33
40
  return this._traceId;
34
41
  },
35
42
  makeTracingHeaders: function makeTracingHeaders() {
@@ -16,7 +16,7 @@ function randomTraceId() {
16
16
  }
17
17
 
18
18
  /**
19
- *
19
+ *
20
20
  * @param {*} configuration 配置信息
21
21
  */
22
22
  function JaegerTracer(configuration) {
@@ -29,6 +29,12 @@ function JaegerTracer(configuration) {
29
29
  this._traceId = rootSpanId;
30
30
  }
31
31
  this._spanId = rootSpanId;
32
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
33
+ var customTraceId = configuration.generateTraceId();
34
+ if (typeof customTraceId === 'string') {
35
+ this.customTraceId = customTraceId;
36
+ }
37
+ }
32
38
  }
33
39
  JaegerTracer.prototype = {
34
40
  isTracingSupported: function isTracingSupported() {
@@ -38,11 +44,12 @@ JaegerTracer.prototype = {
38
44
  return this._spanId;
39
45
  },
40
46
  getTraceId: function getTraceId() {
47
+ if (this.customTraceId) return this.customTraceId;
41
48
  return this._traceId;
42
49
  },
43
50
  getUberTraceId: function getUberTraceId() {
44
51
  //{trace-id}:{span-id}:{parent-span-id}:{flags}
45
- return this._traceId + ':' + this._spanId + ':' + '0' + ':' + '1';
52
+ return this.getTraceId() + ':' + this.getSpanId() + ':' + '0' + ':' + '1';
46
53
  },
47
54
  makeTracingHeaders: function makeTracingHeaders() {
48
55
  return {
@@ -17,7 +17,7 @@ function uuid() {
17
17
  }
18
18
 
19
19
  /**
20
- *
20
+ *
21
21
  * @param {*} configuration 配置信息
22
22
  * @param {*} requestUrl 请求的url
23
23
  */
@@ -28,6 +28,12 @@ function SkyWalkingTracer(configuration, requestUrl) {
28
28
  this._env = configuration.env;
29
29
  this._version = configuration.version;
30
30
  this._urlParse = (0, _utils.urlParse)(requestUrl).getParse();
31
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
32
+ var customTraceId = configuration.generateTraceId();
33
+ if (typeof customTraceId === 'string') {
34
+ this.customTraceId = customTraceId;
35
+ }
36
+ }
31
37
  }
32
38
  SkyWalkingTracer.prototype = {
33
39
  isTracingSupported: function isTracingSupported() {
@@ -38,12 +44,13 @@ SkyWalkingTracer.prototype = {
38
44
  return this._spanId;
39
45
  },
40
46
  getTraceId: function getTraceId() {
47
+ if (this.customTraceId) return this.customTraceId;
41
48
  return this._traceId;
42
49
  },
43
50
  getSkyWalkingSw8: function getSkyWalkingSw8() {
44
51
  try {
45
- var traceIdStr = String((0, _utils.base64Encode)(this._traceId));
46
- var segmentId = String((0, _utils.base64Encode)(this._spanId));
52
+ var traceIdStr = String((0, _utils.base64Encode)(this.getTraceId()));
53
+ var segmentId = String((0, _utils.base64Encode)(this.getSpanId()));
47
54
  var service = String((0, _utils.base64Encode)(this._applicationId + '_rum_' + this.env));
48
55
  var instance = String((0, _utils.base64Encode)(this._version));
49
56
  var activePage = (0, _utils.getActivePage)();
@@ -62,7 +69,7 @@ SkyWalkingTracer.prototype = {
62
69
  },
63
70
  makeTracingHeaders: function makeTracingHeaders() {
64
71
  return {
65
- 'sw8': this.getSkyWalkingSw8()
72
+ sw8: this.getSkyWalkingSw8()
66
73
  };
67
74
  }
68
75
  };
@@ -55,7 +55,7 @@ function injectHeadersIfTracingAllowed(configuration, context, inject) {
55
55
  var tracer;
56
56
  switch (configuration.traceType) {
57
57
  case _enums.TraceType.DDTRACE:
58
- tracer = new _ddtraceTracer.DDtraceTracer();
58
+ tracer = new _ddtraceTracer.DDtraceTracer(configuration);
59
59
  break;
60
60
  case _enums.TraceType.SKYWALKING_V3:
61
61
  tracer = new _skywalkingTracer.SkyWalkingTracer(configuration, context.url);
@@ -16,13 +16,19 @@ function randomTraceId() {
16
16
  }
17
17
 
18
18
  /**
19
- *
19
+ *
20
20
  * @param {*} configuration 配置信息
21
21
  */
22
22
  function W3cTraceParentTracer(configuration) {
23
23
  var rootSpanId = randomTraceId();
24
24
  this._traceId = randomTraceId() + rootSpanId;
25
25
  this._spanId = rootSpanId;
26
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
27
+ var customTraceId = configuration.generateTraceId();
28
+ if (typeof customTraceId === 'string') {
29
+ this.customTraceId = customTraceId;
30
+ }
31
+ }
26
32
  }
27
33
  W3cTraceParentTracer.prototype = {
28
34
  isTracingSupported: function isTracingSupported() {
@@ -32,15 +38,16 @@ W3cTraceParentTracer.prototype = {
32
38
  return this._spanId;
33
39
  },
34
40
  getTraceId: function getTraceId() {
41
+ if (this.customTraceId) return this.customTraceId;
35
42
  return this._traceId;
36
43
  },
37
44
  getTraceParent: function getTraceParent() {
38
45
  // '{version}-{traceId}-{spanId}-{sampleDecision}'
39
- return '00-' + this._traceId + '-' + this._spanId + '-01';
46
+ return '00-' + this.getTraceId() + '-' + this.getSpanId() + '-01';
40
47
  },
41
48
  makeTracingHeaders: function makeTracingHeaders() {
42
49
  return {
43
- 'traceparent': this.getTraceParent()
50
+ traceparent: this.getTraceParent()
44
51
  };
45
52
  }
46
53
  };
@@ -16,7 +16,7 @@ function randomTraceId() {
16
16
  }
17
17
 
18
18
  /**
19
- *
19
+ *
20
20
  * @param {*} configuration 配置信息
21
21
  */
22
22
  function ZipkinMultiTracer(configuration) {
@@ -28,6 +28,12 @@ function ZipkinMultiTracer(configuration) {
28
28
  this._traceId = rootSpanId;
29
29
  }
30
30
  this._spanId = rootSpanId;
31
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
32
+ var customTraceId = configuration.generateTraceId();
33
+ if (typeof customTraceId === 'string') {
34
+ this.customTraceId = customTraceId;
35
+ }
36
+ }
31
37
  }
32
38
  ZipkinMultiTracer.prototype = {
33
39
  isTracingSupported: function isTracingSupported() {
@@ -37,6 +43,7 @@ ZipkinMultiTracer.prototype = {
37
43
  return this._spanId;
38
44
  },
39
45
  getTraceId: function getTraceId() {
46
+ if (this.customTraceId) return this.customTraceId;
40
47
  return this._traceId;
41
48
  },
42
49
  makeTracingHeaders: function makeTracingHeaders() {
@@ -16,13 +16,19 @@ function randomTraceId() {
16
16
  }
17
17
 
18
18
  /**
19
- *
19
+ *
20
20
  * @param {*} configuration 配置信息
21
21
  */
22
22
  function ZipkinSingleTracer(configuration) {
23
23
  var rootSpanId = randomTraceId();
24
24
  this._traceId = randomTraceId() + rootSpanId;
25
25
  this._spanId = rootSpanId;
26
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
27
+ var customTraceId = configuration.generateTraceId();
28
+ if (typeof customTraceId === 'string') {
29
+ this.customTraceId = customTraceId;
30
+ }
31
+ }
26
32
  }
27
33
  ZipkinSingleTracer.prototype = {
28
34
  isTracingSupported: function isTracingSupported() {
@@ -32,15 +38,16 @@ ZipkinSingleTracer.prototype = {
32
38
  return this._spanId;
33
39
  },
34
40
  getTraceId: function getTraceId() {
41
+ if (this.customTraceId) return this.customTraceId;
35
42
  return this._traceId;
36
43
  },
37
44
  getB3Str: function getB3Str() {
38
45
  //{TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
39
- return this._traceId + '-' + this._spanId + '-1';
46
+ return this.getTraceId() + '-' + this.getSpanId() + '-1';
40
47
  },
41
48
  makeTracingHeaders: function makeTracingHeaders() {
42
49
  return {
43
- 'b3': this.getB3Str()
50
+ b3: this.getB3Str()
44
51
  };
45
52
  }
46
53
  };
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '2.2.2',
2
+ sdkVersion: '2.2.3',
3
3
  sdkName: 'df_uniapp_rum_sdk'
4
4
  };
@@ -58,7 +58,8 @@ export function commonInit(userConfiguration, buildEnv) {
58
58
  sdkName: buildEnv.sdkName,
59
59
  datakitUrl: getDatakitEndPoint(userConfiguration),
60
60
  tags: userConfiguration.tags || [],
61
- injectTraceHeader: userConfiguration.injectTraceHeader && catchUserErrors(userConfiguration.injectTraceHeader, 'injectTraceHeader threw an error:')
61
+ injectTraceHeader: userConfiguration.injectTraceHeader && catchUserErrors(userConfiguration.injectTraceHeader, 'injectTraceHeader threw an error:'),
62
+ generateTraceId: userConfiguration.generateTraceId && catchUserErrors(userConfiguration.generateTraceId, 'generateTraceId threw an error:')
62
63
  };
63
64
  if ('trackInteractions' in userConfiguration) {
64
65
  transportConfiguration.trackInteractions = !!userConfiguration.trackInteractions;
@@ -9,12 +9,18 @@ function randomTraceId() {
9
9
  return n;
10
10
  }
11
11
  /**
12
- *
12
+ *
13
13
  * @param {*} configuration 配置信息
14
14
  */
15
15
  export function DDtraceTracer(configuration) {
16
16
  this._spanId = randomTraceId();
17
17
  this._traceId = randomTraceId();
18
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
19
+ var customTraceId = configuration.generateTraceId();
20
+ if (typeof customTraceId === 'string') {
21
+ this.customTraceId = customTraceId;
22
+ }
23
+ }
18
24
  }
19
25
  DDtraceTracer.prototype = {
20
26
  isTracingSupported: function isTracingSupported() {
@@ -24,6 +30,7 @@ DDtraceTracer.prototype = {
24
30
  return this._spanId;
25
31
  },
26
32
  getTraceId: function getTraceId() {
33
+ if (this.customTraceId) return this.customTraceId;
27
34
  return this._traceId;
28
35
  },
29
36
  makeTracingHeaders: function makeTracingHeaders() {
@@ -10,7 +10,7 @@ function randomTraceId() {
10
10
  }
11
11
 
12
12
  /**
13
- *
13
+ *
14
14
  * @param {*} configuration 配置信息
15
15
  */
16
16
  export function JaegerTracer(configuration) {
@@ -23,6 +23,12 @@ export function JaegerTracer(configuration) {
23
23
  this._traceId = rootSpanId;
24
24
  }
25
25
  this._spanId = rootSpanId;
26
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
27
+ var customTraceId = configuration.generateTraceId();
28
+ if (typeof customTraceId === 'string') {
29
+ this.customTraceId = customTraceId;
30
+ }
31
+ }
26
32
  }
27
33
  JaegerTracer.prototype = {
28
34
  isTracingSupported: function isTracingSupported() {
@@ -32,11 +38,12 @@ JaegerTracer.prototype = {
32
38
  return this._spanId;
33
39
  },
34
40
  getTraceId: function getTraceId() {
41
+ if (this.customTraceId) return this.customTraceId;
35
42
  return this._traceId;
36
43
  },
37
44
  getUberTraceId: function getUberTraceId() {
38
45
  //{trace-id}:{span-id}:{parent-span-id}:{flags}
39
- return this._traceId + ':' + this._spanId + ':' + '0' + ':' + '1';
46
+ return this.getTraceId() + ':' + this.getSpanId() + ':' + '0' + ':' + '1';
40
47
  },
41
48
  makeTracingHeaders: function makeTracingHeaders() {
42
49
  return {
@@ -11,7 +11,7 @@ function uuid() {
11
11
  }
12
12
 
13
13
  /**
14
- *
14
+ *
15
15
  * @param {*} configuration 配置信息
16
16
  * @param {*} requestUrl 请求的url
17
17
  */
@@ -22,6 +22,12 @@ export function SkyWalkingTracer(configuration, requestUrl) {
22
22
  this._env = configuration.env;
23
23
  this._version = configuration.version;
24
24
  this._urlParse = urlParse(requestUrl).getParse();
25
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
26
+ var customTraceId = configuration.generateTraceId();
27
+ if (typeof customTraceId === 'string') {
28
+ this.customTraceId = customTraceId;
29
+ }
30
+ }
25
31
  }
26
32
  SkyWalkingTracer.prototype = {
27
33
  isTracingSupported: function isTracingSupported() {
@@ -32,12 +38,13 @@ SkyWalkingTracer.prototype = {
32
38
  return this._spanId;
33
39
  },
34
40
  getTraceId: function getTraceId() {
41
+ if (this.customTraceId) return this.customTraceId;
35
42
  return this._traceId;
36
43
  },
37
44
  getSkyWalkingSw8: function getSkyWalkingSw8() {
38
45
  try {
39
- var traceIdStr = String(base64Encode(this._traceId));
40
- var segmentId = String(base64Encode(this._spanId));
46
+ var traceIdStr = String(base64Encode(this.getTraceId()));
47
+ var segmentId = String(base64Encode(this.getSpanId()));
41
48
  var service = String(base64Encode(this._applicationId + '_rum_' + this.env));
42
49
  var instance = String(base64Encode(this._version));
43
50
  var activePage = getActivePage();
@@ -56,7 +63,7 @@ SkyWalkingTracer.prototype = {
56
63
  },
57
64
  makeTracingHeaders: function makeTracingHeaders() {
58
65
  return {
59
- 'sw8': this.getSkyWalkingSw8()
66
+ sw8: this.getSkyWalkingSw8()
60
67
  };
61
68
  }
62
69
  };
@@ -47,7 +47,7 @@ export function injectHeadersIfTracingAllowed(configuration, context, inject) {
47
47
  var tracer;
48
48
  switch (configuration.traceType) {
49
49
  case TraceType.DDTRACE:
50
- tracer = new DDtraceTracer();
50
+ tracer = new DDtraceTracer(configuration);
51
51
  break;
52
52
  case TraceType.SKYWALKING_V3:
53
53
  tracer = new SkyWalkingTracer(configuration, context.url);
@@ -10,13 +10,19 @@ function randomTraceId() {
10
10
  }
11
11
 
12
12
  /**
13
- *
13
+ *
14
14
  * @param {*} configuration 配置信息
15
15
  */
16
16
  export function W3cTraceParentTracer(configuration) {
17
17
  var rootSpanId = randomTraceId();
18
18
  this._traceId = randomTraceId() + rootSpanId;
19
19
  this._spanId = rootSpanId;
20
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
21
+ var customTraceId = configuration.generateTraceId();
22
+ if (typeof customTraceId === 'string') {
23
+ this.customTraceId = customTraceId;
24
+ }
25
+ }
20
26
  }
21
27
  W3cTraceParentTracer.prototype = {
22
28
  isTracingSupported: function isTracingSupported() {
@@ -26,15 +32,16 @@ W3cTraceParentTracer.prototype = {
26
32
  return this._spanId;
27
33
  },
28
34
  getTraceId: function getTraceId() {
35
+ if (this.customTraceId) return this.customTraceId;
29
36
  return this._traceId;
30
37
  },
31
38
  getTraceParent: function getTraceParent() {
32
39
  // '{version}-{traceId}-{spanId}-{sampleDecision}'
33
- return '00-' + this._traceId + '-' + this._spanId + '-01';
40
+ return '00-' + this.getTraceId() + '-' + this.getSpanId() + '-01';
34
41
  },
35
42
  makeTracingHeaders: function makeTracingHeaders() {
36
43
  return {
37
- 'traceparent': this.getTraceParent()
44
+ traceparent: this.getTraceParent()
38
45
  };
39
46
  }
40
47
  };
@@ -10,7 +10,7 @@ function randomTraceId() {
10
10
  }
11
11
 
12
12
  /**
13
- *
13
+ *
14
14
  * @param {*} configuration 配置信息
15
15
  */
16
16
  export function ZipkinMultiTracer(configuration) {
@@ -22,6 +22,12 @@ export function ZipkinMultiTracer(configuration) {
22
22
  this._traceId = rootSpanId;
23
23
  }
24
24
  this._spanId = rootSpanId;
25
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
26
+ var customTraceId = configuration.generateTraceId();
27
+ if (typeof customTraceId === 'string') {
28
+ this.customTraceId = customTraceId;
29
+ }
30
+ }
25
31
  }
26
32
  ZipkinMultiTracer.prototype = {
27
33
  isTracingSupported: function isTracingSupported() {
@@ -31,6 +37,7 @@ ZipkinMultiTracer.prototype = {
31
37
  return this._spanId;
32
38
  },
33
39
  getTraceId: function getTraceId() {
40
+ if (this.customTraceId) return this.customTraceId;
34
41
  return this._traceId;
35
42
  },
36
43
  makeTracingHeaders: function makeTracingHeaders() {
@@ -10,13 +10,19 @@ function randomTraceId() {
10
10
  }
11
11
 
12
12
  /**
13
- *
13
+ *
14
14
  * @param {*} configuration 配置信息
15
15
  */
16
16
  export function ZipkinSingleTracer(configuration) {
17
17
  var rootSpanId = randomTraceId();
18
18
  this._traceId = randomTraceId() + rootSpanId;
19
19
  this._spanId = rootSpanId;
20
+ if (configuration.generateTraceId && typeof configuration.generateTraceId === 'function') {
21
+ var customTraceId = configuration.generateTraceId();
22
+ if (typeof customTraceId === 'string') {
23
+ this.customTraceId = customTraceId;
24
+ }
25
+ }
20
26
  }
21
27
  ZipkinSingleTracer.prototype = {
22
28
  isTracingSupported: function isTracingSupported() {
@@ -26,15 +32,16 @@ ZipkinSingleTracer.prototype = {
26
32
  return this._spanId;
27
33
  },
28
34
  getTraceId: function getTraceId() {
35
+ if (this.customTraceId) return this.customTraceId;
29
36
  return this._traceId;
30
37
  },
31
38
  getB3Str: function getB3Str() {
32
39
  //{TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
33
- return this._traceId + '-' + this._spanId + '-1';
40
+ return this.getTraceId() + '-' + this.getSpanId() + '-1';
34
41
  },
35
42
  makeTracingHeaders: function makeTracingHeaders() {
36
43
  return {
37
- 'b3': this.getB3Str()
44
+ b3: this.getB3Str()
38
45
  };
39
46
  }
40
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/rum-uniapp",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "miniprogram": "cjs",