@arms/rum-core 0.0.25-beta.13 → 0.0.25-beta.15

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.
Files changed (51) hide show
  1. package/es/index.d.ts +17 -0
  2. package/es/index.js +17 -0
  3. package/es/model/client.d.ts +20 -0
  4. package/es/model/client.js +73 -0
  5. package/es/model/context.d.ts +18 -0
  6. package/es/model/context.js +38 -0
  7. package/es/model/reporter.d.ts +30 -0
  8. package/es/model/reporter.js +131 -0
  9. package/es/model/shell.d.ts +33 -0
  10. package/es/model/shell.js +80 -0
  11. package/es/style.js +1 -0
  12. package/es/types/client.d.ts +133 -0
  13. package/es/types/client.js +4 -0
  14. package/es/types/collector.d.ts +7 -0
  15. package/es/types/collector.js +1 -0
  16. package/es/types/processor.d.ts +8 -0
  17. package/es/types/processor.js +1 -0
  18. package/es/types/reporter.d.ts +8 -0
  19. package/es/types/reporter.js +1 -0
  20. package/es/types/rum-event.d.ts +163 -0
  21. package/es/types/rum-event.js +24 -0
  22. package/es/types/shell.d.ts +28 -0
  23. package/es/types/shell.js +1 -0
  24. package/es/utils/base.d.ts +39 -0
  25. package/es/utils/base.js +131 -0
  26. package/es/utils/exception.d.ts +7 -0
  27. package/es/utils/exception.js +10 -0
  28. package/es/utils/is.d.ts +12 -0
  29. package/es/utils/is.js +33 -0
  30. package/es/utils/match.d.ts +7 -0
  31. package/es/utils/match.js +37 -0
  32. package/es/utils/number.d.ts +17 -0
  33. package/es/utils/number.js +40 -0
  34. package/es/utils/polyfills.d.ts +7 -0
  35. package/es/utils/polyfills.js +28 -0
  36. package/es/utils/trace.d.ts +28 -0
  37. package/es/utils/trace.js +101 -0
  38. package/lib/model/client.d.ts +2 -2
  39. package/lib/model/client.js +6 -2
  40. package/lib/model/context.d.ts +3 -2
  41. package/lib/model/context.js +6 -1
  42. package/lib/model/reporter.js +3 -1
  43. package/lib/types/client.d.ts +21 -1
  44. package/lib/types/processor.d.ts +1 -0
  45. package/lib/types/rum-event.d.ts +11 -2
  46. package/lib/types/rum-event.js +11 -1
  47. package/lib/utils/base.d.ts +1 -3
  48. package/lib/utils/base.js +2 -10
  49. package/lib/utils/number.d.ts +4 -1
  50. package/lib/utils/number.js +6 -4
  51. package/package.json +4 -3
