@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
package/README.md CHANGED
@@ -56,19 +56,49 @@ yarn add @jaak.ai/stamps
56
56
 
57
57
  ### Properties/Attributes
58
58
 
59
+ #### License Properties (Required)
60
+
61
+ | Property | Type | Default | Description |
62
+ |----------|------|---------|-------------|
63
+ | `license` | `string` | `undefined` | **[REQUIRED]** License key for component authentication |
64
+ | `license-environment` | `'dev' \| 'qa' \| 'sandbox' \| 'prod'` | `'prod'` | API environment for license validation |
65
+ | `app-id` | `string` | `'jaak-stamps-web'` | Application identifier for analytics and tracking |
66
+ | `trace-id` | `string` | `undefined` | Optional trace ID for distributed tracing (auto-generated if not provided) |
67
+
68
+ #### Base Configuration Properties
69
+
59
70
  | Property | Type | Default | Description |
60
71
  |----------|------|---------|-------------|
61
72
  | `debug` | `boolean` | `false` | Enable debug mode with additional logging and overlays |
62
- | `mask-size` | `number` | `90` | Size percentage of the document detection mask |
63
- | `alignment-tolerance` | `number` | `15` | Tolerance level for document alignment detection |
64
- | `capture-delay` | `number` | `1500` | Delay in milliseconds before automatic capture |
65
- | `crop-margin` | `number` | `20` | Margin in pixels around detected document for cropping |
73
+ | `mask-size` | `number` | `90` | Size percentage of the document detection mask (50-100) |
74
+ | `alignment-tolerance` | `number` | `15` | Tolerance level in pixels for document alignment detection |
75
+ | `capture-delay` | `number` | `1500` | Delay in milliseconds before automatic capture (0-10000) |
76
+ | `crop-margin` | `number` | `20` | Margin in pixels around detected document for cropping (0-100) |
66
77
  | `preferred-camera` | `'auto' \| 'front' \| 'back'` | `'auto'` | Preferred camera selection |
67
- | `use-document-classification` | `boolean` | `false` | Enable AI document classification |
78
+ | `use-document-classification` | `boolean` | `false` | Enable AI document type classification |
68
79
  | `use-document-detector` | `boolean` | `true` | Enable/disable AI document detection model |
69
80
  | `enable-back-document-timer` | `boolean` | `false` | Enable timer for back document capture |
70
81
  | `back-document-timer-duration` | `number` | `20` | Duration in seconds for back document capture timer |
71
82
 
83
+ #### Telemetry and OpenTelemetry Properties
84
+
85
+ | Property | Type | Default | Description |
86
+ |----------|------|---------|-------------|
87
+ | `telemetry-collector-url` | `string` | `'https://collector.jaak.ai/v1/traces'` | OTLP collector URL for distributed traces |
88
+ | `metrics-collector-url` | `string` | `'https://collector.jaak.ai/v1/metrics'` | OTLP collector URL for metrics |
89
+ | `enable-telemetry` | `boolean` | `true` | Enable distributed tracing with OpenTelemetry |
90
+ | `enable-metrics` | `boolean` | `true` | Enable metrics export to OpenTelemetry |
91
+ | `metrics-export-interval-millis` | `number` | `60000` | Metrics export interval in milliseconds |
92
+ | `propagate-trace-header-cors-urls` | `string` | `undefined` | Comma-separated URLs for W3C Trace Context header propagation |
93
+
94
+ #### Context Properties
95
+
96
+ | Property | Type | Default | Description |
97
+ |----------|------|---------|-------------|
98
+ | `customer-id` | `string` | `undefined` | Customer ID for telemetry and analytics |
99
+ | `tenant-id` | `string` | `undefined` | Tenant ID for multi-tenancy support |
100
+ | `environment` | `string` | `'production'` | Execution environment (development/staging/production) |
101
+
72
102
  ### Methods
73
103
 
74
104
  #### Camera Control
