@jaak.ai/stamps 2.2.0-dev.10 → 2.2.0-dev.12

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 (2) hide show
  1. package/README.md +188 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -56,23 +56,49 @@ yarn add @jaak.ai/stamps
56
56
 
57
57
  ### Properties/Attributes
58
58
 
59
+ #### License Properties (Required)
60
+
59
61
  | Property | Type | Default | Description |
60
62
  |----------|------|---------|-------------|
61
- | `license` | `string` | `undefined` | License key for component authentication (required) |
62
- | `environment` | `'dev' \| 'qa' \| 'staging' \| 'prod'` | `'prod'` | API environment for license validation |
63
- | `trace-id` | `string` | `undefined` | Optional trace ID for request tracing (auto-generated if not provided) |
63
+ | `license` | `string` | `undefined` | **[REQUIRED]** License key for component authentication |
64
+ | `license-environment` | `'dev' \| 'qa' \| 'sandbox' \| 'prod'` | `'prod'` | API environment for license validation |
64
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
+
70
+ | Property | Type | Default | Description |
71
+ |----------|------|---------|-------------|
65
72
  | `debug` | `boolean` | `false` | Enable debug mode with additional logging and overlays |
66
- | `mask-size` | `number` | `90` | Size percentage of the document detection mask |
67
- | `alignment-tolerance` | `number` | `15` | Tolerance level for document alignment detection |
68
- | `capture-delay` | `number` | `1500` | Delay in milliseconds before automatic capture |
69
- | `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) |
70
77
  | `preferred-camera` | `'auto' \| 'front' \| 'back'` | `'auto'` | Preferred camera selection |
71
- | `use-document-classification` | `boolean` | `false` | Enable AI document classification |
78
+ | `use-document-classification` | `boolean` | `false` | Enable AI document type classification |
72
79
  | `use-document-detector` | `boolean` | `true` | Enable/disable AI document detection model |
73
80
  | `enable-back-document-timer` | `boolean` | `false` | Enable timer for back document capture |
74
81
  | `back-document-timer-duration` | `number` | `20` | Duration in seconds for back document capture timer |
75
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
+
76
102
  ### Methods
77
103
 
78
104
  #### Camera Control
@@ -581,6 +607,160 @@ import { DocumentScannerComponent } from './document-scanner.component';
581
607
  export class DocumentScannerModule { }
582
608
  ```
583
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
+
584
764
  ## Style Guide
585
765
 
586
766
  ### CSS Custom Properties
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jaak.ai/stamps",
3
- "version": "2.2.0-dev.10",
3
+ "version": "2.2.0-dev.12",
4
4
  "description": "Jaak Document Identifier",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",