@jaak.ai/stamps 2.1.0-dev.9 → 2.2.0-dev.1
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/README.md +42 -9
- package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
- package/dist/cjs/{index-BfhtOB0D.js → index-D6NBn_qu.js} +203 -121
- package/dist/cjs/index-D6NBn_qu.js.map +1 -0
- package/dist/cjs/jaak-stamps-webcomponent.cjs.js +5 -4
- package/dist/cjs/jaak-stamps-webcomponent.cjs.js.map +1 -1
- package/dist/cjs/jaak-stamps.cjs.entry.js +20219 -420
- package/dist/cjs/jaak-stamps.cjs.entry.js.map +1 -1
- package/dist/cjs/jaak-stamps.entry.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/my-component/my-component.css +83 -3
- package/dist/collection/components/my-component/my-component.js +521 -302
- package/dist/collection/components/my-component/my-component.js.map +1 -1
- package/dist/collection/services/CameraService.js +84 -2
- package/dist/collection/services/CameraService.js.map +1 -1
- package/dist/collection/services/DetectionService.js +7 -148
- package/dist/collection/services/DetectionService.js.map +1 -1
- package/dist/collection/services/LicenseValidationService.js +111 -0
- package/dist/collection/services/LicenseValidationService.js.map +1 -0
- package/dist/collection/services/MetricsService.js +350 -0
- package/dist/collection/services/MetricsService.js.map +1 -0
- package/dist/collection/services/ServiceContainer.js +66 -1
- package/dist/collection/services/ServiceContainer.js.map +1 -1
- package/dist/collection/services/TracingService.js +442 -0
- package/dist/collection/services/TracingService.js.map +1 -0
- package/dist/collection/services/interfaces/IDetectionService.js.map +1 -1
- package/dist/collection/services/interfaces/ILicenseValidationService.js +2 -0
- package/dist/collection/services/interfaces/ILicenseValidationService.js.map +1 -0
- package/dist/collection/services/interfaces/IMetricsService.js +2 -0
- package/dist/collection/services/interfaces/IMetricsService.js.map +1 -0
- package/dist/collection/services/interfaces/ITracingService.js +2 -0
- package/dist/collection/services/interfaces/ITracingService.js.map +1 -0
- package/dist/components/index.js +192 -115
- package/dist/components/index.js.map +1 -1
- package/dist/components/jaak-stamps.js +20235 -423
- package/dist/components/jaak-stamps.js.map +1 -1
- package/dist/esm/app-globals-DQuL1Twl.js +6 -0
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
- package/dist/esm/{index-BP1Q4KOg.js → index-BCfAsrzL.js} +204 -121
- package/dist/esm/index-BCfAsrzL.js.map +1 -0
- package/dist/esm/jaak-stamps-webcomponent.js +5 -4
- package/dist/esm/jaak-stamps-webcomponent.js.map +1 -1
- package/dist/esm/jaak-stamps.entry.js +20219 -420
- package/dist/esm/jaak-stamps.entry.js.map +1 -1
- package/dist/esm/loader.js +4 -3
- package/dist/esm/loader.js.map +1 -1
- package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js +1 -1
- package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js.map +1 -1
- package/dist/jaak-stamps-webcomponent/jaak-stamps.entry.esm.js.map +1 -1
- package/dist/jaak-stamps-webcomponent/loader.esm.js.map +1 -1
- package/dist/jaak-stamps-webcomponent/p-8c49893d.entry.js +7 -0
- package/dist/jaak-stamps-webcomponent/p-8c49893d.entry.js.map +1 -0
- package/dist/jaak-stamps-webcomponent/p-BCfAsrzL.js +3 -0
- package/dist/jaak-stamps-webcomponent/p-BCfAsrzL.js.map +1 -0
- package/dist/jaak-stamps-webcomponent/p-DQuL1Twl.js +2 -0
- package/dist/jaak-stamps-webcomponent/p-DQuL1Twl.js.map +1 -0
- package/dist/types/components/my-component/my-component.d.ts +24 -27
- package/dist/types/components.d.ts +77 -3
- package/dist/types/services/CameraService.d.ts +1 -0
- package/dist/types/services/DetectionService.d.ts +1 -9
- package/dist/types/services/LicenseValidationService.d.ts +59 -0
- package/dist/types/services/MetricsService.d.ts +74 -0
- package/dist/types/services/ServiceContainer.d.ts +14 -1
- package/dist/types/services/TracingService.d.ts +67 -0
- package/dist/types/services/interfaces/IDetectionService.d.ts +0 -6
- package/dist/types/services/interfaces/ILicenseValidationService.d.ts +4 -0
- package/dist/types/services/interfaces/IMetricsService.d.ts +70 -0
- package/dist/types/services/interfaces/ITracingService.d.ts +59 -0
- package/dist/types/stencil-public-runtime.d.ts +12 -5
- package/package.json +20 -2
- package/dist/cjs/index-BfhtOB0D.js.map +0 -1
- package/dist/esm/index-BP1Q4KOg.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js +0 -3
- package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-c115e01a.entry.js +0 -2
- package/dist/jaak-stamps-webcomponent/p-c115e01a.entry.js.map +0 -1
|
@@ -12,8 +12,24 @@ export declare class JaakStamps {
|
|
|
12
12
|
captureDelay: number;
|
|
13
13
|
enableBackDocumentTimer: boolean;
|
|
14
14
|
backDocumentTimerDuration: number;
|
|
15
|
+
telemetryCollectorUrl?: string;
|
|
16
|
+
metricsCollectorUrl?: string;
|
|
17
|
+
enableTelemetry: boolean;
|
|
18
|
+
enableMetrics: boolean;
|
|
19
|
+
customerId?: string;
|
|
20
|
+
tenantId?: string;
|
|
21
|
+
environment?: string;
|
|
22
|
+
propagateTraceHeaderCorsUrls?: string;
|
|
23
|
+
metricsExportIntervalMillis?: number;
|
|
24
|
+
license?: string;
|
|
25
|
+
licenseEnvironment?: 'dev' | 'qa' | 'staging' | 'prod';
|
|
26
|
+
traceId?: string;
|
|
27
|
+
appId?: string;
|
|
15
28
|
captureCompleted: EventEmitter<any>;
|
|
16
29
|
isReady: EventEmitter<boolean>;
|
|
30
|
+
traceIdGenerated: EventEmitter<{
|
|
31
|
+
traceId: string;
|
|
32
|
+
}>;
|
|
17
33
|
detectionBoxes: Array<{
|
|
18
34
|
x: number;
|
|
19
35
|
y: number;
|
|
@@ -66,11 +82,16 @@ export declare class JaakStamps {
|
|
|
66
82
|
showPerformanceMessage: boolean;
|
|
67
83
|
captureStateVersion: number;
|
|
68
84
|
processingButton: 'capture-front' | 'capture-back' | 'skip-back' | null;
|
|
85
|
+
licenseValid: boolean;
|
|
86
|
+
licenseError: string | null;
|
|
87
|
+
private licenseValidationService;
|
|
69
88
|
private serviceContainer;
|
|
70
89
|
private eventBus;
|
|
71
90
|
private stateManager;
|
|
72
91
|
private cameraService;
|
|
73
92
|
private detectionService;
|
|
93
|
+
private tracingService;
|
|
94
|
+
private metricsService;
|
|
74
95
|
private videoRef?;
|
|
75
96
|
private detectionContainer?;
|
|
76
97
|
private videoStream?;
|
|
@@ -81,6 +102,7 @@ export declare class JaakStamps {
|
|
|
81
102
|
private alignmentStartTime?;
|
|
82
103
|
private alignmentTimer?;
|
|
83
104
|
private backDocumentTimer?;
|
|
105
|
+
private orientationTimer?;
|
|
84
106
|
private performanceMetrics;
|
|
85
107
|
private performanceUpdateInterval?;
|
|
86
108
|
private frameSkipCounter;
|
|
@@ -99,8 +121,10 @@ export declare class JaakStamps {
|
|
|
99
121
|
private hasAutoSwitchedToManual;
|
|
100
122
|
private canvasPool;
|
|
101
123
|
private readonly MAX_CANVAS_POOL_SIZE;
|
|
124
|
+
componentWillLoad(): Promise<void>;
|
|
102
125
|
componentDidLoad(): Promise<void>;
|
|
103
126
|
private initializeServices;
|
|
127
|
+
private validateLicense;
|
|
104
128
|
private setupEventListeners;
|
|
105
129
|
private initializeComponent;
|
|
106
130
|
private validateProps;
|
|
@@ -127,14 +151,10 @@ export declare class JaakStamps {
|
|
|
127
151
|
}>;
|
|
128
152
|
stopCapture(): Promise<{
|
|
129
153
|
success: boolean;
|
|
130
|
-
resourcesFreed: string[];
|
|
131
|
-
cleanupErrors: string[];
|
|
132
154
|
error?: undefined;
|
|
133
155
|
} | {
|
|
134
156
|
success: boolean;
|
|
135
157
|
error: any;
|
|
136
|
-
resourcesFreed?: undefined;
|
|
137
|
-
cleanupErrors?: undefined;
|
|
138
158
|
}>;
|
|
139
159
|
resetCapture(): Promise<{
|
|
140
160
|
success: boolean;
|
|
@@ -182,35 +202,12 @@ export declare class JaakStamps {
|
|
|
182
202
|
error?: undefined;
|
|
183
203
|
}>;
|
|
184
204
|
getCaptureDelay(): Promise<number>;
|
|
185
|
-
getResourceReport(): Promise<any>;
|
|
186
|
-
forceResourceCleanup(): Promise<{
|
|
187
|
-
success: boolean;
|
|
188
|
-
resourcesFreed: string[];
|
|
189
|
-
errors: string[];
|
|
190
|
-
timestamp: string;
|
|
191
|
-
error?: undefined;
|
|
192
|
-
} | {
|
|
193
|
-
success: boolean;
|
|
194
|
-
error: any;
|
|
195
|
-
resourcesFreed?: undefined;
|
|
196
|
-
errors?: undefined;
|
|
197
|
-
timestamp?: undefined;
|
|
198
|
-
}>;
|
|
199
205
|
private checkDeviceCapabilities;
|
|
200
206
|
private startDetection;
|
|
201
207
|
private initializeVideoStream;
|
|
202
208
|
private detectFrame;
|
|
203
209
|
disconnectedCallback(): void;
|
|
204
210
|
private cleanup;
|
|
205
|
-
private cleanupDOMReferences;
|
|
206
|
-
private clearBrowserCache;
|
|
207
|
-
private clearLocalStorage;
|
|
208
|
-
aggressiveResourceCleanup(): Promise<{
|
|
209
|
-
freed: string[];
|
|
210
|
-
errors: string[];
|
|
211
|
-
}>;
|
|
212
|
-
onFrontCaptureComplete(): Promise<void>;
|
|
213
|
-
getResourceReportInternal(): any;
|
|
214
211
|
render(): any;
|
|
215
212
|
private updateDetectionBoxes;
|
|
216
213
|
private updateMaskColor;
|
|
@@ -13,6 +13,10 @@ export namespace Components {
|
|
|
13
13
|
* @default 15
|
|
14
14
|
*/
|
|
15
15
|
"alignmentTolerance": number;
|
|
16
|
+
/**
|
|
17
|
+
* @default 'jaak-stamps-web'
|
|
18
|
+
*/
|
|
19
|
+
"appId"?: string;
|
|
16
20
|
/**
|
|
17
21
|
* @default 20
|
|
18
22
|
*/
|
|
@@ -25,6 +29,7 @@ export namespace Components {
|
|
|
25
29
|
* @default 20
|
|
26
30
|
*/
|
|
27
31
|
"cropMargin": number;
|
|
32
|
+
"customerId"?: string;
|
|
28
33
|
/**
|
|
29
34
|
* @default false
|
|
30
35
|
*/
|
|
@@ -33,28 +38,58 @@ export namespace Components {
|
|
|
33
38
|
* @default false
|
|
34
39
|
*/
|
|
35
40
|
"enableBackDocumentTimer": boolean;
|
|
36
|
-
|
|
41
|
+
/**
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
"enableMetrics": boolean;
|
|
45
|
+
/**
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
"enableTelemetry": boolean;
|
|
49
|
+
/**
|
|
50
|
+
* @default 'production'
|
|
51
|
+
*/
|
|
52
|
+
"environment"?: string;
|
|
37
53
|
"getCameraInfo": () => Promise<CameraInfoResponse>;
|
|
38
54
|
"getCaptureDelay": () => Promise<number>;
|
|
39
55
|
"getCapturedImages": () => Promise<CapturedImagesResponse>;
|
|
40
|
-
"getResourceReport": () => Promise<any>;
|
|
41
56
|
"getStatus": () => Promise<StatusResponse>;
|
|
42
57
|
"isProcessCompleted": () => Promise<boolean>;
|
|
58
|
+
"license"?: string;
|
|
59
|
+
/**
|
|
60
|
+
* @default 'prod'
|
|
61
|
+
*/
|
|
62
|
+
"licenseEnvironment"?: 'dev' | 'qa' | 'staging' | 'prod';
|
|
43
63
|
/**
|
|
44
64
|
* @default 90
|
|
45
65
|
*/
|
|
46
66
|
"maskSize": number;
|
|
67
|
+
/**
|
|
68
|
+
* @default 'https://collector.jaak.ai/v1/metrics'
|
|
69
|
+
*/
|
|
70
|
+
"metricsCollectorUrl"?: string;
|
|
71
|
+
/**
|
|
72
|
+
* @default 60000
|
|
73
|
+
*/
|
|
74
|
+
"metricsExportIntervalMillis"?: number;
|
|
47
75
|
/**
|
|
48
76
|
* @default 'auto'
|
|
49
77
|
*/
|
|
50
78
|
"preferredCamera": 'auto' | 'front' | 'back';
|
|
51
79
|
"preloadModel": () => Promise<{ success: boolean; message: string; error?: undefined; } | { success: boolean; error: any; message?: undefined; }>;
|
|
80
|
+
"propagateTraceHeaderCorsUrls"?: string;
|
|
52
81
|
"resetCapture": () => Promise<{ success: boolean; error?: undefined; } | { success: boolean; error: any; }>;
|
|
53
82
|
"setCaptureDelay": (delay: number) => Promise<{ success: boolean; error: string; captureDelay: number; } | { success: boolean; captureDelay: number; error?: undefined; }>;
|
|
54
83
|
"setPreferredCamera": (camera: "auto" | "front" | "back") => Promise<{ success: boolean; selectedCamera: string; availableCameras: number; error?: undefined; } | { success: boolean; error: any; selectedCamera: any; availableCameras: number; }>;
|
|
55
84
|
"skipBackCapture": () => Promise<{ success: boolean; error?: undefined; } | { success: boolean; error: any; }>;
|
|
56
85
|
"startCapture": () => Promise<{ success: boolean; error?: undefined; } | { success: boolean; error: any; }>;
|
|
57
|
-
"stopCapture": () => Promise<{ success: boolean;
|
|
86
|
+
"stopCapture": () => Promise<{ success: boolean; error?: undefined; } | { success: boolean; error: any; }>;
|
|
87
|
+
/**
|
|
88
|
+
* @default 'https://collector.jaak.ai/v1/traces'
|
|
89
|
+
*/
|
|
90
|
+
"telemetryCollectorUrl"?: string;
|
|
91
|
+
"tenantId"?: string;
|
|
92
|
+
"traceId"?: string;
|
|
58
93
|
/**
|
|
59
94
|
* @default false
|
|
60
95
|
*/
|
|
@@ -73,6 +108,7 @@ declare global {
|
|
|
73
108
|
interface HTMLJaakStampsElementEventMap {
|
|
74
109
|
"captureCompleted": any;
|
|
75
110
|
"isReady": boolean;
|
|
111
|
+
"traceIdGenerated": {traceId: string};
|
|
76
112
|
}
|
|
77
113
|
interface HTMLJaakStampsElement extends Components.JaakStamps, HTMLStencilElement {
|
|
78
114
|
addEventListener<K extends keyof HTMLJaakStampsElementEventMap>(type: K, listener: (this: HTMLJaakStampsElement, ev: JaakStampsCustomEvent<HTMLJaakStampsElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -98,6 +134,10 @@ declare namespace LocalJSX {
|
|
|
98
134
|
* @default 15
|
|
99
135
|
*/
|
|
100
136
|
"alignmentTolerance"?: number;
|
|
137
|
+
/**
|
|
138
|
+
* @default 'jaak-stamps-web'
|
|
139
|
+
*/
|
|
140
|
+
"appId"?: string;
|
|
101
141
|
/**
|
|
102
142
|
* @default 20
|
|
103
143
|
*/
|
|
@@ -110,6 +150,7 @@ declare namespace LocalJSX {
|
|
|
110
150
|
* @default 20
|
|
111
151
|
*/
|
|
112
152
|
"cropMargin"?: number;
|
|
153
|
+
"customerId"?: string;
|
|
113
154
|
/**
|
|
114
155
|
* @default false
|
|
115
156
|
*/
|
|
@@ -118,16 +159,49 @@ declare namespace LocalJSX {
|
|
|
118
159
|
* @default false
|
|
119
160
|
*/
|
|
120
161
|
"enableBackDocumentTimer"?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* @default true
|
|
164
|
+
*/
|
|
165
|
+
"enableMetrics"?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* @default true
|
|
168
|
+
*/
|
|
169
|
+
"enableTelemetry"?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* @default 'production'
|
|
172
|
+
*/
|
|
173
|
+
"environment"?: string;
|
|
174
|
+
"license"?: string;
|
|
175
|
+
/**
|
|
176
|
+
* @default 'prod'
|
|
177
|
+
*/
|
|
178
|
+
"licenseEnvironment"?: 'dev' | 'qa' | 'staging' | 'prod';
|
|
121
179
|
/**
|
|
122
180
|
* @default 90
|
|
123
181
|
*/
|
|
124
182
|
"maskSize"?: number;
|
|
183
|
+
/**
|
|
184
|
+
* @default 'https://collector.jaak.ai/v1/metrics'
|
|
185
|
+
*/
|
|
186
|
+
"metricsCollectorUrl"?: string;
|
|
187
|
+
/**
|
|
188
|
+
* @default 60000
|
|
189
|
+
*/
|
|
190
|
+
"metricsExportIntervalMillis"?: number;
|
|
125
191
|
"onCaptureCompleted"?: (event: JaakStampsCustomEvent<any>) => void;
|
|
126
192
|
"onIsReady"?: (event: JaakStampsCustomEvent<boolean>) => void;
|
|
193
|
+
"onTraceIdGenerated"?: (event: JaakStampsCustomEvent<{traceId: string}>) => void;
|
|
127
194
|
/**
|
|
128
195
|
* @default 'auto'
|
|
129
196
|
*/
|
|
130
197
|
"preferredCamera"?: 'auto' | 'front' | 'back';
|
|
198
|
+
"propagateTraceHeaderCorsUrls"?: string;
|
|
199
|
+
/**
|
|
200
|
+
* @default 'https://collector.jaak.ai/v1/traces'
|
|
201
|
+
*/
|
|
202
|
+
"telemetryCollectorUrl"?: string;
|
|
203
|
+
"tenantId"?: string;
|
|
204
|
+
"traceId"?: string;
|
|
131
205
|
/**
|
|
132
206
|
* @default false
|
|
133
207
|
*/
|
|
@@ -18,9 +18,6 @@ export declare class DetectionService implements IDetectionService {
|
|
|
18
18
|
private captureCanvas?;
|
|
19
19
|
private static canvasPool;
|
|
20
20
|
private static readonly MAX_POOL_SIZE;
|
|
21
|
-
private modelLoadController?;
|
|
22
|
-
private classificationLoadController?;
|
|
23
|
-
private modelBlobUrls;
|
|
24
21
|
constructor(debug?: boolean, useDocumentClassification?: boolean, useDocumentDetector?: boolean);
|
|
25
22
|
loadModel(): Promise<void>;
|
|
26
23
|
loadClassificationModel(): Promise<void>;
|
|
@@ -38,12 +35,7 @@ export declare class DetectionService implements IDetectionService {
|
|
|
38
35
|
private preprocessMobileNet;
|
|
39
36
|
private getCanvas;
|
|
40
37
|
private returnCanvas;
|
|
41
|
-
|
|
42
|
-
private abortPendingRequests;
|
|
43
|
-
private revokeModelBlobUrls;
|
|
44
|
-
releaseMobileNetResources(): Promise<void>;
|
|
45
|
-
optimizeCanvasPool(maxSize: number): void;
|
|
46
|
-
static clearAllCanvasPools(): void;
|
|
38
|
+
static clearCanvasPools(): void;
|
|
47
39
|
getPoolStats(): {
|
|
48
40
|
[key: string]: number;
|
|
49
41
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* License Validation Service
|
|
3
|
+
* Handles license validation for the jaak-stamps webcomponent
|
|
4
|
+
*/
|
|
5
|
+
export type Environment = 'dev' | 'qa' | 'staging' | 'prod';
|
|
6
|
+
export interface LicenseValidationRequest {
|
|
7
|
+
license: string;
|
|
8
|
+
origin: string;
|
|
9
|
+
app_id?: string;
|
|
10
|
+
product?: string;
|
|
11
|
+
product_version?: string;
|
|
12
|
+
metadata?: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface LicenseValidationResponse {
|
|
17
|
+
access_token: string;
|
|
18
|
+
token_type: string;
|
|
19
|
+
expires_at: string;
|
|
20
|
+
session_id: string;
|
|
21
|
+
jti: string;
|
|
22
|
+
step: number;
|
|
23
|
+
license: string;
|
|
24
|
+
traceId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface LicenseValidationError {
|
|
27
|
+
error: string;
|
|
28
|
+
error_description?: string;
|
|
29
|
+
status_code?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare class LicenseValidationService {
|
|
32
|
+
private apiEndpoint;
|
|
33
|
+
private baseUrl;
|
|
34
|
+
private static readonly ENVIRONMENT_URLS;
|
|
35
|
+
constructor(environment?: Environment);
|
|
36
|
+
/**
|
|
37
|
+
* Validate license with the API
|
|
38
|
+
* @param license License key to validate
|
|
39
|
+
* @param traceId Optional trace ID from W3C Trace Context
|
|
40
|
+
* @param appId Optional application ID
|
|
41
|
+
* @param metadata Optional additional metadata
|
|
42
|
+
* @returns Promise<LicenseValidationResponse>
|
|
43
|
+
*/
|
|
44
|
+
validateLicense(license: string, traceId?: string, appId?: string): Promise<LicenseValidationResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Generate a random trace ID for W3C Trace Context (32 hex characters)
|
|
47
|
+
*/
|
|
48
|
+
private generateTraceId;
|
|
49
|
+
/**
|
|
50
|
+
* Generate a random span ID for W3C Trace Context (16 hex characters)
|
|
51
|
+
*/
|
|
52
|
+
private generateSpanId;
|
|
53
|
+
/**
|
|
54
|
+
* Extract trace ID from license field
|
|
55
|
+
* License format: "L<32-hex-chars>"
|
|
56
|
+
* Example: "Ld79223833a2fd91971e4c14a33298904" -> "d79223833a2fd91971e4c14a33298904"
|
|
57
|
+
*/
|
|
58
|
+
static extractTraceIdFromLicense(license: string): string | null;
|
|
59
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { IMetricsService } from './interfaces/IMetricsService';
|
|
2
|
+
export interface MetricsConfig {
|
|
3
|
+
collectorUrl?: string;
|
|
4
|
+
serviceName?: string;
|
|
5
|
+
serviceVersion?: string;
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
customerId?: string;
|
|
8
|
+
tenantId?: string;
|
|
9
|
+
environment?: string;
|
|
10
|
+
exportIntervalMillis?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class MetricsService implements IMetricsService {
|
|
13
|
+
private meterProvider;
|
|
14
|
+
private meter;
|
|
15
|
+
private readonly collectorUrl;
|
|
16
|
+
private readonly serviceName;
|
|
17
|
+
private readonly serviceVersion;
|
|
18
|
+
private readonly debug;
|
|
19
|
+
private readonly customerId?;
|
|
20
|
+
private readonly tenantId?;
|
|
21
|
+
private readonly environment?;
|
|
22
|
+
private readonly exportIntervalMillis;
|
|
23
|
+
private metricReader;
|
|
24
|
+
private captureCounter;
|
|
25
|
+
private errorCounter;
|
|
26
|
+
private modelLoadCounter;
|
|
27
|
+
private userInteractionCounter;
|
|
28
|
+
private captureLatencyHistogram;
|
|
29
|
+
private modelLoadLatencyHistogram;
|
|
30
|
+
private detectionLatencyHistogram;
|
|
31
|
+
private imageSizeHistogram;
|
|
32
|
+
private activeSessionsGauge;
|
|
33
|
+
private memoryUsageGauge;
|
|
34
|
+
private activeSessions;
|
|
35
|
+
private gaugeValues;
|
|
36
|
+
constructor(config?: MetricsConfig);
|
|
37
|
+
initialize(): void;
|
|
38
|
+
private initializeMetrics;
|
|
39
|
+
private getBaseAttributes;
|
|
40
|
+
incrementCounter(name: string, value?: number, attributes?: Record<string, any>): void;
|
|
41
|
+
recordHistogram(name: string, value: number, attributes?: Record<string, any>): void;
|
|
42
|
+
setGauge(name: string, value: number, attributes?: Record<string, any>): void;
|
|
43
|
+
measureDuration<T>(name: string, fn: () => T | Promise<T>, attributes?: Record<string, any>): Promise<T>;
|
|
44
|
+
flush(): Promise<void>;
|
|
45
|
+
cleanup(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Record a successful capture
|
|
48
|
+
*/
|
|
49
|
+
recordCapture(side: 'front' | 'back', mode: 'auto' | 'manual', durationMs: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Record an error
|
|
52
|
+
*/
|
|
53
|
+
recordError(errorType: string, operation: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Record model load performance
|
|
56
|
+
*/
|
|
57
|
+
recordModelLoad(modelType: 'detection' | 'classification', durationMs: number, cached: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* Record detection performance
|
|
60
|
+
*/
|
|
61
|
+
recordDetection(durationMs: number, detectionsFound: number): void;
|
|
62
|
+
/**
|
|
63
|
+
* Record image size
|
|
64
|
+
*/
|
|
65
|
+
recordImageSize(side: 'front' | 'back', sizeBytes: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Update active sessions count
|
|
68
|
+
*/
|
|
69
|
+
updateActiveSessions(count: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* Record user interaction
|
|
72
|
+
*/
|
|
73
|
+
recordUserInteraction(interactionType: string): void;
|
|
74
|
+
}
|
|
@@ -2,6 +2,8 @@ import { ICameraService } from './interfaces/ICameraService';
|
|
|
2
2
|
import { IDetectionService } from './interfaces/IDetectionService';
|
|
3
3
|
import { IStateManager } from './interfaces/IStateManager';
|
|
4
4
|
import { IEventBus } from './interfaces/IEventBus';
|
|
5
|
+
import { ITracingService } from './interfaces/ITracingService';
|
|
6
|
+
import { IMetricsService } from './interfaces/IMetricsService';
|
|
5
7
|
export interface ComponentConfig {
|
|
6
8
|
debug: boolean;
|
|
7
9
|
alignmentTolerance: number;
|
|
@@ -11,6 +13,15 @@ export interface ComponentConfig {
|
|
|
11
13
|
useDocumentDetector: boolean;
|
|
12
14
|
preferredCamera: 'auto' | 'front' | 'back';
|
|
13
15
|
captureDelay: number;
|
|
16
|
+
telemetryCollectorUrl?: string;
|
|
17
|
+
metricsCollectorUrl?: string;
|
|
18
|
+
enableTelemetry?: boolean;
|
|
19
|
+
enableMetrics?: boolean;
|
|
20
|
+
customerId?: string;
|
|
21
|
+
tenantId?: string;
|
|
22
|
+
environment?: string;
|
|
23
|
+
propagateTraceHeaderCorsUrls?: (string | RegExp)[];
|
|
24
|
+
metricsExportIntervalMillis?: number;
|
|
14
25
|
}
|
|
15
26
|
export declare class ServiceContainer {
|
|
16
27
|
private services;
|
|
@@ -21,6 +32,8 @@ export declare class ServiceContainer {
|
|
|
21
32
|
getStateManager(): IStateManager;
|
|
22
33
|
getCameraService(): ICameraService;
|
|
23
34
|
getDetectionService(): IDetectionService;
|
|
35
|
+
getTracingService(): ITracingService | null;
|
|
36
|
+
getMetricsService(): IMetricsService | null;
|
|
24
37
|
updateConfig(config: Partial<ComponentConfig>): void;
|
|
25
|
-
cleanup(): void
|
|
38
|
+
cleanup(): Promise<void>;
|
|
26
39
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ITracingService } from './interfaces/ITracingService';
|
|
2
|
+
import { Span } from '@opentelemetry/api';
|
|
3
|
+
export interface TracingConfig {
|
|
4
|
+
collectorUrl?: string;
|
|
5
|
+
serviceName?: string;
|
|
6
|
+
serviceVersion?: string;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
customerId?: string;
|
|
9
|
+
tenantId?: string;
|
|
10
|
+
environment?: string;
|
|
11
|
+
propagateTraceHeaderCorsUrls?: (string | RegExp)[];
|
|
12
|
+
enableAutoInstrumentation?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class TracingService implements ITracingService {
|
|
15
|
+
private provider;
|
|
16
|
+
private tracer;
|
|
17
|
+
private sessionTraceId;
|
|
18
|
+
private readonly collectorUrl;
|
|
19
|
+
private readonly serviceName;
|
|
20
|
+
private readonly serviceVersion;
|
|
21
|
+
private readonly debug;
|
|
22
|
+
private readonly customerId?;
|
|
23
|
+
private readonly tenantId?;
|
|
24
|
+
private readonly environment?;
|
|
25
|
+
private readonly propagateTraceHeaderCorsUrls;
|
|
26
|
+
private readonly enableAutoInstrumentation;
|
|
27
|
+
private spanProcessor;
|
|
28
|
+
private parser;
|
|
29
|
+
private geoCache;
|
|
30
|
+
private geoCacheTimestamp;
|
|
31
|
+
private readonly GEO_CACHE_DURATION_MS;
|
|
32
|
+
constructor(config?: TracingConfig);
|
|
33
|
+
initialize(): void;
|
|
34
|
+
private initializeAutoInstrumentation;
|
|
35
|
+
private getDeviceInfo;
|
|
36
|
+
private getBrowserInfo;
|
|
37
|
+
private getOSInfo;
|
|
38
|
+
/**
|
|
39
|
+
* Set the session trace ID from external source (license or component prop)
|
|
40
|
+
* @param traceId - The trace ID to use for all spans (32 hex characters)
|
|
41
|
+
*/
|
|
42
|
+
setSessionTraceId(traceId: string | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get the current session trace ID
|
|
45
|
+
*/
|
|
46
|
+
getSessionTraceId(): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Generate a random span ID (16 hex characters)
|
|
49
|
+
*/
|
|
50
|
+
private generateSpanId;
|
|
51
|
+
private getGeoLocation;
|
|
52
|
+
startSpan(name: string, attributes?: Record<string, any>): Span;
|
|
53
|
+
endSpan(span: Span): void;
|
|
54
|
+
addSpanEvent(span: Span, name: string, attributes?: Record<string, any>): void;
|
|
55
|
+
recordException(span: Span, error: Error): void;
|
|
56
|
+
setSpanAttribute(span: Span, key: string, value: any): void;
|
|
57
|
+
trace<T>(name: string, fn: () => T | Promise<T>, attributes?: Record<string, any>): Promise<T>;
|
|
58
|
+
cleanup(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Get the current trace ID (useful for logging correlation)
|
|
61
|
+
*/
|
|
62
|
+
getCurrentTraceId(): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Get the current span ID
|
|
65
|
+
*/
|
|
66
|
+
getCurrentSpanId(): string | undefined;
|
|
67
|
+
}
|
|
@@ -28,10 +28,4 @@ export interface IDetectionService {
|
|
|
28
28
|
isCardInFrame(box: DetectionBox): boolean;
|
|
29
29
|
areAllSidesAligned(alignment: SideAlignment): boolean;
|
|
30
30
|
cleanup(): void;
|
|
31
|
-
clearModelCache(): Promise<void>;
|
|
32
|
-
releaseMobileNetResources(): Promise<void>;
|
|
33
|
-
optimizeCanvasPool(maxSize: number): void;
|
|
34
|
-
getPoolStats(): {
|
|
35
|
-
[key: string]: number;
|
|
36
|
-
};
|
|
37
31
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export interface IMetricsService {
|
|
2
|
+
/**
|
|
3
|
+
* Initializes the metrics service with the collector endpoint
|
|
4
|
+
*/
|
|
5
|
+
initialize(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Increments a counter metric
|
|
8
|
+
* @param name - Name of the counter
|
|
9
|
+
* @param value - Value to add (default: 1)
|
|
10
|
+
* @param attributes - Optional attributes
|
|
11
|
+
*/
|
|
12
|
+
incrementCounter(name: string, value?: number, attributes?: Record<string, any>): void;
|
|
13
|
+
/**
|
|
14
|
+
* Records a histogram value (for latencies, sizes, etc.)
|
|
15
|
+
* @param name - Name of the histogram
|
|
16
|
+
* @param value - Value to record
|
|
17
|
+
* @param attributes - Optional attributes
|
|
18
|
+
*/
|
|
19
|
+
recordHistogram(name: string, value: number, attributes?: Record<string, any>): void;
|
|
20
|
+
/**
|
|
21
|
+
* Sets a gauge value (for current state values)
|
|
22
|
+
* @param name - Name of the gauge
|
|
23
|
+
* @param value - Current value
|
|
24
|
+
* @param attributes - Optional attributes
|
|
25
|
+
*/
|
|
26
|
+
setGauge(name: string, value: number, attributes?: Record<string, any>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Records operation duration automatically
|
|
29
|
+
* @param name - Name of the operation
|
|
30
|
+
* @param fn - Function to measure
|
|
31
|
+
* @param attributes - Optional attributes
|
|
32
|
+
*/
|
|
33
|
+
measureDuration<T>(name: string, fn: () => T | Promise<T>, attributes?: Record<string, any>): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Forces flush of metrics
|
|
36
|
+
*/
|
|
37
|
+
flush(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Cleans up resources
|
|
40
|
+
*/
|
|
41
|
+
cleanup(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Record a successful capture
|
|
44
|
+
*/
|
|
45
|
+
recordCapture(side: 'front' | 'back', mode: 'auto' | 'manual', durationMs: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Record an error
|
|
48
|
+
*/
|
|
49
|
+
recordError(errorType: string, operation: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Record model load performance
|
|
52
|
+
*/
|
|
53
|
+
recordModelLoad(modelType: 'detection' | 'classification', durationMs: number, cached: boolean): void;
|
|
54
|
+
/**
|
|
55
|
+
* Record detection performance
|
|
56
|
+
*/
|
|
57
|
+
recordDetection(durationMs: number, detectionsFound: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* Record image size
|
|
60
|
+
*/
|
|
61
|
+
recordImageSize(side: 'front' | 'back', sizeBytes: number): void;
|
|
62
|
+
/**
|
|
63
|
+
* Update active sessions count
|
|
64
|
+
*/
|
|
65
|
+
updateActiveSessions(count: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Record user interaction
|
|
68
|
+
*/
|
|
69
|
+
recordUserInteraction(interactionType: string): void;
|
|
70
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Span } from '@opentelemetry/api';
|
|
2
|
+
export interface ITracingService {
|
|
3
|
+
/**
|
|
4
|
+
* Initializes the tracing service with the collector endpoint
|
|
5
|
+
*/
|
|
6
|
+
initialize(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Starts a new span with the given name
|
|
9
|
+
* @param name - Name of the span
|
|
10
|
+
* @param attributes - Optional attributes to add to the span
|
|
11
|
+
* @returns The created span
|
|
12
|
+
*/
|
|
13
|
+
startSpan(name: string, attributes?: Record<string, any>): Span;
|
|
14
|
+
/**
|
|
15
|
+
* Ends a span
|
|
16
|
+
* @param span - The span to end
|
|
17
|
+
*/
|
|
18
|
+
endSpan(span: Span): void;
|
|
19
|
+
/**
|
|
20
|
+
* Adds an event to a span
|
|
21
|
+
* @param span - The span to add the event to
|
|
22
|
+
* @param name - Name of the event
|
|
23
|
+
* @param attributes - Optional attributes for the event
|
|
24
|
+
*/
|
|
25
|
+
addSpanEvent(span: Span, name: string, attributes?: Record<string, any>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Records an exception in a span
|
|
28
|
+
* @param span - The span to record the exception in
|
|
29
|
+
* @param error - The error to record
|
|
30
|
+
*/
|
|
31
|
+
recordException(span: Span, error: Error): void;
|
|
32
|
+
/**
|
|
33
|
+
* Sets an attribute on a span
|
|
34
|
+
* @param span - The span to set the attribute on
|
|
35
|
+
* @param key - Attribute key
|
|
36
|
+
* @param value - Attribute value
|
|
37
|
+
*/
|
|
38
|
+
setSpanAttribute(span: Span, key: string, value: any): void;
|
|
39
|
+
/**
|
|
40
|
+
* Wraps a function with automatic span creation
|
|
41
|
+
* @param name - Name of the span
|
|
42
|
+
* @param fn - Function to wrap
|
|
43
|
+
* @param attributes - Optional attributes
|
|
44
|
+
*/
|
|
45
|
+
trace<T>(name: string, fn: () => T | Promise<T>, attributes?: Record<string, any>): Promise<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Cleans up resources
|
|
48
|
+
*/
|
|
49
|
+
cleanup(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Set the session trace ID from external source (license or component prop)
|
|
52
|
+
* @param traceId - The trace ID to use for all spans (32 hex characters)
|
|
53
|
+
*/
|
|
54
|
+
setSessionTraceId(traceId: string | null): void;
|
|
55
|
+
/**
|
|
56
|
+
* Get the current session trace ID
|
|
57
|
+
*/
|
|
58
|
+
getSessionTraceId(): string | null;
|
|
59
|
+
}
|