@@ -0,0 +1,163 @@
1
+ export declare enum RumEventType {
2
+ VIEW = "view",
3
+ RESOURCE = "resource",
4
+ EXCEPTION = "exception",
5
+ LONG_TASK = "longtask",
6
+ ACTION = "action",
7
+ CUSTOM = "custom"
8
+ }
9
+ export interface BaseObject {
10
+ [key: string]: BaseObjectValue;
11
+ }
12
+ export interface IViewData {
13
+ id: string;
14
+ name: string;
15
+ }
16
+ export type BaseObjectPrimitiveValue = string | number | boolean | null | undefined;
17
+ export type BaseObjectValue = BaseObjectPrimitiveValue | BaseObject | BaseObjectPrimitiveValue[] | IViewData;
18
+ export interface RumBaseEvent {
19
+ event_type?: RumEventType;
20
+ event_id?: string;
21
+ timestamp?: number;
22
+ times?: number;
23
+ view?: IViewData;
24
+ snapshots?: string;
25
+ [key: string]: BaseObjectValue;
26
+ }
27
+ export interface RumViewEvent extends RumBaseEvent {
28
+ loading_type?: 'initial_load' | 'route_change';
29
+ type: 'pv' | 'perf' | 'webvitals';
30
+ largest_contentful_paint?: number;
31
+ first_input_delay?: number;
32
+ cumulative_layout_shift?: number;
33
+ first_input_time?: number;
34
+ loading_time?: number;
35
+ first_paint?: number;
36
+ first_contentful_paint?: number;
37
+ dom_interactive?: number;
38
+ dom_content_loaded?: number;
39
+ dom_complete?: number;
40
+ load_event?: number;
41
+ referrer?: string;
42
+ url?: string;
43
+ timing_data?: string;
44
+ }
45
+ /**
46
+ * 枚举值,表示资源是否加载成功
47
+ */
48
+ export declare enum ResourceStatus {
49
+ Unknown = -1,
50
+ Failed = 0,
51
+ Success = 1
52
+ }
53
+ export interface RumResourceEvent extends RumBaseEvent {
54
+ name?: string;
55
+ type?: string;
56
+ method?: string;
57
+ status_code?: number | string;
58
+ message?: string;
59
+ success?: -1 | 0 | 1 | ResourceStatus;
60
+ trace_id?: string;
61
+ duration?: number;
62
+ size?: number;
63
+ connect_duration?: number;
64
+ ssl_duration?: number;
65
+ dns_duration?: number;
66
+ redirect_duration?: number;
67
+ first_byte_duration?: number;
68
+ download_duration?: number;
69
+ url?: string;
70
+ timing_data?: string;
71
+ tracing_data?: string;
72
+ }
73
+ export interface RumExceptionEvent extends RumBaseEvent {
74
+ source?: string;
75
+ type?: 'crash' | 'custom' | 'error' | 'blank';
76
+ name?: string;
77
+ message?: string;
78
+ file?: string;
79
+ stack?: string;
80
+ line?: number;
81
+ column?: number;
82
+ }
83
+ export interface RumLongTaskEvent extends RumBaseEvent {
84
+ view_name: string;
85
+ source?: string;
86
+ type?: string;
87
+ message?: string;
88
+ count: number;
89
+ stack?: string;
90
+ caused_by?: string;
91
+ }
92
+ export interface RumActionEvent extends RumBaseEvent {
93
+ type?: string;
94
+ name?: string;
95
+ target_name?: string;
96
+ duration?: number;
97
+ }
98
+ export interface RumCustomEvent extends RumBaseEvent {
99
+ type: string;
100
+ name: string;
101
+ group?: string;
102
+ value: number;
103
+ }
104
+ export type RumEvent = RumViewEvent | RumResourceEvent | RumExceptionEvent | RumActionEvent | RumCustomEvent;
105
+ export declare enum AppType {
106
+ browser = "browser",
107
+ miniapp = "miniapp",
108
+ uniapp = "uniapp"
109
+ }
110
+ export interface RumEventBundle {
111
+ app: {
112
+ id: string;
113
+ type: AppType;
114
+ name?: string;
115
+ version?: string;
116
+ channel?: string;
117
+ env?: string;
118
+ package?: string;
119
+ };
120
+ user: {
121
+ id: string;
122
+ name?: string;
123
+ tags?: string;
124
+ };
125
+ session: {
126
+ id: string;
127
+ };
128
+ view: {
129
+ id: string;
130
+ name: string;
131
+ };
132
+ device?: {
133
+ id?: string;
134
+ type?: string;
135
+ brand?: string;
136
+ model?: string;
137
+ name?: string;
138
+ };
139
+ os?: {
140
+ type?: string;
141
+ version?: string;
142
+ container?: string;
143
+ container_version?: string;
144
+ };
145
+ geo?: {
146
+ country?: string;
147
+ country_id?: string;
148
+ province?: string;
149
+ province_id?: string;
150
+ city?: string;
151
+ city_id?: string;
152
+ };
153
+ isp?: {
154
+ id?: string;
155
+ name?: string;
156
+ };
157
+ net?: {
158
+ model?: string;
159
+ name?: string;
160
+ };
161
+ events: Array<RumEvent>;
162
+ _v: string;
163
+ }
@@ -0,0 +1,24 @@
1
+ export var RumEventType = /*#__PURE__*/function (RumEventType) {
2
+ RumEventType["VIEW"] = "view";
3
+ RumEventType["RESOURCE"] = "resource";
4
+ RumEventType["EXCEPTION"] = "exception";
5
+ RumEventType["LONG_TASK"] = "longtask";
6
+ RumEventType["ACTION"] = "action";
7
+ RumEventType["CUSTOM"] = "custom";
8
+ return RumEventType;
9
+ }({});
10
+ /**
11
+ * 枚举值,表示资源是否加载成功
12
+ */
13
+ export var ResourceStatus = /*#__PURE__*/function (ResourceStatus) {
14
+ ResourceStatus[ResourceStatus["Unknown"] = -1] = "Unknown";
15
+ ResourceStatus[ResourceStatus["Failed"] = 0] = "Failed";
16
+ ResourceStatus[ResourceStatus["Success"] = 1] = "Success";
17
+ return ResourceStatus;
18
+ }({});
19
+ export var AppType = /*#__PURE__*/function (AppType) {
20
+ AppType["browser"] = "browser";
21
+ AppType["miniapp"] = "miniapp";
22
+ AppType["uniapp"] = "uniapp";
23
+ return AppType;
24
+ }({});
@@ -0,0 +1,28 @@
1
+ import { IConfiguration } from "./client";
2
+ import { RumEvent } from "./rum-event";
3
+ /**
4
+ * 每个 sdk shell 导出固定需要实现的基础 api
5
+ * 对外导出 shell 层, 所有 shell 层模型的 API 设计约定:
6
+ * 1. API 命名空间按照 variables / functions / events 来组织
7
+ * 2. 事件(events)的命名格式为:on[Will|Did]VerbNoun?,参考 https://code.visualstudio.com/api/references/vscode-api#events
8
+ * 3. 基于 Disposable 模式,对于事件的绑定、快捷键的绑定函数,返回值则是解绑函数
9
+ */
10
+ export interface IShell {
11
+ /**
12
+ * 初始化
13
+ */
14
+ init(configuration: IConfiguration): void;
15
+ /**
16
+ * 自定义上传数据
17
+ */
18
+ sendEvent(payload: RumEvent): void;
19
+ /**
20
+ * get config
21
+ */
22
+ getConfig(): IConfiguration;
23
+ /**
24
+ * set config
25
+ */
26
+ setConfig<T extends keyof IConfiguration>(key: T, value: IConfiguration[T]): void;
27
+ setConfig(value: IConfiguration): void;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * 劫持函数
3
+ */
4
+ export declare function interceptFunction(target: any, name: string, callback: Function): void;
5
+ /**
6
+ * @description: GUID v4
7
+ * @return {String}
8
+ */
9
+ export declare function generateGUID(): string;
10
+ /**
11
+ * @description: 随机生成 traceId 或 sessionId
12
+ * @return {String}
13
+ */
14
+ export declare function generateTraceId(): string;
15
+ /**
16
+ * @description: 随机生成 spanId
17
+ * @param len {number}
18
+ * @param radix {number}
19
+ * @return {String}
20
+ */
21
+ export declare function generateSpanId(len?: number, radix?: number): string;
22
+ /**
23
+ * @description: 随机生成 eventId
24
+ * @param sessionId {string} sessionId
25
+ * @return {String}
26
+ */
27
+ export declare function generateEventId(sessionId: string): string;
28
+ /**
29
+ * @desc 函数防抖
30
+ * @param func 回调函数
31
+ * @param wait 延迟执行毫秒数
32
+ */
33
+ export declare function debounce(func: Function, wait: number): () => void;
34
+ /**
35
+ * @desc 函数延迟执行
36
+ * @param func 回调函数
37
+ * @param wait 延迟执行毫秒数
38
+ */
39
+ export declare function delay(func: Function, wait: number, ...args: any[]): number;
@@ -0,0 +1,131 @@
1
+ import { isFunction } from "./is";
2
+
3
+ /**
4
+ * 劫持函数
5
+ */
6
+ export function interceptFunction(target, name, callback) {
7
+ var registeredMethod = target[name];
8
+ target[name] = function () {
9
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10
+ args[_key] = arguments[_key];
11
+ }
12
+ callback.apply(this, args);
13
+ if (registeredMethod) {
14
+ return registeredMethod.apply(this, args);
15
+ }
16
+ };
17
+ }
18
+
19
+ /**
20
+ * @description: GUID v4
21
+ * @return {String}
22
+ */
23
+ export function generateGUID() {
24
+ var guid = '';
25
+ try {
26
+ if (crypto && crypto.randomUUID) {
27
+ guid = crypto.randomUUID();
28
+ } else if (crypto && crypto.getRandomValues) {
29
+ var buf = new Uint8Array(16);
30
+ crypto.getRandomValues(buf);
31
+ buf[6] = buf[6] & 0x0f | 0x40; // version 4 UUID
32
+ buf[8] = buf[8] & 0x3f | 0x80; // variant 10xxxxxx
33
+ guid = buf.reduce(function (str, _byte) {
34
+ return str + _byte.toString(16).padStart(2, '0');
35
+ }, '').replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, '\$1-\$2-\$3-\$4-\$5');
36
+ }
37
+ } catch (e) {
38
+ //
39
+ }
40
+ if (!guid) {
41
+ guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
42
+ var r = Math.random() * 16 | 0,
43
+ v = c == 'x' ? r : r & 0x3 | 0x8;
44
+ return v.toString(16);
45
+ });
46
+ }
47
+ return guid;
48
+ }
49
+
50
+ /**
51
+ * @description: 随机生成 traceId 或 sessionId
52
+ * @return {String}
53
+ */
54
+ export function generateTraceId() {
55
+ var traceId = generateGUID().replace(/-/g, '');
56
+ // 适配OpenTracing 实现(long long转成16进制最高位不能为0)
57
+ if (traceId[0] === '0') {
58
+ traceId = '1' + traceId.substring(1);
59
+ }
60
+ if (traceId[16] === '0') {
61
+ traceId = traceId.substring(0, 16) + '1' + traceId.substring(17);
62
+ }
63
+ return traceId;
64
+ }
65
+
66
+ /**
67
+ * @description: 随机生成 spanId
68
+ * @param len {number}
69
+ * @param radix {number}
70
+ * @return {String}
71
+ */
72
+ export function generateSpanId(len, radix) {
73
+ if (len === void 0) {
74
+ len = 16;
75
+ }
76
+ if (radix === void 0) {
77
+ radix = 16;
78
+ }
79
+ var result = '';
80
+ for (var i = 0; i < len; i++) {
81
+ result += Math.floor(Math.random() * radix).toString(radix);
82
+ }
83
+ return result;
84
+ }
85
+
86
+ /**
87
+ * @description: 随机生成 eventId
88
+ * @param sessionId {string} sessionId
89
+ * @return {String}
90
+ */
91
+ export function generateEventId(sessionId) {
92
+ var spanId = generateSpanId();
93
+ return "00-" + sessionId + "-" + spanId;
94
+ }
95
+
96
+ /**
97
+ * @desc 函数防抖
98
+ * @param func 回调函数
99
+ * @param wait 延迟执行毫秒数
100
+ */
101
+ export function debounce(func, wait) {
102
+ var timer;
103
+ if (!isFunction(func)) {
104
+ return;
105
+ }
106
+ return function () {
107
+ var context = this;
108
+ var args = arguments;
109
+ if (timer) {
110
+ clearTimeout(timer);
111
+ }
112
+ timer = setTimeout(function () {
113
+ func.apply(context, args);
114
+ }, wait);
115
+ };
116
+ }
117
+
118
+ /**
119
+ * @desc 函数延迟执行
120
+ * @param func 回调函数
121
+ * @param wait 延迟执行毫秒数
122
+ */
123
+ export function delay(func, wait) {
124
+ if (!isFunction(func)) {
125
+ return;
126
+ }
127
+ for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
128
+ args[_key2 - 2] = arguments[_key2];
129
+ }
130
+ return setTimeout.apply(void 0, [func, +wait || 0].concat(args));
131
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 获取错误对象唯一标识
3
+ */
4
+ export declare const getErrorID: (error: {
5
+ message?: string;
6
+ stack?: string;
7
+ }) => string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 获取错误对象唯一标识
3
+ */
4
+ export var getErrorID = function getErrorID(error) {
5
+ var _error$message = error.message,
6
+ message = _error$message === void 0 ? '' : _error$message,
7
+ _error$stack = error.stack,
8
+ stack = _error$stack === void 0 ? '' : _error$stack;
9
+ return message + stack;
10
+ };
@@ -0,0 +1,12 @@
1
+ export type IsFnHelper<T = unknown> = (value: unknown) => value is T;
2
+ export declare function isTypeof<T = unknown>(value: unknown, type: string): value is T;
3
+ export declare const isFunction: (func: any) => boolean;
4
+ export declare const isUndefined: IsFnHelper<undefined>;
5
+ export declare const isString: IsFnHelper<string>;
6
+ export declare function isToString<T = unknown>(value: unknown, type: string): value is T;
7
+ export declare const isArray: IsFnHelper<unknown[]>;
8
+ export declare const isRegExp: IsFnHelper<string>;
9
+ export declare const isBoolean: IsFnHelper<boolean>;
10
+ export declare const isNumber: IsFnHelper<number | bigint>;
11
+ export declare const isNull: IsFnHelper<null>;
12
+ export declare const isObject: IsFnHelper<object>;
package/es/utils/is.js ADDED
@@ -0,0 +1,33 @@
1
+ export function isTypeof(value, type) {
2
+ return typeof value === type;
3
+ }
4
+ export var isFunction = function isFunction(func) {
5
+ return typeof func === 'function';
6
+ };
7
+ export var isUndefined = function isUndefined(value) {
8
+ return isTypeof(value, 'undefined');
9
+ };
10
+ export var isString = function isString(value) {
11
+ return isTypeof(value, 'string');
12
+ };
13
+ export function isToString(value, type) {
14
+ return Object.prototype.toString.call(value) === "[object " + type + "]";
15
+ }
16
+ export var isArray = function isArray(value) {
17
+ return isToString(value, 'Array');
18
+ };
19
+ export var isRegExp = function isRegExp(value) {
20
+ return isToString(value, 'RegExp');
21
+ };
22
+ export var isBoolean = function isBoolean(value) {
23
+ return isTypeof(value, 'boolean');
24
+ };
25
+ export var isNumber = function isNumber(value) {
26
+ return isTypeof(value, 'number') && !isNaN(value) || isTypeof(value, 'bigint');
27
+ };
28
+ export var isNull = function isNull(value) {
29
+ return isTypeof(value, 'null');
30
+ };
31
+ export var isObject = function isObject(value) {
32
+ return !isNull(value) && isTypeof(value, 'object');
33
+ };
@@ -0,0 +1,7 @@
1
+ export type MatchOption = string | RegExp | ((value: string) => boolean);
2
+ export declare function isMatchOption(item: unknown): item is MatchOption;
3
+ /**
4
+ * 如果值有一个选项匹配,则返回true。在比较字符串时,useStartsWith: true时将把值与选项的开始进行比较,而不是要求精确匹配。
5
+ */
6
+ export declare function matchList(list: MatchOption[], value: string, useStartsWith?: boolean): boolean;
7
+ export declare function urlMatch(url: string, list?: MatchOption[]): boolean;
@@ -0,0 +1,37 @@
1
+ import { isFunction, isRegExp, isString } from "./is";
2
+ import { startsWith } from "./polyfills";
3
+ export function isMatchOption(item) {
4
+ return isString(item) || isFunction(item) || isRegExp(item);
5
+ }
6
+
7
+ /**
8
+ * 如果值有一个选项匹配,则返回true。在比较字符串时,useStartsWith: true时将把值与选项的开始进行比较,而不是要求精确匹配。
9
+ */
10
+ export function matchList(list, value, useStartsWith) {
11
+ if (useStartsWith === void 0) {
12
+ useStartsWith = true;
13
+ }
14
+ return list.some(function (item) {
15
+ try {
16
+ if (typeof item === 'function') {
17
+ return item(value);
18
+ } else if (item instanceof RegExp) {
19
+ return item.test(value);
20
+ } else if (typeof item === 'string') {
21
+ return useStartsWith ? startsWith(value, item) : item === value;
22
+ }
23
+ } catch (e) {}
24
+ return false;
25
+ });
26
+ }
27
+ export function urlMatch(url, list) {
28
+ if (list === void 0) {
29
+ list = [];
30
+ }
31
+ try {
32
+ var rules = [/https?:\/\/.*rum|retcode\.aliyuncs\.com/, /https?:\/\/.*log-global\.aliyuncs\.com/, /https?:\/\/.*\.mmstat\.com/].concat(list);
33
+ return matchList(rules, url);
34
+ } catch (e) {
35
+ return false;
36
+ }
37
+ }
@@ -0,0 +1,17 @@
1
+ export declare const ONE_SECOND = 1000;
2
+ export declare const ONE_MINUTE: number;
3
+ export declare const ONE_HOUR: number;
4
+ export declare const ONE_DAY: number;
5
+ /**
6
+ * Return true if the draw is successful
7
+ * @param threshold between 0 and 100
8
+ */
9
+ export declare function performDraw(threshold: number): boolean;
10
+ /**
11
+ * 保留指定位数的小数
12
+ * @param num 原数据
13
+ * @param decimal 小数位数
14
+ * @param min 限制最小值,否则返回undefined
15
+ * @returns
16
+ */
17
+ export declare function formatNumber(num: number, decimal?: number, min?: number): number;
@@ -0,0 +1,40 @@
1
+ export var ONE_SECOND = 1e3;
2
+ export var ONE_MINUTE = 60 * ONE_SECOND;
3
+ export var ONE_HOUR = 60 * ONE_MINUTE;
4
+ export var ONE_DAY = 24 * ONE_HOUR;
5
+
6
+ /**
7
+ * Return true if the draw is successful
8
+ * @param threshold between 0 and 100
9
+ */
10
+ export function performDraw(threshold) {
11
+ return threshold !== 0 && Math.random() * 100 <= threshold;
12
+ }
13
+
14
+ /**
15
+ * 保留指定位数的小数
16
+ * @param num 原数据
17
+ * @param decimal 小数位数
18
+ * @param min 限制最小值,否则返回undefined
19
+ * @returns
20
+ */
21
+ export function formatNumber(num, decimal, min) {
22
+ if (decimal === void 0) {
23
+ decimal = 3;
24
+ }
25
+ if (min === void 0) {
26
+ min = 0;
27
+ }
28
+ if (!num) {
29
+ return num;
30
+ }
31
+ var str = num.toString();
32
+ var index = str.indexOf('.');
33
+ if (index !== -1) {
34
+ str = str.substring(0, decimal + index + 1);
35
+ } else {
36
+ str = str.substring(0);
37
+ }
38
+ var result = parseFloat(str);
39
+ return result >= min ? result : undefined;
40
+ }
@@ -0,0 +1,7 @@
1
+ export declare function find<T, S extends T>(array: ArrayLike<T>, predicate: (item: T, index: number) => item is S): S | undefined;
2
+ export declare function find<T>(array: ArrayLike<T>, predicate: (item: T, index: number) => boolean): T | undefined;
3
+ export declare function startsWith(candidate: string, search: string): boolean;
4
+ export declare function endsWith(candidate: string, search: string): boolean;
5
+ export declare function assign<T, U>(target: T, source: U): T & U;
6
+ export declare function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
7
+ export declare function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
@@ -0,0 +1,28 @@
1
+ export function find(array, predicate) {
2
+ for (var i = 0; i < array.length; i += 1) {
3
+ var item = array[i];
4
+ if (predicate(item, i)) {
5
+ return item;
6
+ }
7
+ }
8
+ return undefined;
9
+ }
10
+ export function startsWith(candidate, search) {
11
+ return candidate.slice(0, search.length) === search;
12
+ }
13
+ export function endsWith(candidate, search) {
14
+ return candidate.slice(-search.length) === search;
15
+ }
16
+ export function assign(target) {
17
+ for (var _len = arguments.length, toAssign = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
18
+ toAssign[_key - 1] = arguments[_key];
19
+ }
20
+ toAssign.forEach(function (source) {
21
+ for (var _key2 in source) {
22
+ if (Object.prototype.hasOwnProperty.call(source, _key2)) {
23
+ target[_key2] = source[_key2];
24
+ }
25
+ }
26
+ });
27
+ return target;
28
+ }
@@ -0,0 +1,28 @@
1
+ import { MatchOption } from "./match";
2
+ export type PropagatorType = 'tracecontext' | 'b3' | 'b3multi' | 'jaeger' | 'sw8';
3
+ export type TraceOption = {
4
+ match: MatchOption;
5
+ propagatorTypes: PropagatorType[];
6
+ };
7
+ export declare function isTraceOption(option: any): option is TraceOption;
8
+ export interface ITracingOption {
9
+ enable?: boolean;
10
+ sample?: number | undefined;
11
+ propagatorTypes?: PropagatorType[];
12
+ allowedUrls?: Array<MatchOption | TraceOption> | undefined;
13
+ tracestate?: boolean;
14
+ baggage?: boolean;
15
+ }
16
+ export interface ITracingHeaders {
17
+ [key: string]: string;
18
+ }
19
+ export interface TraceSubOption {
20
+ tracestate?: string;
21
+ baggage?: string;
22
+ appId?: string;
23
+ appVersion?: string;
24
+ viewName?: string;
25
+ host?: string;
26
+ }
27
+ export declare function makeTracingHeaders(traceId: string, spanId: string, sampled: boolean, propagatorTypes: PropagatorType[], subOption?: TraceSubOption): ITracingHeaders;
28
+ export declare function parseTracingOptions(tracingOption: boolean | ITracingOption): ITracingOption;