@jaak.ai/stamps 2.1.0 → 2.2.0-dev.10
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/{index-Ga0t6BMe.js → index-D6NBn_qu.js} +30 -5
- package/dist/cjs/index-D6NBn_qu.js.map +1 -0
- package/dist/cjs/jaak-stamps-webcomponent.cjs.js +2 -2
- package/dist/cjs/jaak-stamps.cjs.entry.js +17577 -12
- 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 +2 -2
- package/dist/collection/components/my-component/my-component.css +82 -2
- package/dist/collection/components/my-component/my-component.js +489 -10
- package/dist/collection/components/my-component/my-component.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 +494 -0
- package/dist/collection/services/TracingService.js.map +1 -0
- 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 +28 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/jaak-stamps.js +17591 -11
- package/dist/components/jaak-stamps.js.map +1 -1
- package/dist/esm/{index-Drbzcuq-.js → index-BCfAsrzL.js} +30 -5
- package/dist/esm/index-BCfAsrzL.js.map +1 -0
- package/dist/esm/jaak-stamps-webcomponent.js +3 -3
- package/dist/esm/jaak-stamps.entry.js +17577 -12
- package/dist/esm/jaak-stamps.entry.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js +1 -1
- package/dist/jaak-stamps-webcomponent/jaak-stamps.entry.esm.js.map +1 -1
- package/dist/jaak-stamps-webcomponent/p-37281823.entry.js +7 -0
- package/dist/jaak-stamps-webcomponent/p-37281823.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/types/components/my-component/my-component.d.ts +23 -0
- package/dist/types/components.d.ts +76 -0
- 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 +72 -0
- 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 +64 -0
- package/package.json +18 -2
- package/dist/cjs/index-Ga0t6BMe.js.map +0 -1
- package/dist/esm/index-Drbzcuq-.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-Drbzcuq-.js +0 -3
- package/dist/jaak-stamps-webcomponent/p-Drbzcuq-.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-c06e5d7b.entry.js +0 -2
- package/dist/jaak-stamps-webcomponent/p-c06e5d7b.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' | 'sandbox' | '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?;
|
|
@@ -100,8 +121,10 @@ export declare class JaakStamps {
|
|
|
100
121
|
private hasAutoSwitchedToManual;
|
|
101
122
|
private canvasPool;
|
|
102
123
|
private readonly MAX_CANVAS_POOL_SIZE;
|
|
124
|
+
componentWillLoad(): Promise<void>;
|
|
103
125
|
componentDidLoad(): Promise<void>;
|
|
104
126
|
private initializeServices;
|
|
127
|
+
private validateLicense;
|
|
105
128
|
private setupEventListeners;
|
|
106
129
|
private initializeComponent;
|
|
107
130
|
private validateProps;
|
|
@@ -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,26 +38,58 @@ export namespace Components {
|
|
|
33
38
|
* @default false
|
|
34
39
|
*/
|
|
35
40
|
"enableBackDocumentTimer": boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
"enableMetrics": boolean;
|
|
45
|
+
/**
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
"enableTelemetry": boolean;
|
|
49
|
+
/**
|
|
50
|
+
* @default 'production'
|
|
51
|
+
*/
|
|
52
|
+
"environment"?: string;
|
|
36
53
|
"getCameraInfo": () => Promise<CameraInfoResponse>;
|
|
37
54
|
"getCaptureDelay": () => Promise<number>;
|
|
38
55
|
"getCapturedImages": () => Promise<CapturedImagesResponse>;
|
|
39
56
|
"getStatus": () => Promise<StatusResponse>;
|
|
40
57
|
"isProcessCompleted": () => Promise<boolean>;
|
|
58
|
+
"license"?: string;
|
|
59
|
+
/**
|
|
60
|
+
* @default 'prod'
|
|
61
|
+
*/
|
|
62
|
+
"licenseEnvironment"?: 'dev' | 'qa' | 'sandbox' | 'prod';
|
|
41
63
|
/**
|
|
42
64
|
* @default 90
|
|
43
65
|
*/
|
|
44
66
|
"maskSize": number;
|
|
67
|
+
/**
|
|
68
|
+
* @default 'https://collector.jaak.ai/v1/metrics'
|
|
69
|
+
*/
|
|
70
|
+
"metricsCollectorUrl"?: string;
|
|
71
|
+
/**
|
|
72
|
+
* @default 60000
|
|
73
|
+
*/
|
|
74
|
+
"metricsExportIntervalMillis"?: number;
|
|
45
75
|
/**
|
|
46
76
|
* @default 'auto'
|
|
47
77
|
*/
|
|
48
78
|
"preferredCamera": 'auto' | 'front' | 'back';
|
|
49
79
|
"preloadModel": () => Promise<{ success: boolean; message: string; error?: undefined; } | { success: boolean; error: any; message?: undefined; }>;
|
|
80
|
+
"propagateTraceHeaderCorsUrls"?: string;
|
|
50
81
|
"resetCapture": () => Promise<{ success: boolean; error?: undefined; } | { success: boolean; error: any; }>;
|
|
51
82
|
"setCaptureDelay": (delay: number) => Promise<{ success: boolean; error: string; captureDelay: number; } | { success: boolean; captureDelay: number; error?: undefined; }>;
|
|
52
83
|
"setPreferredCamera": (camera: "auto" | "front" | "back") => Promise<{ success: boolean; selectedCamera: string; availableCameras: number; error?: undefined; } | { success: boolean; error: any; selectedCamera: any; availableCameras: number; }>;
|
|
53
84
|
"skipBackCapture": () => Promise<{ success: boolean; error?: undefined; } | { success: boolean; error: any; }>;
|
|
54
85
|
"startCapture": () => Promise<{ success: boolean; error?: undefined; } | { success: boolean; error: any; }>;
|
|
55
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;
|
|
56
93
|
/**
|
|
57
94
|
* @default false
|
|
58
95
|
*/
|
|
@@ -71,6 +108,7 @@ declare global {
|
|
|
71
108
|
interface HTMLJaakStampsElementEventMap {
|
|
72
109
|
"captureCompleted": any;
|
|
73
110
|
"isReady": boolean;
|
|
111
|
+
"traceIdGenerated": {traceId: string};
|
|
74
112
|
}
|
|
75
113
|
interface HTMLJaakStampsElement extends Components.JaakStamps, HTMLStencilElement {
|
|
76
114
|
addEventListener<K extends keyof HTMLJaakStampsElementEventMap>(type: K, listener: (this: HTMLJaakStampsElement, ev: JaakStampsCustomEvent<HTMLJaakStampsElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -96,6 +134,10 @@ declare namespace LocalJSX {
|
|
|
96
134
|
* @default 15
|
|
97
135
|
*/
|
|
98
136
|
"alignmentTolerance"?: number;
|
|
137
|
+
/**
|
|
138
|
+
* @default 'jaak-stamps-web'
|
|
139
|
+
*/
|
|
140
|
+
"appId"?: string;
|
|
99
141
|
/**
|
|
100
142
|
* @default 20
|
|
101
143
|
*/
|
|
@@ -108,6 +150,7 @@ declare namespace LocalJSX {
|
|
|
108
150
|
* @default 20
|
|
109
151
|
*/
|
|
110
152
|
"cropMargin"?: number;
|
|
153
|
+
"customerId"?: string;
|
|
111
154
|
/**
|
|
112
155
|
* @default false
|
|
113
156
|
*/
|
|
@@ -116,16 +159,49 @@ declare namespace LocalJSX {
|
|
|
116
159
|
* @default false
|
|
117
160
|
*/
|
|
118
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' | 'sandbox' | 'prod';
|
|
119
179
|
/**
|
|
120
180
|
* @default 90
|
|
121
181
|
*/
|
|
122
182
|
"maskSize"?: number;
|
|
183
|
+
/**
|
|
184
|
+
* @default 'https://collector.jaak.ai/v1/metrics'
|
|
185
|
+
*/
|
|
186
|
+
"metricsCollectorUrl"?: string;
|
|
187
|
+
/**
|
|
188
|
+
* @default 60000
|
|
189
|
+
*/
|
|
190
|
+
"metricsExportIntervalMillis"?: number;
|
|
123
191
|
"onCaptureCompleted"?: (event: JaakStampsCustomEvent<any>) => void;
|
|
124
192
|
"onIsReady"?: (event: JaakStampsCustomEvent<boolean>) => void;
|
|
193
|
+
"onTraceIdGenerated"?: (event: JaakStampsCustomEvent<{traceId: string}>) => void;
|
|
125
194
|
/**
|
|
126
195
|
* @default 'auto'
|
|
127
196
|
*/
|
|
128
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;
|
|
129
205
|
/**
|
|
130
206
|
* @default false
|
|
131
207
|
*/
|
|
@@ -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' | 'sandbox' | '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,72 @@
|
|
|
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 enableAutoInstrumentation;
|
|
26
|
+
private spanProcessor;
|
|
27
|
+
private parser;
|
|
28
|
+
private geoCache;
|
|
29
|
+
private geoCacheTimestamp;
|
|
30
|
+
private readonly GEO_CACHE_DURATION_MS;
|
|
31
|
+
constructor(config?: TracingConfig);
|
|
32
|
+
initialize(): void;
|
|
33
|
+
private initializeAutoInstrumentation;
|
|
34
|
+
private getDeviceInfo;
|
|
35
|
+
private getBrowserInfo;
|
|
36
|
+
private getOSInfo;
|
|
37
|
+
/**
|
|
38
|
+
* Set the session trace ID from external source (license or component prop)
|
|
39
|
+
* @param traceId - The trace ID to use for all spans (32 hex characters)
|
|
40
|
+
*/
|
|
41
|
+
setSessionTraceId(traceId: string | null): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get the current session trace ID
|
|
44
|
+
*/
|
|
45
|
+
getSessionTraceId(): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Generate a random span ID (16 hex characters)
|
|
48
|
+
*/
|
|
49
|
+
private generateSpanId;
|
|
50
|
+
private getGeoLocation;
|
|
51
|
+
startSpan(name: string, attributes?: Record<string, any>): Span;
|
|
52
|
+
endSpan(span: Span): void;
|
|
53
|
+
addSpanEvent(span: Span, name: string, attributes?: Record<string, any>): void;
|
|
54
|
+
recordException(span: Span, error: Error): void;
|
|
55
|
+
setSpanAttribute(span: Span, key: string, value: any): void;
|
|
56
|
+
trace<T>(name: string, fn: () => T | Promise<T>, attributes?: Record<string, any>): Promise<T>;
|
|
57
|
+
traceAsync<T>(name: string, fn: () => Promise<T>, attributes?: Record<string, any>): Promise<T>;
|
|
58
|
+
/**
|
|
59
|
+
* Flush all pending spans to the collector
|
|
60
|
+
* Call this when capture/process is complete to send all traces
|
|
61
|
+
*/
|
|
62
|
+
flush(): Promise<void>;
|
|
63
|
+
cleanup(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Get the current trace ID (useful for logging correlation)
|
|
66
|
+
*/
|
|
67
|
+
getCurrentTraceId(): string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Get the current span ID
|
|
70
|
+
*/
|
|
71
|
+
getCurrentSpanId(): string | undefined;
|
|
72
|
+
}
|
|
@@ -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,64 @@
|
|
|
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
|
+
* Flushes all pending spans to the collector
|
|
48
|
+
* Call this when capture/process is complete
|
|
49
|
+
*/
|
|
50
|
+
flush(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Cleans up resources
|
|
53
|
+
*/
|
|
54
|
+
cleanup(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Set the session trace ID from external source (license or component prop)
|
|
57
|
+
* @param traceId - The trace ID to use for all spans (32 hex characters)
|
|
58
|
+
*/
|
|
59
|
+
setSessionTraceId(traceId: string | null): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get the current session trace ID
|
|
62
|
+
*/
|
|
63
|
+
getSessionTraceId(): string | null;
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaak.ai/stamps",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-dev.10",
|
|
4
4
|
"description": "Jaak Document Identifier",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@stencil/core": "^4.27.1",
|
|
44
44
|
"@types/jest": "^29.5.14",
|
|
45
45
|
"@types/node": "^22.13.5",
|
|
46
|
+
"@types/ua-parser-js": "^0.7.39",
|
|
46
47
|
"http-server": "^14.1.1",
|
|
47
48
|
"jest": "^29.7.0",
|
|
48
49
|
"jest-cli": "^29.7.0",
|
|
@@ -50,12 +51,27 @@
|
|
|
50
51
|
},
|
|
51
52
|
"license": "MIT",
|
|
52
53
|
"dependencies": {
|
|
54
|
+
"@opentelemetry/api": "^1.9.0",
|
|
55
|
+
"@opentelemetry/context-zone": "^2.2.0",
|
|
56
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.208.0",
|
|
57
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.208.0",
|
|
58
|
+
"@opentelemetry/instrumentation-document-load": "^0.54.0",
|
|
59
|
+
"@opentelemetry/instrumentation-fetch": "^0.208.0",
|
|
60
|
+
"@opentelemetry/instrumentation-user-interaction": "^0.53.0",
|
|
61
|
+
"@opentelemetry/instrumentation-xml-http-request": "^0.208.0",
|
|
62
|
+
"@opentelemetry/propagator-b3": "^2.2.0",
|
|
63
|
+
"@opentelemetry/resources": "^2.2.0",
|
|
64
|
+
"@opentelemetry/sdk-metrics": "^2.2.0",
|
|
65
|
+
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
66
|
+
"@opentelemetry/sdk-trace-web": "^2.2.0",
|
|
67
|
+
"@opentelemetry/semantic-conventions": "^1.38.0",
|
|
53
68
|
"@semantic-release/changelog": "^6.0.3",
|
|
54
69
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
55
70
|
"@semantic-release/git": "^10.0.1",
|
|
56
71
|
"@semantic-release/github": "^11.0.4",
|
|
57
72
|
"@semantic-release/npm": "^12.0.2",
|
|
58
73
|
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
59
|
-
"semantic-release": "^24.2.7"
|
|
74
|
+
"semantic-release": "^24.2.7",
|
|
75
|
+
"ua-parser-js": "^1.0.40"
|
|
60
76
|
}
|
|
61
77
|
}
|