@multiplayer-app/session-recorder-react-native 1.0.1-beta.4 → 1.0.1-beta.5
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/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativeModule.kt +2 -2
- package/lib/module/components/SessionRecorderWidget/ErrorBanner.js.map +1 -1
- package/lib/module/components/SessionRecorderWidget/ModalHeader.js.map +1 -1
- package/lib/module/components/SessionRecorderWidget/SessionRecorderWidget.js.map +1 -1
- package/lib/module/components/SessionRecorderWidget/icons.js.map +1 -1
- package/lib/module/components/SessionRecorderWidget/styles.js.map +1 -1
- package/lib/module/config/constants.js.map +1 -1
- package/lib/module/config/defaults.js.map +1 -1
- package/lib/module/config/masking.js.map +1 -1
- package/lib/module/config/session-recorder.js.map +1 -1
- package/lib/module/config/validators.js.map +1 -1
- package/lib/module/config/widget.js.map +1 -1
- package/lib/module/context/SessionRecorderStore.js.map +1 -1
- package/lib/module/context/useSessionRecorderStore.js.map +1 -1
- package/lib/module/context/useStoreSelector.js.map +1 -1
- package/lib/module/native/SessionRecorderNative.js.map +1 -1
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/otel/helpers.js +1 -1
- package/lib/module/otel/helpers.js.map +1 -1
- package/lib/module/otel/index.js.map +1 -1
- package/lib/module/otel/instrumentations/index.js.map +1 -1
- package/lib/module/patch/xhr.js.map +1 -1
- package/lib/module/recorder/eventExporter.js.map +1 -1
- package/lib/module/recorder/gestureRecorder.js.map +1 -1
- package/lib/module/recorder/index.js.map +1 -1
- package/lib/module/recorder/navigationTracker.js.map +1 -1
- package/lib/module/recorder/screenRecorder.js.map +1 -1
- package/lib/module/services/api.service.js.map +1 -1
- package/lib/module/services/network.service.js.map +1 -1
- package/lib/module/services/screenMaskingService.js.map +1 -1
- package/lib/module/services/storage.service.js.map +1 -1
- package/lib/module/session-recorder.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/session-recorder.js.map +1 -1
- package/lib/module/utils/app-metadata.js +2 -2
- package/lib/module/utils/constants.optional.js.map +1 -1
- package/lib/module/utils/createStore.js.map +1 -1
- package/lib/module/utils/logger.js +0 -8
- package/lib/module/utils/logger.js.map +1 -1
- package/lib/module/utils/platform.js +1 -1
- package/lib/module/utils/platform.js.map +1 -1
- package/lib/module/utils/rrweb-events.js.map +1 -1
- package/lib/module/utils/session.js.map +1 -1
- package/lib/module/utils/shallowEqual.js.map +1 -1
- package/lib/module/utils/time.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/components/ScreenRecorderView/index.d.ts +1 -1
- package/lib/typescript/src/components/SessionRecorderWidget/ErrorBanner.d.ts.map +1 -1
- package/lib/typescript/src/components/SessionRecorderWidget/ModalHeader.d.ts.map +1 -1
- package/lib/typescript/src/components/SessionRecorderWidget/SessionRecorderWidget.d.ts.map +1 -1
- package/lib/typescript/src/components/SessionRecorderWidget/icons.d.ts.map +1 -1
- package/lib/typescript/src/components/SessionRecorderWidget/index.d.ts +1 -1
- package/lib/typescript/src/components/SessionRecorderWidget/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/config/constants.d.ts.map +1 -1
- package/lib/typescript/src/config/defaults.d.ts.map +1 -1
- package/lib/typescript/src/config/index.d.ts.map +1 -1
- package/lib/typescript/src/config/masking.d.ts.map +1 -1
- package/lib/typescript/src/config/session-recorder.d.ts.map +1 -1
- package/lib/typescript/src/config/validators.d.ts.map +1 -1
- package/lib/typescript/src/config/widget.d.ts +1 -1
- package/lib/typescript/src/config/widget.d.ts.map +1 -1
- package/lib/typescript/src/context/SessionRecorderStore.d.ts.map +1 -1
- package/lib/typescript/src/context/useSessionRecorderStore.d.ts +3 -3
- package/lib/typescript/src/context/useSessionRecorderStore.d.ts.map +1 -1
- package/lib/typescript/src/context/useStoreSelector.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/SessionRecorderNative.d.ts.map +1 -1
- package/lib/typescript/src/native/index.d.ts +1 -1
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/otel/helpers.d.ts.map +1 -1
- package/lib/typescript/src/otel/index.d.ts.map +1 -1
- package/lib/typescript/src/otel/instrumentations/index.d.ts.map +1 -1
- package/lib/typescript/src/patch/index.d.ts.map +1 -1
- package/lib/typescript/src/patch/xhr.d.ts.map +1 -1
- package/lib/typescript/src/recorder/eventExporter.d.ts.map +1 -1
- package/lib/typescript/src/recorder/gestureRecorder.d.ts.map +1 -1
- package/lib/typescript/src/recorder/index.d.ts.map +1 -1
- package/lib/typescript/src/recorder/navigationTracker.d.ts.map +1 -1
- package/lib/typescript/src/recorder/screenRecorder.d.ts.map +1 -1
- package/lib/typescript/src/services/api.service.d.ts.map +1 -1
- package/lib/typescript/src/services/network.service.d.ts.map +1 -1
- package/lib/typescript/src/services/screenMaskingService.d.ts.map +1 -1
- package/lib/typescript/src/services/storage.service.d.ts.map +1 -1
- package/lib/typescript/src/session-recorder.d.ts.map +1 -1
- package/lib/typescript/src/types/configs.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/session-recorder.d.ts +4 -4
- package/lib/typescript/src/types/session-recorder.d.ts.map +1 -1
- package/lib/typescript/src/types/session.d.ts.map +1 -1
- package/lib/typescript/src/utils/app-metadata.d.ts.map +1 -1
- package/lib/typescript/src/utils/constants.optional.d.ts.map +1 -1
- package/lib/typescript/src/utils/constants.optional.expo.d.ts.map +1 -1
- package/lib/typescript/src/utils/createStore.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/logger.d.ts +1 -1
- package/lib/typescript/src/utils/logger.d.ts.map +1 -1
- package/lib/typescript/src/utils/platform.d.ts.map +1 -1
- package/lib/typescript/src/utils/request-utils.d.ts.map +1 -1
- package/lib/typescript/src/utils/rrweb-events.d.ts.map +1 -1
- package/lib/typescript/src/utils/session.d.ts.map +1 -1
- package/lib/typescript/src/utils/shallowEqual.d.ts.map +1 -1
- package/lib/typescript/src/utils/time.d.ts.map +1 -1
- package/lib/typescript/src/utils/type-utils.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/ScreenRecorderView/index.ts +1 -1
- package/src/components/SessionRecorderWidget/ErrorBanner.tsx +14 -14
- package/src/components/SessionRecorderWidget/ModalHeader.tsx +11 -9
- package/src/components/SessionRecorderWidget/SessionRecorderWidget.tsx +70 -56
- package/src/components/SessionRecorderWidget/icons.tsx +58 -30
- package/src/components/SessionRecorderWidget/index.ts +1 -1
- package/src/components/SessionRecorderWidget/styles.ts +17 -18
- package/src/components/index.ts +2 -2
- package/src/config/constants.ts +19 -20
- package/src/config/defaults.ts +35 -31
- package/src/config/index.ts +5 -5
- package/src/config/masking.ts +44 -18
- package/src/config/session-recorder.ts +54 -26
- package/src/config/validators.ts +43 -20
- package/src/config/widget.ts +24 -15
- package/src/context/SessionRecorderStore.ts +19 -18
- package/src/context/useSessionRecorderStore.ts +17 -10
- package/src/context/useStoreSelector.ts +20 -18
- package/src/index.ts +7 -7
- package/src/native/SessionRecorderNative.ts +83 -67
- package/src/native/index.ts +5 -1
- package/src/otel/helpers.ts +109 -93
- package/src/otel/index.ts +46 -49
- package/src/otel/instrumentations/index.ts +44 -41
- package/src/patch/index.ts +1 -1
- package/src/patch/xhr.ts +77 -78
- package/src/recorder/eventExporter.ts +63 -68
- package/src/recorder/gestureRecorder.ts +359 -212
- package/src/recorder/index.ts +75 -62
- package/src/recorder/navigationTracker.ts +120 -97
- package/src/recorder/screenRecorder.ts +214 -163
- package/src/services/api.service.ts +49 -48
- package/src/services/network.service.ts +67 -58
- package/src/services/screenMaskingService.ts +81 -50
- package/src/services/storage.service.ts +99 -70
- package/src/session-recorder.ts +270 -214
- package/src/types/configs.ts +53 -31
- package/src/types/expo-constants.d.ts +2 -2
- package/src/types/index.ts +16 -18
- package/src/types/session-recorder.ts +106 -111
- package/src/types/session.ts +45 -45
- package/src/utils/app-metadata.ts +9 -9
- package/src/utils/constants.optional.expo.ts +3 -3
- package/src/utils/constants.optional.ts +14 -12
- package/src/utils/createStore.ts +23 -20
- package/src/utils/index.ts +7 -7
- package/src/utils/logger.ts +87 -58
- package/src/utils/platform.ts +149 -118
- package/src/utils/request-utils.ts +15 -15
- package/src/utils/rrweb-events.ts +47 -34
- package/src/utils/session.ts +15 -12
- package/src/utils/shallowEqual.ts +16 -10
- package/src/utils/time.ts +7 -4
- package/src/utils/type-utils.ts +36 -36
- package/src/version.ts +1 -1
- package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativeModuleSpec.kt +0 -51
- package/android/src/main/java/com/xxx/XxxModule.kt +0 -23
- package/ios/Xxx.h +0 -5
- package/ios/Xxx.mm +0 -21
package/src/types/session.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { SessionType } from '@multiplayer-app/session-recorder-common'
|
|
1
|
+
import { SessionType } from '@multiplayer-app/session-recorder-common';
|
|
2
2
|
|
|
3
3
|
export interface IResourceAttributes {
|
|
4
|
-
browserInfo?: string
|
|
5
|
-
cookiesEnabled?: string
|
|
6
|
-
deviceInfo?: string
|
|
7
|
-
hardwareConcurrency?: number
|
|
8
|
-
osInfo?: string
|
|
9
|
-
pixelRatio?: number
|
|
10
|
-
screenSize?: string
|
|
11
|
-
packageVersion?: string
|
|
12
|
-
[key: string]: any
|
|
4
|
+
browserInfo?: string;
|
|
5
|
+
cookiesEnabled?: string;
|
|
6
|
+
deviceInfo?: string;
|
|
7
|
+
hardwareConcurrency?: number;
|
|
8
|
+
osInfo?: string;
|
|
9
|
+
pixelRatio?: number;
|
|
10
|
+
screenSize?: string;
|
|
11
|
+
packageVersion?: string;
|
|
12
|
+
[key: string]: any;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface ISessionAttributes {
|
|
16
|
-
userEmail?: string
|
|
17
|
-
userId?: string
|
|
18
|
-
userName?: string
|
|
19
|
-
accountId?: string
|
|
20
|
-
accountName?: string
|
|
21
|
-
[key: string]: any
|
|
16
|
+
userEmail?: string;
|
|
17
|
+
userId?: string;
|
|
18
|
+
userName?: string;
|
|
19
|
+
accountId?: string;
|
|
20
|
+
accountName?: string;
|
|
21
|
+
[key: string]: any;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface ISessionView {
|
|
25
|
-
_id: string
|
|
26
|
-
name: string
|
|
27
|
-
components?: string[]
|
|
25
|
+
_id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
components?: string[];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface ISession {
|
|
31
|
-
_id: string
|
|
32
|
-
shortId: string
|
|
33
|
-
workspace: string
|
|
34
|
-
project: string
|
|
35
|
-
continuousDebugSession?: string
|
|
36
|
-
creationType: SessionType
|
|
37
|
-
name: string
|
|
38
|
-
startedAt: string | Date
|
|
39
|
-
stoppedAt: string | Date
|
|
40
|
-
durationInSeconds?: number
|
|
41
|
-
createdAt: string | Date
|
|
42
|
-
updatedAt: string | Date
|
|
43
|
-
tags: any[]
|
|
31
|
+
_id: string;
|
|
32
|
+
shortId: string;
|
|
33
|
+
workspace: string;
|
|
34
|
+
project: string;
|
|
35
|
+
continuousDebugSession?: string;
|
|
36
|
+
creationType: SessionType;
|
|
37
|
+
name: string;
|
|
38
|
+
startedAt: string | Date;
|
|
39
|
+
stoppedAt: string | Date;
|
|
40
|
+
durationInSeconds?: number;
|
|
41
|
+
createdAt: string | Date;
|
|
42
|
+
updatedAt: string | Date;
|
|
43
|
+
tags: any[];
|
|
44
44
|
|
|
45
|
-
resourceAttributes?: IResourceAttributes
|
|
46
|
-
sessionAttributes?: ISessionAttributes
|
|
47
|
-
views: ISessionView[]
|
|
48
|
-
starred: boolean
|
|
49
|
-
starredItems: string[]
|
|
45
|
+
resourceAttributes?: IResourceAttributes;
|
|
46
|
+
sessionAttributes?: ISessionAttributes;
|
|
47
|
+
views: ISessionView[];
|
|
48
|
+
starred: boolean;
|
|
49
|
+
starredItems: string[];
|
|
50
50
|
s3Files: {
|
|
51
|
-
_id?: string
|
|
52
|
-
bucket: string
|
|
53
|
-
key: string
|
|
54
|
-
dataType: DebugSessionDataType
|
|
55
|
-
url?: string
|
|
56
|
-
}[]
|
|
57
|
-
finishedS3Transfer?: boolean
|
|
58
|
-
tempApiKey?: string
|
|
51
|
+
_id?: string;
|
|
52
|
+
bucket: string;
|
|
53
|
+
key: string;
|
|
54
|
+
dataType: DebugSessionDataType;
|
|
55
|
+
url?: string;
|
|
56
|
+
}[];
|
|
57
|
+
finishedS3Transfer?: boolean;
|
|
58
|
+
tempApiKey?: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export enum DebugSessionDataType {
|
|
@@ -7,25 +7,25 @@
|
|
|
7
7
|
// It extracts metadata from app.json, app.config.js, or package.json
|
|
8
8
|
|
|
9
9
|
export interface AppMetadata {
|
|
10
|
-
name?: string
|
|
11
|
-
version?: string
|
|
12
|
-
bundleId?: string
|
|
13
|
-
buildNumber?: string
|
|
14
|
-
displayName?: string
|
|
10
|
+
name?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
bundleId?: string;
|
|
13
|
+
buildNumber?: string;
|
|
14
|
+
displayName?: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// Auto-detected values from project configuration files
|
|
18
18
|
export const APP_METADATA: AppMetadata = {
|
|
19
|
-
name:
|
|
20
|
-
version:
|
|
19
|
+
name: '@multiplayer-app/session-recorder-react-native',
|
|
20
|
+
version: '0.0.1',
|
|
21
21
|
bundleId: undefined,
|
|
22
22
|
buildNumber: undefined,
|
|
23
23
|
displayName: undefined,
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Get auto-detected app metadata
|
|
28
28
|
*/
|
|
29
29
|
export function getAutoDetectedAppMetadata(): AppMetadata {
|
|
30
|
-
return { ...APP_METADATA }
|
|
30
|
+
return { ...APP_METADATA };
|
|
31
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Expo variant: re-export expo-constants default to be consumed via the optional shim path
|
|
2
|
-
import Constants from 'expo-constants'
|
|
3
|
-
import type { OptionalExpoConstants } from './constants.optional'
|
|
2
|
+
import Constants from 'expo-constants';
|
|
3
|
+
import type { OptionalExpoConstants } from './constants.optional';
|
|
4
4
|
|
|
5
|
-
export default Constants as OptionalExpoConstants
|
|
5
|
+
export default Constants as OptionalExpoConstants;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// Non-Expo fallback: export undefined to avoid bundling expo-constants in non-Expo apps
|
|
2
2
|
// Define a lightweight type that includes only the members we read.
|
|
3
|
-
export type OptionalExpoConstants =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
3
|
+
export type OptionalExpoConstants =
|
|
4
|
+
| {
|
|
5
|
+
expoVersion?: string;
|
|
6
|
+
platform?: { ios?: unknown; android?: unknown };
|
|
7
|
+
expoConfig?: {
|
|
8
|
+
name?: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
ios?: { buildNumber?: string | number; bundleIdentifier?: string };
|
|
11
|
+
android?: { versionCode?: string | number; package?: string };
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
| undefined;
|
|
13
15
|
|
|
14
|
-
const OptionalConstants: OptionalExpoConstants = undefined
|
|
16
|
+
const OptionalConstants: OptionalExpoConstants = undefined;
|
|
15
17
|
|
|
16
|
-
export default OptionalConstants
|
|
18
|
+
export default OptionalConstants;
|
package/src/utils/createStore.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
type Listener<T> = (state: T, prevState: T) => void
|
|
1
|
+
type Listener<T> = (state: T, prevState: T) => void;
|
|
2
2
|
|
|
3
3
|
export type Store<T> = {
|
|
4
|
-
getState: () => T
|
|
5
|
-
setState: (partial: Partial<T> | ((prev: T) => T), action?: string) => void
|
|
6
|
-
subscribe: (listener: Listener<T>) => () => void
|
|
7
|
-
}
|
|
4
|
+
getState: () => T;
|
|
5
|
+
setState: (partial: Partial<T> | ((prev: T) => T), action?: string) => void;
|
|
6
|
+
subscribe: (listener: Listener<T>) => () => void;
|
|
7
|
+
};
|
|
8
8
|
|
|
9
9
|
export function createStore<T extends object>(initialState: T): Store<T> {
|
|
10
|
-
let state: T = initialState
|
|
11
|
-
const listeners = new Set<Listener<T>>()
|
|
10
|
+
let state: T = initialState;
|
|
11
|
+
const listeners = new Set<Listener<T>>();
|
|
12
12
|
|
|
13
|
-
const getState = () => state
|
|
13
|
+
const getState = () => state;
|
|
14
14
|
|
|
15
|
-
const setState: Store<T>[
|
|
16
|
-
const prevState = state
|
|
17
|
-
const nextState =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const setState: Store<T>['setState'] = (partial) => {
|
|
16
|
+
const prevState = state;
|
|
17
|
+
const nextState =
|
|
18
|
+
typeof partial === 'function'
|
|
19
|
+
? (partial as (prev: T) => T)(prevState)
|
|
20
|
+
: ({ ...prevState, ...partial } as T);
|
|
21
|
+
if (Object.is(nextState, prevState)) return;
|
|
22
|
+
state = nextState;
|
|
23
|
+
listeners.forEach((l) => l(state, prevState));
|
|
24
|
+
};
|
|
22
25
|
|
|
23
|
-
const subscribe: Store<T>[
|
|
24
|
-
listeners.add(listener)
|
|
25
|
-
return () => listeners.delete(listener)
|
|
26
|
-
}
|
|
26
|
+
const subscribe: Store<T>['subscribe'] = (listener) => {
|
|
27
|
+
listeners.add(listener);
|
|
28
|
+
return () => listeners.delete(listener);
|
|
29
|
+
};
|
|
27
30
|
|
|
28
|
-
return { getState, setState, subscribe }
|
|
31
|
+
return { getState, setState, subscribe };
|
|
29
32
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Export all utility functions
|
|
2
|
-
export * from './platform'
|
|
3
|
-
export * from './session'
|
|
4
|
-
export * from './time'
|
|
5
|
-
export * from './type-utils'
|
|
6
|
-
export * from './request-utils'
|
|
7
|
-
export * from './rrweb-events'
|
|
8
|
-
export * from './logger'
|
|
2
|
+
export * from './platform';
|
|
3
|
+
export * from './session';
|
|
4
|
+
export * from './time';
|
|
5
|
+
export * from './type-utils';
|
|
6
|
+
export * from './request-utils';
|
|
7
|
+
export * from './rrweb-events';
|
|
8
|
+
export * from './logger';
|
package/src/utils/logger.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Provides consistent logging across all components
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { LogLevel } from
|
|
6
|
+
import { LogLevel } from '../types';
|
|
7
7
|
|
|
8
8
|
export interface LoggerConfig {
|
|
9
|
-
level: LogLevel
|
|
10
|
-
enabled: boolean
|
|
11
|
-
enablePrefix: boolean
|
|
12
|
-
prefix: string
|
|
9
|
+
level: LogLevel;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
enablePrefix: boolean;
|
|
12
|
+
prefix: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
class Logger {
|
|
@@ -18,7 +18,7 @@ class Logger {
|
|
|
18
18
|
enabled: true,
|
|
19
19
|
enablePrefix: true,
|
|
20
20
|
prefix: '[SessionRecorder]',
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
|
|
23
23
|
private componentPrefixes: Map<string, string> = new Map([
|
|
24
24
|
['ScreenRecorder', '📸'],
|
|
@@ -28,14 +28,14 @@ class Logger {
|
|
|
28
28
|
['NavigationTracker', '📸'],
|
|
29
29
|
['RecorderReactNativeSDK', '📤'],
|
|
30
30
|
['DEBUGGER_LIB', '🔍'],
|
|
31
|
-
])
|
|
31
|
+
]);
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Configure the logger
|
|
35
35
|
* @param config - Logger configuration
|
|
36
36
|
*/
|
|
37
37
|
configure(config: Partial<LoggerConfig>): void {
|
|
38
|
-
this.config = { ...this.config, ...config }
|
|
38
|
+
this.config = { ...this.config, ...config };
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -43,7 +43,7 @@ class Logger {
|
|
|
43
43
|
* @param level - Log level to set
|
|
44
44
|
*/
|
|
45
45
|
setLevel(level: LogLevel): void {
|
|
46
|
-
this.config.level = level
|
|
46
|
+
this.config.level = level;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -51,7 +51,7 @@ class Logger {
|
|
|
51
51
|
* @param enabled - Whether to enable console output
|
|
52
52
|
*/
|
|
53
53
|
setConsoleEnabled(enabled: boolean): void {
|
|
54
|
-
this.config.enabled = enabled
|
|
54
|
+
this.config.enabled = enabled;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -60,7 +60,7 @@ class Logger {
|
|
|
60
60
|
* @param emoji - Emoji prefix for the component
|
|
61
61
|
*/
|
|
62
62
|
setComponentPrefix(component: string, emoji: string): void {
|
|
63
|
-
this.componentPrefixes.set(component, emoji)
|
|
63
|
+
this.componentPrefixes.set(component, emoji);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -69,10 +69,10 @@ class Logger {
|
|
|
69
69
|
* @returns Formatted prefix string
|
|
70
70
|
*/
|
|
71
71
|
private getPrefix(component: string): string {
|
|
72
|
-
if (!this.config.enablePrefix) return ''
|
|
72
|
+
if (!this.config.enablePrefix) return '';
|
|
73
73
|
|
|
74
|
-
const emoji = this.componentPrefixes.get(component) || '📝'
|
|
75
|
-
return `${this.config.prefix} ${emoji} [${component}]
|
|
74
|
+
const emoji = this.componentPrefixes.get(component) || '📝';
|
|
75
|
+
return `${this.config.prefix} ${emoji} [${component}]`;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
@@ -81,7 +81,7 @@ class Logger {
|
|
|
81
81
|
* @returns True if should output
|
|
82
82
|
*/
|
|
83
83
|
private shouldLog(level: LogLevel): boolean {
|
|
84
|
-
return level >= this.config.level && this.config.enabled
|
|
84
|
+
return level >= this.config.level && this.config.enabled;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
@@ -92,17 +92,22 @@ class Logger {
|
|
|
92
92
|
* @param data - Additional data to log
|
|
93
93
|
* @returns Formatted log message
|
|
94
94
|
*/
|
|
95
|
-
private formatMessage(
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
private formatMessage(
|
|
96
|
+
component: string,
|
|
97
|
+
level: LogLevel,
|
|
98
|
+
message: string,
|
|
99
|
+
data?: any
|
|
100
|
+
): string {
|
|
101
|
+
const prefix = this.getPrefix(component);
|
|
102
|
+
const levelName = LogLevel[level];
|
|
98
103
|
|
|
99
|
-
let formattedMessage = `${prefix} ${levelName} ${message}
|
|
104
|
+
let formattedMessage = `${prefix} ${levelName} ${message}`;
|
|
100
105
|
|
|
101
106
|
if (data !== undefined) {
|
|
102
|
-
formattedMessage += ` ${JSON.stringify(data)}
|
|
107
|
+
formattedMessage += ` ${JSON.stringify(data)}`;
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
return formattedMessage
|
|
110
|
+
return formattedMessage;
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
/**
|
|
@@ -112,11 +117,16 @@ class Logger {
|
|
|
112
117
|
* @param data - Additional data to log
|
|
113
118
|
*/
|
|
114
119
|
debug(component: string, message: string, data?: any): void {
|
|
115
|
-
if (!this.shouldLog(LogLevel.DEBUG)) return
|
|
120
|
+
if (!this.shouldLog(LogLevel.DEBUG)) return;
|
|
121
|
+
|
|
122
|
+
const formattedMessage = this.formatMessage(
|
|
123
|
+
component,
|
|
124
|
+
LogLevel.DEBUG,
|
|
125
|
+
message,
|
|
126
|
+
data
|
|
127
|
+
);
|
|
116
128
|
|
|
117
|
-
|
|
118
|
-
// eslint-disable-next-line no-console
|
|
119
|
-
console.log(formattedMessage)
|
|
129
|
+
console.log(formattedMessage);
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
/**
|
|
@@ -126,11 +136,16 @@ class Logger {
|
|
|
126
136
|
* @param data - Additional data to log
|
|
127
137
|
*/
|
|
128
138
|
info(component: string, message: string, data?: any): void {
|
|
129
|
-
if (!this.shouldLog(LogLevel.INFO)) return
|
|
139
|
+
if (!this.shouldLog(LogLevel.INFO)) return;
|
|
140
|
+
|
|
141
|
+
const formattedMessage = this.formatMessage(
|
|
142
|
+
component,
|
|
143
|
+
LogLevel.INFO,
|
|
144
|
+
message,
|
|
145
|
+
data
|
|
146
|
+
);
|
|
130
147
|
|
|
131
|
-
|
|
132
|
-
// eslint-disable-next-line no-console
|
|
133
|
-
console.log(formattedMessage)
|
|
148
|
+
console.log(formattedMessage);
|
|
134
149
|
}
|
|
135
150
|
|
|
136
151
|
/**
|
|
@@ -140,11 +155,16 @@ class Logger {
|
|
|
140
155
|
* @param data - Additional data to log
|
|
141
156
|
*/
|
|
142
157
|
warn(component: string, message: string, data?: any): void {
|
|
143
|
-
if (!this.shouldLog(LogLevel.WARN)) return
|
|
158
|
+
if (!this.shouldLog(LogLevel.WARN)) return;
|
|
144
159
|
|
|
145
|
-
const formattedMessage = this.formatMessage(
|
|
146
|
-
|
|
147
|
-
|
|
160
|
+
const formattedMessage = this.formatMessage(
|
|
161
|
+
component,
|
|
162
|
+
LogLevel.WARN,
|
|
163
|
+
message,
|
|
164
|
+
data
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
console.warn(formattedMessage);
|
|
148
168
|
}
|
|
149
169
|
|
|
150
170
|
/**
|
|
@@ -154,11 +174,16 @@ class Logger {
|
|
|
154
174
|
* @param data - Additional data to log
|
|
155
175
|
*/
|
|
156
176
|
error(component: string, message: string, data?: any): void {
|
|
157
|
-
if (!this.shouldLog(LogLevel.ERROR)) return
|
|
177
|
+
if (!this.shouldLog(LogLevel.ERROR)) return;
|
|
178
|
+
|
|
179
|
+
const formattedMessage = this.formatMessage(
|
|
180
|
+
component,
|
|
181
|
+
LogLevel.ERROR,
|
|
182
|
+
message,
|
|
183
|
+
data
|
|
184
|
+
);
|
|
158
185
|
|
|
159
|
-
|
|
160
|
-
// eslint-disable-next-line no-console
|
|
161
|
-
console.error(formattedMessage)
|
|
186
|
+
console.error(formattedMessage);
|
|
162
187
|
}
|
|
163
188
|
|
|
164
189
|
/**
|
|
@@ -168,18 +193,17 @@ class Logger {
|
|
|
168
193
|
* @param data - Additional data to log
|
|
169
194
|
*/
|
|
170
195
|
success(component: string, message: string, data?: any): void {
|
|
171
|
-
if (!this.shouldLog(LogLevel.INFO)) return
|
|
196
|
+
if (!this.shouldLog(LogLevel.INFO)) return;
|
|
172
197
|
|
|
173
|
-
const prefix = this.getPrefix(component)
|
|
174
|
-
const formattedMessage = `${prefix} ✅ ${message}
|
|
198
|
+
const prefix = this.getPrefix(component);
|
|
199
|
+
const formattedMessage = `${prefix} ✅ ${message}`;
|
|
175
200
|
|
|
176
|
-
let fullMessage = formattedMessage
|
|
201
|
+
let fullMessage = formattedMessage;
|
|
177
202
|
if (data !== undefined) {
|
|
178
|
-
fullMessage += ` ${JSON.stringify(data)}
|
|
203
|
+
fullMessage += ` ${JSON.stringify(data)}`;
|
|
179
204
|
}
|
|
180
205
|
|
|
181
|
-
|
|
182
|
-
console.log(fullMessage)
|
|
206
|
+
console.log(fullMessage);
|
|
183
207
|
}
|
|
184
208
|
|
|
185
209
|
/**
|
|
@@ -189,28 +213,33 @@ class Logger {
|
|
|
189
213
|
* @param data - Additional data to log
|
|
190
214
|
*/
|
|
191
215
|
failure(component: string, message: string, data?: any): void {
|
|
192
|
-
if (!this.shouldLog(LogLevel.ERROR)) return
|
|
216
|
+
if (!this.shouldLog(LogLevel.ERROR)) return;
|
|
193
217
|
|
|
194
|
-
const prefix = this.getPrefix(component)
|
|
195
|
-
const formattedMessage = `${prefix} ❌ ${message}
|
|
218
|
+
const prefix = this.getPrefix(component);
|
|
219
|
+
const formattedMessage = `${prefix} ❌ ${message}`;
|
|
196
220
|
|
|
197
|
-
let fullMessage = formattedMessage
|
|
221
|
+
let fullMessage = formattedMessage;
|
|
198
222
|
if (data !== undefined) {
|
|
199
|
-
fullMessage += ` ${JSON.stringify(data)}
|
|
223
|
+
fullMessage += ` ${JSON.stringify(data)}`;
|
|
200
224
|
}
|
|
201
225
|
|
|
202
|
-
|
|
203
|
-
console.error(fullMessage)
|
|
226
|
+
console.error(fullMessage);
|
|
204
227
|
}
|
|
205
228
|
}
|
|
206
229
|
|
|
207
230
|
// Export a singleton instance
|
|
208
|
-
export const logger = new Logger()
|
|
231
|
+
export const logger = new Logger();
|
|
209
232
|
|
|
210
233
|
// Export convenience functions for common use cases
|
|
211
|
-
export const logDebug = (component: string, message: string, data?: any) =>
|
|
212
|
-
|
|
213
|
-
export const
|
|
214
|
-
|
|
215
|
-
export const
|
|
216
|
-
|
|
234
|
+
export const logDebug = (component: string, message: string, data?: any) =>
|
|
235
|
+
logger.debug(component, message, data);
|
|
236
|
+
export const logInfo = (component: string, message: string, data?: any) =>
|
|
237
|
+
logger.info(component, message, data);
|
|
238
|
+
export const logWarn = (component: string, message: string, data?: any) =>
|
|
239
|
+
logger.warn(component, message, data);
|
|
240
|
+
export const logError = (component: string, message: string, data?: any) =>
|
|
241
|
+
logger.error(component, message, data);
|
|
242
|
+
export const logSuccess = (component: string, message: string, data?: any) =>
|
|
243
|
+
logger.success(component, message, data);
|
|
244
|
+
export const logFailure = (component: string, message: string, data?: any) =>
|
|
245
|
+
logger.failure(component, message, data);
|