@@ -152,6 +182,7 @@ preloadModel(): Promise<{
152
182
  |-------|-------------|-------------|
153
183
  | `isReady` | `boolean` | Fired when component is fully initialized and ready |
154
184
  | `captureCompleted` | `object` | Fired when document capture process is completed |
185
+ | `traceIdGenerated` | `{ traceId: string }` | Fired after license validation with the generated or provided trace ID for request tracing |
155
186
 
156
187
  ### Type Definitions
157
188
 
@@ -206,6 +237,9 @@ interface StatusResponse {
206
237
  <body>
207
238
  <jaak-stamps
208
239
  id="documentScanner"
240
+ license="your-license-key-here"
241
+ environment="prod"
242
+ app-id="my-custom-app"
209
243
  preferred-camera="auto"
210
244
  capture-delay="1500"
211
245
  use-document-detector="true"
@@ -214,23 +248,29 @@ interface StatusResponse {
214
248
 
215
249
  <script>
216
250
  const scanner = document.getElementById('documentScanner');
217
-
251
+
252
+ // Handle trace ID generation
253
+ scanner.addEventListener('traceIdGenerated', (event) => {
254
+ console.log('Trace ID for this session:', event.detail.traceId);
255
+ // Use this trace ID for correlating requests across your system
256
+ });
257
+
218
258
  // Wait for component to be ready
219
259
  scanner.addEventListener('isReady', () => {
220
260
  console.log('Document scanner is ready');
221
-
261
+
222
262
  // Start the capture process
223
263
  scanner.startCapture();
224
264
  });
225
-
265
+
226
266
  // Handle capture completion
227
267
  scanner.addEventListener('captureCompleted', async (event) => {
228
268
  console.log('Capture completed:', event.detail);
229
-
269
+
230
270
  // Get captured images
231
271
  const images = await scanner.getCapturedImages();
232
272
  console.log('Captured images:', images);
233
-
273
+
234
274
  // Process the images as needed
235
275
  if (images.front.cropped) {
236
276
  // Display or upload the cropped front image
@@ -285,22 +325,29 @@ const DocumentScanner: React.FC = () => {
285
325
  const scanner = scannerRef.current;
286
326
  if (!scanner) return;
287
327
 
328
+ // Trace ID generation handler
329
+ const handleTraceIdGenerated = (event: CustomEvent) => {
330
+ console.log('Trace ID:', event.detail.traceId);
331
+ };
332
+
288
333
  // Component ready handler
289
334
  const handleReady = () => {
290
335
  setIsReady(true);
291
336
  };
292
-
337
+
293
338
  // Capture completion handler
294
339
  const handleCaptureCompleted = async () => {
295
340
  const images = await (scanner as any).getCapturedImages();
296
341
  setCapturedImages(images);
297
342
  };
298
-
343
+
299
344
  // Add event listeners
345
+ scanner.addEventListener('traceIdGenerated', handleTraceIdGenerated);
300
346
  scanner.addEventListener('isReady', handleReady);
301
347
  scanner.addEventListener('captureCompleted', handleCaptureCompleted);
302
348
 
303
349
  return () => {
350
+ scanner.removeEventListener('traceIdGenerated', handleTraceIdGenerated);
304
351
  scanner.removeEventListener('isReady', handleReady);
305
352
  scanner.removeEventListener('captureCompleted', handleCaptureCompleted);
306
353
  };
@@ -318,6 +365,10 @@ const DocumentScanner: React.FC = () => {
318
365
 
319
366
  <jaak-stamps
320
367
  ref={scannerRef}
368
+ license="your-license-key-here"
369
+ environment="prod"
370
+ app-id="my-react-app"
371
+ trace-id="" // Leave empty to auto-generate
321
372
  preferred-camera="auto"
322
373
  capture-delay={1500}
323
374
  use-document-classification={true}
@@ -390,6 +441,9 @@ interface CapturedImages {
390
441
 
391
442
  <jaak-stamps
392
443
  #scanner
444
+ license="your-license-key-here"
445
+ environment="prod"
446
+ app-id="my-angular-app"
393
447
  preferred-camera="auto"
394
448
  [capture-delay]="1500"
395
449
  [use-document-classification]="true"
@@ -506,12 +560,17 @@ export class DocumentScannerComponent implements AfterViewInit {
506
560
 
507
561
  ngAfterViewInit() {
508
562
  const scanner = this.scannerRef.nativeElement;
509
-
563
+
564
+ // Trace ID generation handler
565
+ scanner.addEventListener('traceIdGenerated', (event: CustomEvent) => {
566
+ console.log('Trace ID:', event.detail.traceId);
567
+ });
568
+
510
569
  // Component ready handler
511
570
  scanner.addEventListener('isReady', () => {
512
571
  this.isReady = true;
513
572
  });
514
-
573
+
515
574
  // Capture completion handler
516
575
  scanner.addEventListener('captureCompleted', async () => {
517
576
  this.capturedImages = await scanner.getCapturedImages();
@@ -548,6 +607,160 @@ import { DocumentScannerComponent } from './document-scanner.component';
548
607
  export class DocumentScannerModule { }
549
608
  ```
550
609
 
610
+ ## Telemetry and Observability (OpenTelemetry)
611
+
612
+ Jaak Stamps includes full **OpenTelemetry** integration for distributed tracing, metrics, and performance monitoring in production environments.
613
+
614
+ ### Distributed Tracing
615
+
616
+ The component implements distributed tracing following the **W3C Trace Context** standard, providing:
617
+
618
+ - Complete flow tracking of document capture processes
619
+ - Request correlation between frontend and backend
620
+ - Performance bottleneck identification
621
+ - Context propagation via `traceparent` headers
622
+
623
+ **Automatically Recorded Spans:**
624
+ - `component.initialize` - Component initialization
625
+ - `capture.start` - Capture process start
626
+ - `model.preload` - AI model preloading
627
+ - `model.detection.load` - Detection model loading
628
+ - `model.classification.load` - Classification model loading
629
+
630
+ ### Performance Metrics
631
+
632
+ The component exports detailed metrics to OpenTelemetry:
633
+
634
+ **Counters:**
635
+ - `capture.counter` - Number of completed captures
636
+ - `error.counter` - Error count by type
637
+ - `model.load.counter` - Model load count
638
+ - `user.interaction.counter` - User interactions
639
+
640
+ **Histograms (Latencies):**
641
+ - `capture.latency` - Total capture time
642
+ - `model.load.latency` - Model loading time
643
+ - `detection.latency` - Per-frame detection time
644
+ - `image.size` - Captured image sizes
645
+
646
+ **Gauges (Current State):**
647
+ - `active.sessions` - Active sessions
648
+ - `memory.usage` - Memory usage
649
+
650
+ ### Telemetry Configuration
651
+
652
+ ```html
653
+ <jaak-stamps
654
+ license="your-license-key"
655
+ enable-telemetry="true"
656
+ enable-metrics="true"
657
+ telemetry-collector-url="https://collector.jaak.ai/v1/traces"
658
+ metrics-collector-url="https://collector.jaak.ai/v1/metrics"
659
+ metrics-export-interval-millis="60000"
660
+ propagate-trace-header-cors-urls="https://api.example.com,https://backend.example.com"
661
+ customer-id="customer123"
662
+ tenant-id="tenant456"
663
+ environment="production"
664
+ trace-id="optional-custom-trace-id">
665
+ </jaak-stamps>
666
+ ```
667
+
668
+ ### Using Trace ID
669
+
670
+ The component automatically generates a unique trace ID for each session, or accepts a custom one:
671
+
672
+ ```javascript
673
+ const scanner = document.getElementById('documentScanner');
674
+
675
+ // Listen for trace ID generation
676
+ scanner.addEventListener('traceIdGenerated', (event) => {
677
+ const traceId = event.detail.traceId;
678
+ console.log('Trace ID for this session:', traceId);
679
+
680
+ // Use this traceId to correlate requests in your backend
681
+ fetch('/api/process-document', {
682
+ method: 'POST',
683
+ headers: {
684
+ 'X-Trace-Id': traceId,
685
+ 'Content-Type': 'application/json'
686
+ },
687
+ body: JSON.stringify({ /* data */ })
688
+ });
689
+ });
690
+ ```
691
+
692
+ ### Enriched Attributes
693
+
694
+ Traces and metrics automatically include:
695
+
696
+ - **User Agent:** Browser, version, operating system
697
+ - **Geolocation:** Country, region, city (when available)
698
+ - **Device Memory:** Device memory capacity
699
+ - **Customer Context:** `customerId`, `tenantId`, `environment`
700
+ - **Service Info:** Service name, component version
701
+
702
+ ### Context Propagation (CORS)
703
+
704
+ To propagate traces to your backend services:
705
+
706
+ ```html
707
+ <jaak-stamps
708
+ propagate-trace-header-cors-urls="https://api.example.com,https://services.example.com">
709
+ </jaak-stamps>
710
+ ```
711
+
712
+ This automatically configures `fetch` and `XMLHttpRequest` interceptors to include the `traceparent` header in requests to those URLs.
713
+
714
+ ### Visualization with Jaeger/Zipkin
715
+
716
+ Exported traces are compatible with:
717
+ - **Jaeger** - Distributed tracing system
718
+ - **Zipkin** - Alternative tracing system
719
+ - **Grafana Tempo** - Grafana trace backend
720
+ - Any OTLP-compatible backend (OpenTelemetry Protocol)
721
+
722
+ ## License Validation
723
+
724
+ The component **requires a valid license** to function. Validation occurs automatically when the component loads.
725
+
726
+ ### License Configuration
727
+
728
+ ```html
729
+ <jaak-stamps
730
+ license="your-license-key-here"
731
+ license-environment="prod"
732
+ app-id="my-application">
733
+ </jaak-stamps>
734
+ ```
735
+
736
+ ### Available Environments
737
+
738
+ | Environment | Validation URL | Use Case |
739
+ |-------------|---------------|----------|
740
+ | `dev` | `https://api.dev.jaak.ai` | Local development |
741
+ | `qa` | `https://api.qa.jaak.ai` | Quality assurance testing |
742
+ | `sandbox` | `https://api.sandbox.jaak.ai` | Integration testing |
743
+ | `prod` | `https://services.api.jaak.ai` | Production |
744
+
745
+ ### License Error Handling
746
+
747
+ If the license is invalid, the component will display an error and not function:
748
+
749
+ ```javascript
750
+ const scanner = document.getElementById('documentScanner');
751
+
752
+ scanner.addEventListener('isReady', (event) => {
753
+ if (!event.detail) {
754
+ console.error('Error: Invalid license or component not initialized');
755
+ }
756
+ });
757
+ ```
758
+
759
+ **Common error messages:**
760
+ - `"License key is required"` - No license provided
761
+ - `"Invalid license key"` - Invalid or expired license
762
+ - `"License validation failed"` - Validation error
763
+
551
764
  ## Style Guide
552
765
 
553
766
  ### CSS Custom Properties
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const globalScripts = () => {};
4
+
5
+ exports.globalScripts = globalScripts;
6
+ //# sourceMappingURL=app-globals-V2Kpy_OQ.js.map
7
+
8
+ //# sourceMappingURL=app-globals-V2Kpy_OQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-globals-V2Kpy_OQ.js","sources":["@stencil/core/internal/app-globals"],"sourcesContent":["export const globalScripts = () => {};\nexport const globalStyles = \"\";\n"],"names":[],"mappings":";;AAAY,MAAC,aAAa,GAAG,MAAM;;;;"}