@grafana/faro-core 1.19.0 → 2.0.0-beta-2
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.
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/apiTestHelpers.d.ts +2 -0
- package/dist/bundle/types/api/events/initialize.d.ts +4 -6
- package/dist/bundle/types/api/exceptions/initialize.d.ts +4 -6
- package/dist/bundle/types/api/index.d.ts +2 -3
- package/dist/bundle/types/api/initialize.d.ts +1 -3
- package/dist/bundle/types/api/logs/initialize.d.ts +4 -6
- package/dist/bundle/types/api/measurements/initialize.d.ts +4 -6
- package/dist/bundle/types/api/meta/initialize.d.ts +1 -5
- package/dist/bundle/types/api/types.d.ts +3 -44
- package/dist/bundle/types/api/userActions/const.d.ts +6 -0
- package/dist/bundle/types/api/userActions/index.d.ts +3 -0
- package/dist/bundle/types/api/userActions/initialize.d.ts +10 -0
- package/dist/bundle/types/api/userActions/types.d.ts +45 -0
- package/dist/bundle/types/api/userActions/userAction.d.ts +41 -0
- package/dist/bundle/types/index.d.ts +2 -2
- package/dist/bundle/types/semantic.d.ts +0 -14
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/apiTestHelpers.js +5 -1
- package/dist/cjs/api/apiTestHelpers.js.map +1 -1
- package/dist/cjs/api/events/initialize.js +4 -5
- package/dist/cjs/api/events/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/initialize.js +6 -7
- package/dist/cjs/api/exceptions/initialize.js.map +1 -1
- package/dist/cjs/api/index.js +5 -8
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/cjs/api/initialize.js +8 -8
- package/dist/cjs/api/initialize.js.map +1 -1
- package/dist/cjs/api/logs/initialize.js +6 -7
- package/dist/cjs/api/logs/initialize.js.map +1 -1
- package/dist/cjs/api/measurements/initialize.js +4 -5
- package/dist/cjs/api/measurements/initialize.js.map +1 -1
- package/dist/cjs/api/meta/initialize.js.map +1 -1
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/api/userActions/const.js +11 -0
- package/dist/cjs/api/userActions/const.js.map +1 -0
- package/dist/cjs/api/userActions/index.js +11 -0
- package/dist/cjs/api/userActions/index.js.map +1 -0
- package/dist/cjs/api/userActions/initialize.js +57 -0
- package/dist/cjs/api/userActions/initialize.js.map +1 -0
- package/dist/cjs/api/userActions/types.js +11 -0
- package/dist/cjs/api/userActions/types.js.map +1 -0
- package/dist/cjs/api/userActions/userAction.js +165 -0
- package/dist/cjs/api/userActions/userAction.js.map +1 -0
- package/dist/cjs/index.js +5 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/semantic.js +1 -15
- package/dist/cjs/semantic.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/apiTestHelpers.js +4 -0
- package/dist/esm/api/apiTestHelpers.js.map +1 -1
- package/dist/esm/api/events/initialize.js +4 -5
- package/dist/esm/api/events/initialize.js.map +1 -1
- package/dist/esm/api/exceptions/initialize.js +4 -5
- package/dist/esm/api/exceptions/initialize.js.map +1 -1
- package/dist/esm/api/index.js +1 -2
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/initialize.js +8 -7
- package/dist/esm/api/initialize.js.map +1 -1
- package/dist/esm/api/logs/initialize.js +4 -5
- package/dist/esm/api/logs/initialize.js.map +1 -1
- package/dist/esm/api/measurements/initialize.js +4 -5
- package/dist/esm/api/measurements/initialize.js.map +1 -1
- package/dist/esm/api/meta/initialize.js.map +1 -1
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/api/userActions/const.js +8 -0
- package/dist/esm/api/userActions/const.js.map +1 -0
- package/dist/esm/api/userActions/index.js +4 -0
- package/dist/esm/api/userActions/index.js.map +1 -0
- package/dist/esm/api/userActions/initialize.js +50 -0
- package/dist/esm/api/userActions/initialize.js.map +1 -0
- package/dist/esm/api/userActions/types.js +10 -0
- package/dist/esm/api/userActions/types.js.map +1 -0
- package/dist/esm/api/userActions/userAction.js +132 -0
- package/dist/esm/api/userActions/userAction.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/semantic.js +0 -14
- package/dist/esm/semantic.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/apiTestHelpers.js +5 -1
- package/dist/spec/core/src/api/apiTestHelpers.js.map +1 -1
- package/dist/spec/core/src/api/events/initialize.js +4 -5
- package/dist/spec/core/src/api/events/initialize.js.map +1 -1
- package/dist/spec/core/src/api/events/initialize.test.js +11 -33
- package/dist/spec/core/src/api/events/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +6 -7
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +24 -52
- package/dist/spec/core/src/api/exceptions/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/index.js +5 -8
- package/dist/spec/core/src/api/index.js.map +1 -1
- package/dist/spec/core/src/api/initialize.js +8 -8
- package/dist/spec/core/src/api/initialize.js.map +1 -1
- package/dist/spec/core/src/api/initialize.test.js +0 -50
- package/dist/spec/core/src/api/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.js +6 -7
- package/dist/spec/core/src/api/logs/initialize.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.test.js +12 -73
- package/dist/spec/core/src/api/logs/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.js +4 -5
- package/dist/spec/core/src/api/measurements/initialize.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.test.js +10 -72
- package/dist/spec/core/src/api/measurements/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/meta/initialize.js.map +1 -1
- package/dist/spec/core/src/api/types.js.map +1 -1
- package/dist/spec/core/src/api/userActions/const.js +11 -0
- package/dist/spec/core/src/api/userActions/const.js.map +1 -0
- package/dist/spec/core/src/api/userActions/index.js +11 -0
- package/dist/spec/core/src/api/userActions/index.js.map +1 -0
- package/dist/spec/core/src/api/userActions/initialize.js +57 -0
- package/dist/spec/core/src/api/userActions/initialize.js.map +1 -0
- package/dist/spec/core/src/api/userActions/initialize.test.js +62 -0
- package/dist/spec/core/src/api/userActions/initialize.test.js.map +1 -0
- package/dist/spec/core/src/api/userActions/types.js +11 -0
- package/dist/spec/core/src/api/userActions/types.js.map +1 -0
- package/dist/spec/core/src/api/userActions/userAction.js +165 -0
- package/dist/spec/core/src/api/userActions/userAction.js.map +1 -0
- package/dist/spec/core/src/api/userActions/userAction.test.js +75 -0
- package/dist/spec/core/src/api/userActions/userAction.test.js.map +1 -0
- package/dist/spec/core/src/index.js +5 -7
- package/dist/spec/core/src/index.js.map +1 -1
- package/dist/spec/core/src/semantic.js +1 -15
- package/dist/spec/core/src/semantic.js.map +1 -1
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/apiTestHelpers.d.ts +2 -0
- package/dist/types/api/events/initialize.d.ts +4 -6
- package/dist/types/api/exceptions/initialize.d.ts +4 -6
- package/dist/types/api/index.d.ts +2 -3
- package/dist/types/api/initialize.d.ts +1 -3
- package/dist/types/api/logs/initialize.d.ts +4 -6
- package/dist/types/api/measurements/initialize.d.ts +4 -6
- package/dist/types/api/meta/initialize.d.ts +1 -5
- package/dist/types/api/types.d.ts +3 -44
- package/dist/types/api/userActions/const.d.ts +6 -0
- package/dist/types/api/userActions/index.d.ts +3 -0
- package/dist/types/api/userActions/initialize.d.ts +10 -0
- package/dist/types/api/userActions/types.d.ts +45 -0
- package/dist/types/api/userActions/userAction.d.ts +41 -0
- package/dist/types/core/src/api/apiTestHelpers.d.ts +2 -0
- package/dist/types/core/src/api/events/initialize.d.ts +4 -6
- package/dist/types/core/src/api/exceptions/initialize.d.ts +4 -6
- package/dist/types/core/src/api/index.d.ts +2 -3
- package/dist/types/core/src/api/initialize.d.ts +1 -3
- package/dist/types/core/src/api/logs/initialize.d.ts +4 -6
- package/dist/types/core/src/api/measurements/initialize.d.ts +4 -6
- package/dist/types/core/src/api/meta/initialize.d.ts +1 -5
- package/dist/types/core/src/api/types.d.ts +3 -44
- package/dist/types/core/src/api/userActions/const.d.ts +6 -0
- package/dist/types/core/src/api/userActions/index.d.ts +3 -0
- package/dist/types/core/src/api/userActions/initialize.d.ts +10 -0
- package/dist/types/core/src/api/userActions/types.d.ts +45 -0
- package/dist/types/core/src/api/userActions/userAction.d.ts +41 -0
- package/dist/types/core/src/api/userActions/userAction.test.d.ts +1 -0
- package/dist/types/core/src/index.d.ts +2 -2
- package/dist/types/core/src/semantic.d.ts +0 -14
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/semantic.d.ts +0 -14
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/dist/bundle/types/api/const.d.ts +0 -4
- package/dist/bundle/types/api/userActionLifecycleHandler.d.ts +0 -13
- package/dist/cjs/api/const.js +0 -8
- package/dist/cjs/api/const.js.map +0 -1
- package/dist/cjs/api/userActionLifecycleHandler.js +0 -58
- package/dist/cjs/api/userActionLifecycleHandler.js.map +0 -1
- package/dist/esm/api/const.js +0 -5
- package/dist/esm/api/const.js.map +0 -1
- package/dist/esm/api/userActionLifecycleHandler.js +0 -43
- package/dist/esm/api/userActionLifecycleHandler.js.map +0 -1
- package/dist/spec/core/src/api/const.js +0 -8
- package/dist/spec/core/src/api/const.js.map +0 -1
- package/dist/spec/core/src/api/userActionLifecycleHandler.js +0 -58
- package/dist/spec/core/src/api/userActionLifecycleHandler.js.map +0 -1
- package/dist/spec/core/src/api/userActionLifecycleHandler.test.js +0 -169
- package/dist/spec/core/src/api/userActionLifecycleHandler.test.js.map +0 -1
- package/dist/types/api/const.d.ts +0 -4
- package/dist/types/api/userActionLifecycleHandler.d.ts +0 -13
- package/dist/types/core/src/api/const.d.ts +0 -4
- package/dist/types/core/src/api/userActionLifecycleHandler.d.ts +0 -13
- /package/dist/types/core/src/api/{userActionLifecycleHandler.test.d.ts → userActions/initialize.test.d.ts} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type TransportItem } from '../../transports';
|
|
2
|
+
import { UserActionSeverity, userActionStartByApiCallEventName } from './const';
|
|
3
|
+
export declare enum UserActionState {
|
|
4
|
+
Started = 0,
|
|
5
|
+
Halted = 1,
|
|
6
|
+
Cancelled = 2,
|
|
7
|
+
Ended = 3
|
|
8
|
+
}
|
|
9
|
+
export type HaltPredicate = () => boolean;
|
|
10
|
+
export interface UserActionInterface {
|
|
11
|
+
name: string;
|
|
12
|
+
parentId: string;
|
|
13
|
+
addItem(item: TransportItem): void;
|
|
14
|
+
extend(haltPredicate?: HaltPredicate): void;
|
|
15
|
+
end(attributes?: Record<string, string>): void;
|
|
16
|
+
halt(reason?: string): void;
|
|
17
|
+
cancel(): void;
|
|
18
|
+
getState(): UserActionState;
|
|
19
|
+
}
|
|
20
|
+
export type ApiUserActionEvent = {
|
|
21
|
+
name: string;
|
|
22
|
+
attributes?: Record<string, string>;
|
|
23
|
+
type: typeof userActionStartByApiCallEventName | string;
|
|
24
|
+
};
|
|
25
|
+
export type EndUserActionProps = {
|
|
26
|
+
userActionName: string;
|
|
27
|
+
startTime: number;
|
|
28
|
+
endTime: number;
|
|
29
|
+
actionId: string;
|
|
30
|
+
event: ApiUserActionEvent;
|
|
31
|
+
attributes?: Record<string, string>;
|
|
32
|
+
};
|
|
33
|
+
export type StartUserActionOptions = {
|
|
34
|
+
triggerName?: string;
|
|
35
|
+
severity?: UserActionSeverity;
|
|
36
|
+
};
|
|
37
|
+
export interface UserActionsAPI {
|
|
38
|
+
startUserAction: (name: string, attributes?: Record<string, string>, options?: StartUserActionOptions) => UserActionInterface | undefined;
|
|
39
|
+
getActiveUserAction: () => UserActionInterface | undefined;
|
|
40
|
+
}
|
|
41
|
+
export type UserActionStart = {
|
|
42
|
+
type: 'user_action_start';
|
|
43
|
+
userAction: UserActionInterface;
|
|
44
|
+
};
|
|
45
|
+
export type UserActionMessage = UserActionStart;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type TransportItem, type Transports } from '../../transports';
|
|
2
|
+
import { Observable } from '../../utils';
|
|
3
|
+
import { type APIEvent } from '../types';
|
|
4
|
+
import { UserActionSeverity } from './const';
|
|
5
|
+
import { type HaltPredicate, type UserActionInterface, UserActionState } from './types';
|
|
6
|
+
export default class UserAction extends Observable implements UserActionInterface {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string;
|
|
9
|
+
attributes?: Record<string, string>;
|
|
10
|
+
parentId: string;
|
|
11
|
+
trigger: string;
|
|
12
|
+
severity: UserActionSeverity;
|
|
13
|
+
startTime?: number;
|
|
14
|
+
trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;
|
|
15
|
+
cancelTimeout: number;
|
|
16
|
+
haltTimeout: number;
|
|
17
|
+
private _state;
|
|
18
|
+
private _timeoutId?;
|
|
19
|
+
private _itemBuffer;
|
|
20
|
+
private _transports;
|
|
21
|
+
private _haltTimeoutId;
|
|
22
|
+
private _isValid;
|
|
23
|
+
constructor({ name, parentId, haltTimeout, trigger, transports, attributes, trackUserActionsExcludeItem, severity, }: {
|
|
24
|
+
name: string;
|
|
25
|
+
transports: Transports;
|
|
26
|
+
parentId?: string;
|
|
27
|
+
trigger: string;
|
|
28
|
+
attributes?: Record<string, string>;
|
|
29
|
+
haltTimeout?: number;
|
|
30
|
+
trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;
|
|
31
|
+
severity?: UserActionSeverity;
|
|
32
|
+
});
|
|
33
|
+
addItem(item: TransportItem): void;
|
|
34
|
+
extend(haltPredicate?: HaltPredicate): void;
|
|
35
|
+
private _setFollowupActionTimeout;
|
|
36
|
+
private _start;
|
|
37
|
+
halt(): void;
|
|
38
|
+
cancel(): void;
|
|
39
|
+
end(): void;
|
|
40
|
+
getState(): UserActionState;
|
|
41
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Transports } from '../transports';
|
|
2
2
|
import type { TracesAPI } from './traces/types';
|
|
3
|
+
import type { UserActionsAPI } from './userActions/types';
|
|
3
4
|
export declare const mockMetas: {
|
|
4
5
|
add: jest.Mock<any, any, any>;
|
|
5
6
|
remove: jest.Mock<any, any, any>;
|
|
@@ -9,3 +10,4 @@ export declare const mockMetas: {
|
|
|
9
10
|
};
|
|
10
11
|
export declare const mockTransports: Transports;
|
|
11
12
|
export declare const mockTracesApi: TracesAPI;
|
|
13
|
+
export declare const mockUserActionsApi: UserActionsAPI;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type { Config } from '../../config';
|
|
2
2
|
import type { InternalLogger } from '../../internalLogger';
|
|
3
3
|
import type { Metas } from '../../metas';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Transports } from '../../transports';
|
|
5
5
|
import type { UnpatchedConsole } from '../../unpatchedConsole';
|
|
6
|
-
import type { ItemBuffer } from '../ItemBuffer';
|
|
7
6
|
import type { TracesAPI } from '../traces';
|
|
8
|
-
import type {
|
|
7
|
+
import type { UserActionsAPI } from '../userActions';
|
|
9
8
|
import type { EventsAPI } from './types';
|
|
10
|
-
export declare function initializeEventsAPI({ internalLogger, config, metas, transports, tracesApi,
|
|
9
|
+
export declare function initializeEventsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }: {
|
|
11
10
|
unpatchedConsole: UnpatchedConsole;
|
|
12
11
|
internalLogger: InternalLogger;
|
|
13
12
|
config: Config;
|
|
14
13
|
metas: Metas;
|
|
15
14
|
transports: Transports;
|
|
16
15
|
tracesApi: TracesAPI;
|
|
17
|
-
|
|
18
|
-
getMessage: () => ApiMessageBusMessages | undefined;
|
|
16
|
+
userActionsApi: UserActionsAPI;
|
|
19
17
|
}): EventsAPI;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type { Config } from '../../config';
|
|
2
2
|
import type { InternalLogger } from '../../internalLogger';
|
|
3
3
|
import type { Metas } from '../../metas';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Transports } from '../../transports';
|
|
5
5
|
import type { UnpatchedConsole } from '../../unpatchedConsole';
|
|
6
|
-
import type { ItemBuffer } from '../ItemBuffer';
|
|
7
6
|
import type { TracesAPI } from '../traces';
|
|
8
|
-
import type {
|
|
7
|
+
import type { UserActionsAPI } from '../userActions';
|
|
9
8
|
import type { ExceptionsAPI } from './types';
|
|
10
|
-
export declare function initializeExceptionsAPI({ internalLogger, config, metas, transports, tracesApi,
|
|
9
|
+
export declare function initializeExceptionsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }: {
|
|
11
10
|
unpatchedConsole: UnpatchedConsole;
|
|
12
11
|
internalLogger: InternalLogger;
|
|
13
12
|
config: Config;
|
|
14
13
|
metas: Metas;
|
|
15
14
|
transports: Transports;
|
|
16
15
|
tracesApi: TracesAPI;
|
|
17
|
-
|
|
18
|
-
getMessage: () => ApiMessageBusMessages | undefined;
|
|
16
|
+
userActionsApi: UserActionsAPI;
|
|
19
17
|
}): ExceptionsAPI;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { initializeAPI } from './initialize';
|
|
2
|
-
export type { API, APIEvent,
|
|
2
|
+
export type { API, APIEvent, UserAction } from './types';
|
|
3
3
|
export type { EventAttributes, EventEvent, EventsAPI, PushEventOptions } from './events';
|
|
4
4
|
export { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';
|
|
5
5
|
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ExceptionEventExtended, } from './exceptions';
|
|
@@ -7,6 +7,5 @@ export { defaultLogArgsSerializer } from './logs';
|
|
|
7
7
|
export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';
|
|
8
8
|
export type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';
|
|
9
9
|
export type { MetaAPI } from './meta';
|
|
10
|
+
export { UserActionSeverity, UserActionState, type UserActionInterface, type UserActionsAPI, userActionsMessageBus, } from './userActions';
|
|
10
11
|
export type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';
|
|
11
|
-
export { apiMessageBus } from './initialize';
|
|
12
|
-
export { USER_ACTION_CANCEL, USER_ACTION_END, USER_ACTION_START, USER_ACTION_HALT } from './const';
|
|
@@ -3,7 +3,5 @@ import type { InternalLogger } from '../internalLogger';
|
|
|
3
3
|
import type { Metas } from '../metas';
|
|
4
4
|
import type { Transports } from '../transports';
|
|
5
5
|
import type { UnpatchedConsole } from '../unpatchedConsole';
|
|
6
|
-
import {
|
|
7
|
-
import type { API, ApiMessageBusMessages } from './types';
|
|
8
|
-
export declare const apiMessageBus: Observable<ApiMessageBusMessages>;
|
|
6
|
+
import type { API } from './types';
|
|
9
7
|
export declare function initializeAPI(unpatchedConsole: UnpatchedConsole, internalLogger: InternalLogger, config: Config, metas: Metas, transports: Transports): API;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type { Config } from '../../config';
|
|
2
2
|
import type { InternalLogger } from '../../internalLogger';
|
|
3
3
|
import type { Metas } from '../../metas';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Transports } from '../../transports';
|
|
5
5
|
import type { UnpatchedConsole } from '../../unpatchedConsole';
|
|
6
|
-
import type { ItemBuffer } from '../ItemBuffer';
|
|
7
6
|
import type { TracesAPI } from '../traces';
|
|
8
|
-
import type {
|
|
7
|
+
import type { UserActionsAPI } from '../userActions';
|
|
9
8
|
import type { LogsAPI } from './types';
|
|
10
|
-
export declare function initializeLogsAPI({ internalLogger, config, metas, transports, tracesApi,
|
|
9
|
+
export declare function initializeLogsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }: {
|
|
11
10
|
unpatchedConsole: UnpatchedConsole;
|
|
12
11
|
internalLogger: InternalLogger;
|
|
13
12
|
config: Config;
|
|
14
13
|
metas: Metas;
|
|
15
14
|
transports: Transports;
|
|
16
15
|
tracesApi: TracesAPI;
|
|
17
|
-
|
|
18
|
-
getMessage: () => ApiMessageBusMessages | undefined;
|
|
16
|
+
userActionsApi: UserActionsAPI;
|
|
19
17
|
}): LogsAPI;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type { Config } from '../../config';
|
|
2
2
|
import type { InternalLogger } from '../../internalLogger';
|
|
3
3
|
import type { Metas } from '../../metas';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Transports } from '../../transports';
|
|
5
5
|
import type { UnpatchedConsole } from '../../unpatchedConsole';
|
|
6
|
-
import type { ItemBuffer } from '../ItemBuffer';
|
|
7
6
|
import type { TracesAPI } from '../traces';
|
|
8
|
-
import type {
|
|
7
|
+
import type { UserActionsAPI } from '../userActions';
|
|
9
8
|
import type { MeasurementsAPI } from './types';
|
|
10
|
-
export declare function initializeMeasurementsAPI({ internalLogger, config, metas, transports, tracesApi,
|
|
9
|
+
export declare function initializeMeasurementsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }: {
|
|
11
10
|
unpatchedConsole: UnpatchedConsole;
|
|
12
11
|
internalLogger: InternalLogger;
|
|
13
12
|
config: Config;
|
|
14
13
|
metas: Metas;
|
|
15
14
|
transports: Transports;
|
|
16
15
|
tracesApi: TracesAPI;
|
|
17
|
-
|
|
18
|
-
getMessage: () => ApiMessageBusMessages | undefined;
|
|
16
|
+
userActionsApi: UserActionsAPI;
|
|
19
17
|
}): MeasurementsAPI;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { Config } from '../../config';
|
|
2
2
|
import type { InternalLogger } from '../../internalLogger';
|
|
3
3
|
import type { Metas } from '../../metas';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Transports } from '../../transports';
|
|
5
5
|
import type { UnpatchedConsole } from '../../unpatchedConsole';
|
|
6
|
-
import type { ItemBuffer } from '../ItemBuffer';
|
|
7
6
|
import type { TracesAPI } from '../traces';
|
|
8
|
-
import type { ApiMessageBusMessages } from '../types';
|
|
9
7
|
import type { MetaAPI } from './types';
|
|
10
8
|
export declare function initializeMetaAPI({ internalLogger, metas, }: {
|
|
11
9
|
unpatchedConsole: UnpatchedConsole;
|
|
@@ -14,6 +12,4 @@ export declare function initializeMetaAPI({ internalLogger, metas, }: {
|
|
|
14
12
|
metas: Metas;
|
|
15
13
|
transports: Transports;
|
|
16
14
|
tracesApi: TracesAPI;
|
|
17
|
-
actionBuffer: ItemBuffer<TransportItem>;
|
|
18
|
-
getMessage: () => ApiMessageBusMessages | undefined;
|
|
19
15
|
}): MetaAPI;
|
|
@@ -1,55 +1,14 @@
|
|
|
1
|
-
import type { USER_ACTION_CANCEL, USER_ACTION_END, USER_ACTION_HALT, USER_ACTION_START } from './const';
|
|
2
1
|
import type { EventEvent, EventsAPI } from './events';
|
|
3
2
|
import type { ExceptionEvent, ExceptionsAPI } from './exceptions';
|
|
4
3
|
import type { LogEvent, LogsAPI } from './logs';
|
|
5
4
|
import type { MeasurementEvent, MeasurementsAPI } from './measurements';
|
|
6
5
|
import type { MetaAPI } from './meta';
|
|
7
6
|
import type { TraceEvent, TracesAPI } from './traces';
|
|
8
|
-
|
|
9
|
-
export type API = LogsAPI & ExceptionsAPI & MeasurementsAPI & TracesAPI & MetaAPI & EventsAPI;
|
|
10
|
-
export type ApiMessageBusMessages = UserActionStartMessage | UserActionEndMessage | UserActionCancelMessage | UserActionHaltMessage;
|
|
11
|
-
export type UserActionMessageType = typeof USER_ACTION_START | typeof USER_ACTION_END | typeof USER_ACTION_CANCEL | typeof USER_ACTION_HALT;
|
|
12
|
-
export type UserActionStartMessage = {
|
|
13
|
-
type: typeof USER_ACTION_START;
|
|
14
|
-
name: string;
|
|
15
|
-
startTime: number;
|
|
16
|
-
/**
|
|
17
|
-
* Unique identifier of the parent user action to which this action belongs.
|
|
18
|
-
*/
|
|
19
|
-
parentId: string;
|
|
20
|
-
};
|
|
21
|
-
export type UserActionEndMessage = {
|
|
22
|
-
type: typeof USER_ACTION_END;
|
|
23
|
-
name: string;
|
|
24
|
-
startTime: number;
|
|
25
|
-
endTime: number;
|
|
26
|
-
duration: number;
|
|
27
|
-
eventType: string;
|
|
28
|
-
/**
|
|
29
|
-
* Unique identifier for the user action. Will be undefined for messages related to child actions.
|
|
30
|
-
*/
|
|
31
|
-
id: string;
|
|
32
|
-
};
|
|
33
|
-
export type UserActionCancelMessage = {
|
|
34
|
-
type: typeof USER_ACTION_CANCEL;
|
|
35
|
-
name: string;
|
|
36
|
-
/**
|
|
37
|
-
* Unique identifier of the parent user action to which this action belongs.
|
|
38
|
-
*/
|
|
39
|
-
parentId?: string;
|
|
40
|
-
};
|
|
41
|
-
export type UserActionHaltMessage = {
|
|
42
|
-
type: typeof USER_ACTION_HALT;
|
|
43
|
-
name: string;
|
|
44
|
-
reason: 'pending-requests';
|
|
45
|
-
haltTime: number;
|
|
46
|
-
/**
|
|
47
|
-
* Unique identifier of the parent user action to which this action belongs.
|
|
48
|
-
*/
|
|
49
|
-
parentId?: string;
|
|
50
|
-
};
|
|
7
|
+
import type { UserActionsAPI } from './userActions';
|
|
51
8
|
export type UserAction = {
|
|
52
9
|
name: string;
|
|
53
10
|
id?: string;
|
|
54
11
|
parentId?: string;
|
|
55
12
|
};
|
|
13
|
+
export type APIEvent = LogEvent | ExceptionEvent | MeasurementEvent | TraceEvent | EventEvent;
|
|
14
|
+
export type API = LogsAPI & ExceptionsAPI & MeasurementsAPI & TracesAPI & MetaAPI & EventsAPI & UserActionsAPI;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type InternalLogger, type Transports } from '../..';
|
|
2
|
+
import type { Config } from '../../config';
|
|
3
|
+
import { Observable } from '../../utils/reactive';
|
|
4
|
+
import { type UserActionsAPI } from './types';
|
|
5
|
+
export declare const userActionsMessageBus: Observable<import("./types").UserActionStart>;
|
|
6
|
+
export declare function initializeUserActionsAPI({ transports, internalLogger, config, }: {
|
|
7
|
+
transports: Transports;
|
|
8
|
+
config: Config;
|
|
9
|
+
internalLogger: InternalLogger;
|
|
10
|
+
}): UserActionsAPI;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type TransportItem } from '../../transports';
|
|
2
|
+
import { UserActionSeverity, userActionStartByApiCallEventName } from './const';
|
|
3
|
+
export declare enum UserActionState {
|
|
4
|
+
Started = 0,
|
|
5
|
+
Halted = 1,
|
|
6
|
+
Cancelled = 2,
|
|
7
|
+
Ended = 3
|
|
8
|
+
}
|
|
9
|
+
export type HaltPredicate = () => boolean;
|
|
10
|
+
export interface UserActionInterface {
|
|
11
|
+
name: string;
|
|
12
|
+
parentId: string;
|
|
13
|
+
addItem(item: TransportItem): void;
|
|
14
|
+
extend(haltPredicate?: HaltPredicate): void;
|
|
15
|
+
end(attributes?: Record<string, string>): void;
|
|
16
|
+
halt(reason?: string): void;
|
|
17
|
+
cancel(): void;
|
|
18
|
+
getState(): UserActionState;
|
|
19
|
+
}
|
|
20
|
+
export type ApiUserActionEvent = {
|
|
21
|
+
name: string;
|
|
22
|
+
attributes?: Record<string, string>;
|
|
23
|
+
type: typeof userActionStartByApiCallEventName | string;
|
|
24
|
+
};
|
|
25
|
+
export type EndUserActionProps = {
|
|
26
|
+
userActionName: string;
|
|
27
|
+
startTime: number;
|
|
28
|
+
endTime: number;
|
|
29
|
+
actionId: string;
|
|
30
|
+
event: ApiUserActionEvent;
|
|
31
|
+
attributes?: Record<string, string>;
|
|
32
|
+
};
|
|
33
|
+
export type StartUserActionOptions = {
|
|
34
|
+
triggerName?: string;
|
|
35
|
+
severity?: UserActionSeverity;
|
|
36
|
+
};
|
|
37
|
+
export interface UserActionsAPI {
|
|
38
|
+
startUserAction: (name: string, attributes?: Record<string, string>, options?: StartUserActionOptions) => UserActionInterface | undefined;
|
|
39
|
+
getActiveUserAction: () => UserActionInterface | undefined;
|
|
40
|
+
}
|
|
41
|
+
export type UserActionStart = {
|
|
42
|
+
type: 'user_action_start';
|
|
43
|
+
userAction: UserActionInterface;
|
|
44
|
+
};
|
|
45
|
+
export type UserActionMessage = UserActionStart;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type TransportItem, type Transports } from '../../transports';
|
|
2
|
+
import { Observable } from '../../utils';
|
|
3
|
+
import { type APIEvent } from '../types';
|
|
4
|
+
import { UserActionSeverity } from './const';
|
|
5
|
+
import { type HaltPredicate, type UserActionInterface, UserActionState } from './types';
|
|
6
|
+
export default class UserAction extends Observable implements UserActionInterface {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string;
|
|
9
|
+
attributes?: Record<string, string>;
|
|
10
|
+
parentId: string;
|
|
11
|
+
trigger: string;
|
|
12
|
+
severity: UserActionSeverity;
|
|
13
|
+
startTime?: number;
|
|
14
|
+
trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;
|
|
15
|
+
cancelTimeout: number;
|
|
16
|
+
haltTimeout: number;
|
|
17
|
+
private _state;
|
|
18
|
+
private _timeoutId?;
|
|
19
|
+
private _itemBuffer;
|
|
20
|
+
private _transports;
|
|
21
|
+
private _haltTimeoutId;
|
|
22
|
+
private _isValid;
|
|
23
|
+
constructor({ name, parentId, haltTimeout, trigger, transports, attributes, trackUserActionsExcludeItem, severity, }: {
|
|
24
|
+
name: string;
|
|
25
|
+
transports: Transports;
|
|
26
|
+
parentId?: string;
|
|
27
|
+
trigger: string;
|
|
28
|
+
attributes?: Record<string, string>;
|
|
29
|
+
haltTimeout?: number;
|
|
30
|
+
trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;
|
|
31
|
+
severity?: UserActionSeverity;
|
|
32
|
+
});
|
|
33
|
+
addItem(item: TransportItem): void;
|
|
34
|
+
extend(haltPredicate?: HaltPredicate): void;
|
|
35
|
+
private _setFollowupActionTimeout;
|
|
36
|
+
private _start;
|
|
37
|
+
halt(): void;
|
|
38
|
+
cancel(): void;
|
|
39
|
+
end(): void;
|
|
40
|
+
getState(): UserActionState;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer,
|
|
2
|
-
export type { API, APIEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionEventExtended, ExceptionStackFrame, ExceptionsAPI, ExtendedError, LogArgsSerializer, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, MetaAPI, OTELApi, PushErrorOptions, PushEventOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI,
|
|
1
|
+
export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer, UserActionSeverity, UserActionState, userActionsMessageBus, } from './api';
|
|
2
|
+
export type { API, APIEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionEventExtended, ExceptionStackFrame, ExceptionsAPI, ExtendedError, LogArgsSerializer, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, MetaAPI, OTELApi, PushErrorOptions, PushEventOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, UserAction, UserActionInterface, } from './api';
|
|
3
3
|
export { BaseExtension } from './extensions';
|
|
4
4
|
export type { Extension } from './extensions';
|
|
5
5
|
export { globalObject } from './globalObject';
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated The conventions object will be removed in a future version
|
|
3
|
-
*/
|
|
4
|
-
export declare const Conventions: {
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated The event names object will be removed in a future version
|
|
7
|
-
*/
|
|
8
|
-
readonly EventNames: {
|
|
9
|
-
readonly CLICK: "click";
|
|
10
|
-
readonly NAVIGATION: "navigation";
|
|
11
|
-
readonly SESSION_START: "session_start";
|
|
12
|
-
readonly VIEW_CHANGED: "view_changed";
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
1
|
export declare const EVENT_CLICK = "click";
|
|
16
2
|
export declare const EVENT_NAVIGATION = "navigation";
|
|
17
3
|
export declare const EVENT_VIEW_CHANGED = "view_changed";
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "
|
|
7
|
+
readonly version = "2.0.0-beta-2";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "
|
|
1
|
+
export declare const VERSION = "2.0.0-beta-2";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer,
|
|
2
|
-
export type { API, APIEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionEventExtended, ExceptionStackFrame, ExceptionsAPI, ExtendedError, LogArgsSerializer, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, MetaAPI, OTELApi, PushErrorOptions, PushEventOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI,
|
|
1
|
+
export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer, UserActionSeverity, UserActionState, userActionsMessageBus, } from './api';
|
|
2
|
+
export type { API, APIEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionEventExtended, ExceptionStackFrame, ExceptionsAPI, ExtendedError, LogArgsSerializer, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, MetaAPI, OTELApi, PushErrorOptions, PushEventOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, UserAction, UserActionInterface, } from './api';
|
|
3
3
|
export { BaseExtension } from './extensions';
|
|
4
4
|
export type { Extension } from './extensions';
|
|
5
5
|
export { globalObject } from './globalObject';
|
package/dist/types/semantic.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated The conventions object will be removed in a future version
|
|
3
|
-
*/
|
|
4
|
-
export declare const Conventions: {
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated The event names object will be removed in a future version
|
|
7
|
-
*/
|
|
8
|
-
readonly EventNames: {
|
|
9
|
-
readonly CLICK: "click";
|
|
10
|
-
readonly NAVIGATION: "navigation";
|
|
11
|
-
readonly SESSION_START: "session_start";
|
|
12
|
-
readonly VIEW_CHANGED: "view_changed";
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
1
|
export declare const EVENT_CLICK = "click";
|
|
16
2
|
export declare const EVENT_NAVIGATION = "navigation";
|
|
17
3
|
export declare const EVENT_VIEW_CHANGED = "view_changed";
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "
|
|
7
|
+
readonly version = "2.0.0-beta-2";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "
|
|
1
|
+
export declare const VERSION = "2.0.0-beta-2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/faro-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta-2",
|
|
4
4
|
"description": "Core package of Faro.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"observability",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@opentelemetry/api": "^1.9.0",
|
|
55
|
-
"@opentelemetry/otlp-transformer": "^0.
|
|
55
|
+
"@opentelemetry/otlp-transformer": "^0.203.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/node": "^24.0.1"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f633489cdfedf7b5b5f6545781cd07b4c0aa5c27"
|
|
64
64
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../config';
|
|
2
|
-
import { type TransportItem, type Transports } from '../transports';
|
|
3
|
-
import type { Observable } from '../utils';
|
|
4
|
-
import { ItemBuffer } from './ItemBuffer';
|
|
5
|
-
import type { APIEvent, ApiMessageBusMessages } from './types';
|
|
6
|
-
export declare function createUserActionLifecycleHandler({ apiMessageBus, transports, config, }: {
|
|
7
|
-
apiMessageBus: Observable<ApiMessageBusMessages>;
|
|
8
|
-
transports: Transports;
|
|
9
|
-
config: Config;
|
|
10
|
-
}): {
|
|
11
|
-
actionBuffer: ItemBuffer<TransportItem<APIEvent>>;
|
|
12
|
-
getMessage: () => ApiMessageBusMessages | undefined;
|
|
13
|
-
};
|
package/dist/cjs/api/const.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.USER_ACTION_HALT = exports.USER_ACTION_CANCEL = exports.USER_ACTION_END = exports.USER_ACTION_START = void 0;
|
|
4
|
-
exports.USER_ACTION_START = 'user-action-start';
|
|
5
|
-
exports.USER_ACTION_END = 'user-action-end';
|
|
6
|
-
exports.USER_ACTION_CANCEL = 'user-action-cancel';
|
|
7
|
-
exports.USER_ACTION_HALT = 'user-action-halt';
|
|
8
|
-
//# sourceMappingURL=const.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/api/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,eAAe,GAAG,iBAAiB,CAAC;AACpC,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC","sourcesContent":["export const USER_ACTION_START = 'user-action-start';\nexport const USER_ACTION_END = 'user-action-end';\nexport const USER_ACTION_CANCEL = 'user-action-cancel';\nexport const USER_ACTION_HALT = 'user-action-halt';\n"]}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.createUserActionLifecycleHandler = createUserActionLifecycleHandler;
|
|
15
|
-
var transports_1 = require("../transports");
|
|
16
|
-
var const_1 = require("./const");
|
|
17
|
-
var ItemBuffer_1 = require("./ItemBuffer");
|
|
18
|
-
function createUserActionLifecycleHandler(_a) {
|
|
19
|
-
var apiMessageBus = _a.apiMessageBus, transports = _a.transports, config = _a.config;
|
|
20
|
-
var actionBuffer = new ItemBuffer_1.ItemBuffer();
|
|
21
|
-
var trackUserActionsExcludeItem = config.trackUserActionsExcludeItem;
|
|
22
|
-
var message;
|
|
23
|
-
apiMessageBus.subscribe(function (msg) {
|
|
24
|
-
if (const_1.USER_ACTION_START === msg.type || const_1.USER_ACTION_HALT === msg.type) {
|
|
25
|
-
message = msg;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (msg.type === const_1.USER_ACTION_END) {
|
|
29
|
-
var id_1 = msg.id, name_1 = msg.name;
|
|
30
|
-
actionBuffer.flushBuffer(function (item) {
|
|
31
|
-
if (isExcludeFromUserAction(item, trackUserActionsExcludeItem)) {
|
|
32
|
-
transports.execute(item);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
var userActionItem = __assign(__assign({}, item), { payload: __assign(__assign({}, item.payload), { action: {
|
|
36
|
-
parentId: id_1,
|
|
37
|
-
name: name_1,
|
|
38
|
-
} }) });
|
|
39
|
-
transports.execute(userActionItem);
|
|
40
|
-
});
|
|
41
|
-
message = undefined;
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (msg.type === const_1.USER_ACTION_CANCEL) {
|
|
45
|
-
message = undefined;
|
|
46
|
-
actionBuffer.flushBuffer(function (item) {
|
|
47
|
-
transports.execute(item);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
var getMessage = function () { return message; };
|
|
52
|
-
return { actionBuffer: actionBuffer, getMessage: getMessage };
|
|
53
|
-
}
|
|
54
|
-
function isExcludeFromUserAction(item, trackUserActionsExcludeItem) {
|
|
55
|
-
return ((trackUserActionsExcludeItem === null || trackUserActionsExcludeItem === void 0 ? void 0 : trackUserActionsExcludeItem(item)) ||
|
|
56
|
-
(item.type === transports_1.TransportItemType.MEASUREMENT && item.payload.type === 'web-vitals'));
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=userActionLifecycleHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"userActionLifecycleHandler.js","sourceRoot":"","sources":["../../../src/api/userActionLifecycleHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AASA,4EAwDC;AAhED,4CAAuF;AAGvF,iCAAmG;AACnG,2CAA0C;AAI1C,SAAgB,gCAAgC,CAAC,EAQhD;QAPC,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,MAAM,YAAA;IAMN,IAAM,YAAY,GAAG,IAAI,uBAAU,EAAiB,CAAC;IACrD,IAAM,2BAA2B,GAAG,MAAM,CAAC,2BAA2B,CAAC;IACvE,IAAI,OAA0C,CAAC;IAE/C,aAAa,CAAC,SAAS,CAAC,UAAC,GAAG;QAC1B,IAAI,yBAAiB,KAAK,GAAG,CAAC,IAAI,IAAI,wBAAgB,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;YACpE,OAAO,GAAG,GAAG,CAAC;YACd,OAAO;QACT,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,uBAAe,EAAE,CAAC;YACzB,IAAA,IAAE,GAAW,GAAG,GAAd,EAAE,MAAI,GAAK,GAAG,KAAR,CAAS;YAEzB,YAAY,CAAC,WAAW,CAAC,UAAC,IAAI;gBAC5B,IAAI,uBAAuB,CAAC,IAAI,EAAE,2BAA2B,CAAC,EAAE,CAAC;oBAC/D,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBACzB,OAAO;gBACT,CAAC;gBAED,IAAM,cAAc,GAAG,sBAClB,IAAI,KACP,OAAO,wBACF,IAAI,CAAC,OAAO,KACf,MAAM,EAAE;4BACN,QAAQ,EAAE,IAAE;4BACZ,IAAI,QAAA;yBACL,MAEa,CAAC;gBAEnB,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;YAEH,OAAO,GAAG,SAAS,CAAC;YACpB,OAAO;QACT,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,0BAAkB,EAAE,CAAC;YACpC,OAAO,GAAG,SAAS,CAAC;YACpB,YAAY,CAAC,WAAW,CAAC,UAAC,IAAI;gBAC5B,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAM,UAAU,GAAG,cAAsB,OAAA,OAAO,EAAP,CAAO,CAAC;IACjD,OAAO,EAAE,YAAY,cAAA,EAAE,UAAU,YAAA,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,uBAAuB,CAC9B,IAA6B,EAC7B,2BAAkE;IAElE,OAAO,CACL,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAG,IAAI,CAAC;QACnC,CAAC,IAAI,CAAC,IAAI,KAAK,8BAAiB,CAAC,WAAW,IAAK,IAAI,CAAC,OAA4B,CAAC,IAAI,KAAK,YAAY,CAAC,CAC1G,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../config';\nimport { type TransportItem, TransportItemType, type Transports } from '../transports';\nimport type { Observable } from '../utils';\n\nimport { USER_ACTION_CANCEL, USER_ACTION_END, USER_ACTION_HALT, USER_ACTION_START } from './const';\nimport { ItemBuffer } from './ItemBuffer';\nimport type { MeasurementEvent } from './measurements';\nimport type { APIEvent, ApiMessageBusMessages } from './types';\n\nexport function createUserActionLifecycleHandler({\n apiMessageBus,\n transports,\n config,\n}: {\n apiMessageBus: Observable<ApiMessageBusMessages>;\n transports: Transports;\n config: Config;\n}) {\n const actionBuffer = new ItemBuffer<TransportItem>();\n const trackUserActionsExcludeItem = config.trackUserActionsExcludeItem;\n let message: ApiMessageBusMessages | undefined;\n\n apiMessageBus.subscribe((msg) => {\n if (USER_ACTION_START === msg.type || USER_ACTION_HALT === msg.type) {\n message = msg;\n return;\n }\n\n if (msg.type === USER_ACTION_END) {\n const { id, name } = msg;\n\n actionBuffer.flushBuffer((item) => {\n if (isExcludeFromUserAction(item, trackUserActionsExcludeItem)) {\n transports.execute(item);\n return;\n }\n\n const userActionItem = {\n ...item,\n payload: {\n ...item.payload,\n action: {\n parentId: id,\n name,\n },\n },\n } as TransportItem;\n\n transports.execute(userActionItem);\n });\n\n message = undefined;\n return;\n }\n\n if (msg.type === USER_ACTION_CANCEL) {\n message = undefined;\n actionBuffer.flushBuffer((item) => {\n transports.execute(item);\n });\n }\n });\n\n const getMessage = (): typeof message => message;\n return { actionBuffer, getMessage };\n}\n\nfunction isExcludeFromUserAction(\n item: TransportItem<APIEvent>,\n trackUserActionsExcludeItem: Config['trackUserActionsExcludeItem']\n) {\n return (\n trackUserActionsExcludeItem?.(item) ||\n (item.type === TransportItemType.MEASUREMENT && (item.payload as MeasurementEvent).type === 'web-vitals')\n );\n}\n"]}
|