@jaak.ai/stamps 2.1.0-dev.9 → 2.2.0-beta.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.
Files changed (79) hide show
  1. package/README.md +227 -14
  2. package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
  3. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
  4. package/dist/cjs/{index-BfhtOB0D.js → index-D6NBn_qu.js} +203 -121
  5. package/dist/cjs/index-D6NBn_qu.js.map +1 -0
  6. package/dist/cjs/jaak-stamps-webcomponent.cjs.js +5 -4
  7. package/dist/cjs/jaak-stamps-webcomponent.cjs.js.map +1 -1
  8. package/dist/cjs/jaak-stamps.cjs.entry.js +17780 -442
  9. package/dist/cjs/jaak-stamps.cjs.entry.js.map +1 -1
  10. package/dist/cjs/jaak-stamps.entry.cjs.js.map +1 -1
  11. package/dist/cjs/loader.cjs.js +4 -3
  12. package/dist/cjs/loader.cjs.js.map +1 -1
  13. package/dist/collection/collection-manifest.json +1 -1
  14. package/dist/collection/components/my-component/my-component.css +106 -5
  15. package/dist/collection/components/my-component/my-component.js +558 -313
  16. package/dist/collection/components/my-component/my-component.js.map +1 -1
  17. package/dist/collection/services/CameraService.js +125 -11
  18. package/dist/collection/services/CameraService.js.map +1 -1
  19. package/dist/collection/services/DetectionService.js +7 -148
  20. package/dist/collection/services/DetectionService.js.map +1 -1
  21. package/dist/collection/services/LicenseValidationService.js +111 -0
  22. package/dist/collection/services/LicenseValidationService.js.map +1 -0
  23. package/dist/collection/services/MetricsService.js +350 -0
  24. package/dist/collection/services/MetricsService.js.map +1 -0
  25. package/dist/collection/services/ServiceContainer.js +66 -1
  26. package/dist/collection/services/ServiceContainer.js.map +1 -1
  27. package/dist/collection/services/TracingService.js +494 -0
  28. package/dist/collection/services/TracingService.js.map +1 -0
  29. package/dist/collection/services/interfaces/IDetectionService.js.map +1 -1
  30. package/dist/collection/services/interfaces/ILicenseValidationService.js +2 -0
  31. package/dist/collection/services/interfaces/ILicenseValidationService.js.map +1 -0
  32. package/dist/collection/services/interfaces/IMetricsService.js +2 -0
  33. package/dist/collection/services/interfaces/IMetricsService.js.map +1 -0
  34. package/dist/collection/services/interfaces/ITracingService.js +2 -0
  35. package/dist/collection/services/interfaces/ITracingService.js.map +1 -0
  36. package/dist/components/index.js +192 -115
  37. package/dist/components/index.js.map +1 -1
  38. package/dist/components/jaak-stamps.js +17796 -445
  39. package/dist/components/jaak-stamps.js.map +1 -1
  40. package/dist/esm/app-globals-DQuL1Twl.js +6 -0
  41. package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
  42. package/dist/esm/{index-BP1Q4KOg.js → index-BCfAsrzL.js} +204 -121
  43. package/dist/esm/index-BCfAsrzL.js.map +1 -0
  44. package/dist/esm/jaak-stamps-webcomponent.js +5 -4
  45. package/dist/esm/jaak-stamps-webcomponent.js.map +1 -1
  46. package/dist/esm/jaak-stamps.entry.js +17780 -442
  47. package/dist/esm/jaak-stamps.entry.js.map +1 -1
  48. package/dist/esm/loader.js +4 -3
  49. package/dist/esm/loader.js.map +1 -1
  50. package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js +1 -1
  51. package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js.map +1 -1
  52. package/dist/jaak-stamps-webcomponent/jaak-stamps.entry.esm.js.map +1 -1
  53. package/dist/jaak-stamps-webcomponent/loader.esm.js.map +1 -1
  54. package/dist/jaak-stamps-webcomponent/p-34bcebb1.entry.js +7 -0
  55. package/dist/jaak-stamps-webcomponent/p-34bcebb1.entry.js.map +1 -0
  56. package/dist/jaak-stamps-webcomponent/p-BCfAsrzL.js +3 -0
  57. package/dist/jaak-stamps-webcomponent/p-BCfAsrzL.js.map +1 -0
  58. package/dist/jaak-stamps-webcomponent/p-DQuL1Twl.js +2 -0
  59. package/dist/jaak-stamps-webcomponent/p-DQuL1Twl.js.map +1 -0
  60. package/dist/types/components/my-component/my-component.d.ts +25 -27
  61. package/dist/types/components.d.ts +77 -3
  62. package/dist/types/services/CameraService.d.ts +1 -0
  63. package/dist/types/services/DetectionService.d.ts +1 -9
  64. package/dist/types/services/LicenseValidationService.d.ts +59 -0
  65. package/dist/types/services/MetricsService.d.ts +74 -0
  66. package/dist/types/services/ServiceContainer.d.ts +14 -1
  67. package/dist/types/services/TracingService.d.ts +72 -0
  68. package/dist/types/services/interfaces/IDetectionService.d.ts +0 -6
  69. package/dist/types/services/interfaces/ILicenseValidationService.d.ts +4 -0
  70. package/dist/types/services/interfaces/IMetricsService.d.ts +70 -0
  71. package/dist/types/services/interfaces/ITracingService.d.ts +64 -0
  72. package/dist/types/stencil-public-runtime.d.ts +12 -5
  73. package/package.json +20 -2
  74. package/dist/cjs/index-BfhtOB0D.js.map +0 -1
  75. package/dist/esm/index-BP1Q4KOg.js.map +0 -1
  76. package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js +0 -3
  77. package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js.map +0 -1
  78. package/dist/jaak-stamps-webcomponent/p-c115e01a.entry.js +0 -2
  79. 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' | '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?;
@@ -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;
@@ -90,6 +112,7 @@ export declare class JaakStamps {
90
112
  private readonly MAX_FAILURES;
91
113
  private lastInferenceTime;
92
114
  private readonly MIN_INFERENCE_INTERVAL;
115
+ private readonly MOBILE_MIN_INFERENCE_INTERVAL;
93
116
  private performanceHistory;
94
117
  private readonly PERFORMANCE_HISTORY_SIZE;
95
118
  private readonly PERFORMANCE_THRESHOLD_MS;
@@ -99,8 +122,10 @@ export declare class JaakStamps {
99
122
  private hasAutoSwitchedToManual;
100
123
  private canvasPool;
101
124
  private readonly MAX_CANVAS_POOL_SIZE;
125
+ componentWillLoad(): Promise<void>;
102
126
  componentDidLoad(): Promise<void>;
103
127
  private initializeServices;
128
+ private validateLicense;
104
129
  private setupEventListeners;
105
130
  private initializeComponent;
106
131
  private validateProps;
@@ -127,14 +152,10 @@ export declare class JaakStamps {
127
152
  }>;
128
153
  stopCapture(): Promise<{
129
154
  success: boolean;
130
- resourcesFreed: string[];
131
- cleanupErrors: string[];
132
155
  error?: undefined;
133
156
  } | {
134
157
  success: boolean;
135
158
  error: any;
136
- resourcesFreed?: undefined;
137
- cleanupErrors?: undefined;
138
159
  }>;
139
160
  resetCapture(): Promise<{
140
161
  success: boolean;
@@ -182,35 +203,12 @@ export declare class JaakStamps {
182
203
  error?: undefined;
183
204
  }>;
184
205
  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
206
  private checkDeviceCapabilities;
200
207
  private startDetection;
201
208
  private initializeVideoStream;
202
209
  private detectFrame;
203
210
  disconnectedCallback(): void;
204
211
  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
212
  render(): any;
215
213
  private updateDetectionBoxes;
216
214
  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
- "forceResourceCleanup": () => Promise<{ success: boolean; resourcesFreed: string[]; errors: string[]; timestamp: string; error?: undefined; } | { success: boolean; error: any; resourcesFreed?: undefined; errors?: undefined; timestamp?: undefined; }>;
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' | 'sandbox' | '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; resourcesFreed: string[]; cleanupErrors: string[]; error?: undefined; } | { success: boolean; error: any; resourcesFreed?: undefined; cleanupErrors?: undefined; }>;
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' | 'sandbox' | '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
  */
@@ -42,4 +42,5 @@ export declare class CameraService implements ICameraService {
42
42
  private constraintsEqual;
43
43
  static clearCaches(): void;
44
44
  invalidateDeviceCache(): void;
45
+ private isVirtualCamera;
45
46
  }
@@ -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
- clearModelCache(): Promise<void>;
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' | '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
+ }
@@ -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,4 @@
1
+ import { LicenseValidationResponse } from '../LicenseValidationService';
2
+ export interface ILicenseValidationService {
3
+ validateLicense(license: string, traceId?: string, appId?: string, metadata?: any): Promise<LicenseValidationResponse>;
4
+ }
@@ -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
+ }