ml-cache 1.0.0 → 1.2.0
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 +99 -128
- package/dist/client.d.ts +23 -41
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +26 -66
- package/dist/client.js.map +1 -1
- package/dist/constants.d.ts +2 -12
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -14
- package/dist/constants.js.map +1 -1
- package/dist/esm/client.d.ts +23 -41
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +26 -66
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/constants.d.ts +2 -12
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +2 -13
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.d.ts +3 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/queue.d.ts.map +1 -1
- package/dist/esm/queue.js.map +1 -1
- package/dist/esm/storage/glacier-storage.d.ts.map +1 -1
- package/dist/esm/storage/glacier-storage.js +1 -1
- package/dist/esm/storage/glacier-storage.js.map +1 -1
- package/dist/esm/storage/s3-storage.d.ts.map +1 -1
- package/dist/esm/storage/s3-storage.js +1 -1
- package/dist/esm/storage/s3-storage.js.map +1 -1
- package/dist/esm/types/index.d.ts +2 -4
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/logger.d.ts.map +1 -1
- package/dist/esm/utils/logger.js.map +1 -1
- package/dist/esm/utils/validator.d.ts +4 -10
- package/dist/esm/utils/validator.d.ts.map +1 -1
- package/dist/esm/utils/validator.js +18 -40
- package/dist/esm/utils/validator.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js.map +1 -1
- package/dist/storage/glacier-storage.d.ts.map +1 -1
- package/dist/storage/glacier-storage.js.map +1 -1
- package/dist/storage/s3-storage.d.ts.map +1 -1
- package/dist/storage/s3-storage.js.map +1 -1
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/validator.d.ts +4 -10
- package/dist/utils/validator.d.ts.map +1 -1
- package/dist/utils/validator.js +18 -41
- package/dist/utils/validator.js.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -28,11 +28,11 @@ Machine learning is transforming every industry, but there's a catch: **you need
|
|
|
28
28
|
|
|
29
29
|
### Why Cold Storage?
|
|
30
30
|
|
|
31
|
-
| Storage Type
|
|
32
|
-
|
|
33
|
-
| S3 Standard
|
|
34
|
-
| S3 Glacier
|
|
35
|
-
| S3 Glacier Deep Archive
|
|
31
|
+
| Storage Type | Cost per TB/month | Retrieval |
|
|
32
|
+
| ------------------------ | ----------------- | ---------------- |
|
|
33
|
+
| S3 Standard | ~$23 | Instant |
|
|
34
|
+
| S3 Glacier | ~$4 | Minutes to hours |
|
|
35
|
+
| S3 Glacier Deep Archive | ~$1 | 12-48 hours |
|
|
36
36
|
|
|
37
37
|
For ML training data that you'll access months or years from now, cold storage is **20x cheaper** than standard storage.
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ For ML training data that you'll access months or years from now, cold storage i
|
|
|
40
40
|
|
|
41
41
|
## Features
|
|
42
42
|
|
|
43
|
-
- **Simple
|
|
43
|
+
- **Simple API** — One method to cache all your data: `cache()`
|
|
44
44
|
- **Automatic Batching** — Efficiently groups events to minimize API calls
|
|
45
45
|
- **Smart Retry Logic** — Exponential backoff ensures no data loss
|
|
46
46
|
- **Type-Safe** — Full TypeScript support with comprehensive type definitions
|
|
@@ -48,6 +48,20 @@ For ML training data that you'll access months or years from now, cold storage i
|
|
|
48
48
|
- **Rich Context** — Capture user, device, page, and campaign data
|
|
49
49
|
- **Zero Dependencies on Analytics** — Direct AWS integration, no middlemen
|
|
50
50
|
- **Production Ready** — Battle-tested error handling and graceful shutdown
|
|
51
|
+
- **Backend Only** — Designed for Node.js server-side applications
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Platform Support
|
|
56
|
+
|
|
57
|
+
> **Important:** This SDK is designed for **backend/server-side use only** (Node.js 18+).
|
|
58
|
+
|
|
59
|
+
It is **not** compatible with:
|
|
60
|
+
- Browser environments
|
|
61
|
+
- Edge runtimes (Cloudflare Workers, Vercel Edge)
|
|
62
|
+
- React Native or mobile apps
|
|
63
|
+
|
|
64
|
+
The SDK requires Node.js APIs (`crypto`, `Buffer`) and direct AWS SDK access, which are not available in browser or edge environments.
|
|
51
65
|
|
|
52
66
|
---
|
|
53
67
|
|
|
@@ -88,10 +102,9 @@ const mlCache = new MLCacheClient({
|
|
|
88
102
|
environment: 'production',
|
|
89
103
|
});
|
|
90
104
|
|
|
91
|
-
//
|
|
92
|
-
await mlCache.
|
|
93
|
-
|
|
94
|
-
properties: {
|
|
105
|
+
// Cache business data
|
|
106
|
+
await mlCache.cache({
|
|
107
|
+
data: {
|
|
95
108
|
productId: 'SKU-12345',
|
|
96
109
|
productName: 'Premium Widget',
|
|
97
110
|
price: 99.99,
|
|
@@ -109,19 +122,6 @@ await mlCache.track({
|
|
|
109
122
|
},
|
|
110
123
|
});
|
|
111
124
|
|
|
112
|
-
// Identify users
|
|
113
|
-
await mlCache.identify('user-789', {
|
|
114
|
-
email: 'user@example.com',
|
|
115
|
-
name: 'Jane Doe',
|
|
116
|
-
company: 'Acme Corp',
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// Track page views
|
|
120
|
-
await mlCache.page('Product Details', {
|
|
121
|
-
url: '/products/SKU-12345',
|
|
122
|
-
referrer: 'google.com',
|
|
123
|
-
});
|
|
124
|
-
|
|
125
125
|
// Graceful shutdown (flushes remaining events)
|
|
126
126
|
await mlCache.shutdown();
|
|
127
127
|
```
|
|
@@ -198,25 +198,24 @@ const client = new MLCacheClient(config);
|
|
|
198
198
|
|
|
199
199
|
Choose the right storage class for your needs:
|
|
200
200
|
|
|
201
|
-
| Storage Class
|
|
202
|
-
|
|
203
|
-
| `STANDARD`
|
|
204
|
-
| `STANDARD_IA`
|
|
205
|
-
| `GLACIER`
|
|
206
|
-
| `DEEP_ARCHIVE` | Rarely accessed, lowest cost
|
|
201
|
+
| Storage Class | Use Case | Retrieval Time |
|
|
202
|
+
| -------------- | ------------------------------ | -------------- |
|
|
203
|
+
| `STANDARD` | Frequent access, testing | Instant |
|
|
204
|
+
| `STANDARD_IA` | Infrequent access | Instant |
|
|
205
|
+
| `GLACIER` | **Recommended for ML data** | 1-5 minutes |
|
|
206
|
+
| `DEEP_ARCHIVE` | Rarely accessed, lowest cost | 12-48 hours |
|
|
207
207
|
|
|
208
208
|
---
|
|
209
209
|
|
|
210
|
-
##
|
|
210
|
+
## Caching Data
|
|
211
211
|
|
|
212
|
-
###
|
|
212
|
+
### Basic Usage
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
Cache any business data with rich context:
|
|
215
215
|
|
|
216
216
|
```typescript
|
|
217
|
-
await mlCache.
|
|
218
|
-
|
|
219
|
-
properties: {
|
|
217
|
+
await mlCache.cache({
|
|
218
|
+
data: {
|
|
220
219
|
orderId: 'ORD-123456',
|
|
221
220
|
total: 299.99,
|
|
222
221
|
items: [
|
|
@@ -237,44 +236,16 @@ await mlCache.track({
|
|
|
237
236
|
});
|
|
238
237
|
```
|
|
239
238
|
|
|
240
|
-
###
|
|
241
|
-
|
|
242
|
-
Build user profiles for personalization:
|
|
243
|
-
|
|
244
|
-
```typescript
|
|
245
|
-
await mlCache.identify('user-123', {
|
|
246
|
-
email: 'user@example.com',
|
|
247
|
-
name: 'John Doe',
|
|
248
|
-
plan: 'enterprise',
|
|
249
|
-
company: 'Acme Corp',
|
|
250
|
-
employeeCount: 500,
|
|
251
|
-
industry: 'technology',
|
|
252
|
-
});
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Page Views
|
|
256
|
-
|
|
257
|
-
Track navigation patterns:
|
|
258
|
-
|
|
259
|
-
```typescript
|
|
260
|
-
await mlCache.page('Pricing', {
|
|
261
|
-
url: 'https://example.com/pricing',
|
|
262
|
-
path: '/pricing',
|
|
263
|
-
title: 'Pricing Plans - Example',
|
|
264
|
-
referrer: 'https://google.com',
|
|
265
|
-
});
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
## Event Context
|
|
239
|
+
### Event Context
|
|
271
240
|
|
|
272
241
|
Enrich events with contextual data:
|
|
273
242
|
|
|
274
243
|
```typescript
|
|
275
|
-
await mlCache.
|
|
276
|
-
|
|
277
|
-
|
|
244
|
+
await mlCache.cache({
|
|
245
|
+
data: {
|
|
246
|
+
action: 'feature_used',
|
|
247
|
+
feature: 'dark_mode',
|
|
248
|
+
},
|
|
278
249
|
context: {
|
|
279
250
|
// User context
|
|
280
251
|
user: {
|
|
@@ -288,7 +259,7 @@ await mlCache.track({
|
|
|
288
259
|
|
|
289
260
|
// Device context
|
|
290
261
|
device: {
|
|
291
|
-
userAgent:
|
|
262
|
+
userAgent: 'Mozilla/5.0...',
|
|
292
263
|
deviceType: 'desktop',
|
|
293
264
|
os: 'macOS',
|
|
294
265
|
browser: 'Chrome',
|
|
@@ -299,10 +270,10 @@ await mlCache.track({
|
|
|
299
270
|
|
|
300
271
|
// Page context
|
|
301
272
|
page: {
|
|
302
|
-
url:
|
|
303
|
-
path:
|
|
304
|
-
title:
|
|
305
|
-
referrer:
|
|
273
|
+
url: 'https://example.com/settings',
|
|
274
|
+
path: '/settings',
|
|
275
|
+
title: 'Settings',
|
|
276
|
+
referrer: 'https://example.com/home',
|
|
306
277
|
},
|
|
307
278
|
|
|
308
279
|
// Campaign/UTM context
|
|
@@ -334,9 +305,9 @@ await mlCache.track({
|
|
|
334
305
|
## Callbacks & Monitoring
|
|
335
306
|
|
|
336
307
|
```typescript
|
|
337
|
-
// Monitor all
|
|
308
|
+
// Monitor all cached events
|
|
338
309
|
mlCache.onEvent((event) => {
|
|
339
|
-
console.log('Event
|
|
310
|
+
console.log('Event cached:', event.eventId);
|
|
340
311
|
});
|
|
341
312
|
|
|
342
313
|
// Handle errors
|
|
@@ -394,8 +365,7 @@ s3://my-bucket/ml-cache-events/
|
|
|
394
365
|
{
|
|
395
366
|
"eventId": "550e8400-e29b-41d4-a716-446655440000",
|
|
396
367
|
"timestamp": "2024-01-15T10:30:00.000Z",
|
|
397
|
-
"
|
|
398
|
-
"properties": {
|
|
368
|
+
"data": {
|
|
399
369
|
"productId": "SKU-123",
|
|
400
370
|
"amount": 99.99
|
|
401
371
|
},
|
|
@@ -425,10 +395,7 @@ Create an IAM policy with minimal required permissions:
|
|
|
425
395
|
"Statement": [
|
|
426
396
|
{
|
|
427
397
|
"Effect": "Allow",
|
|
428
|
-
"Action": [
|
|
429
|
-
"s3:PutObject",
|
|
430
|
-
"s3:GetBucketLocation"
|
|
431
|
-
],
|
|
398
|
+
"Action": ["s3:PutObject", "s3:GetBucketLocation"],
|
|
432
399
|
"Resource": [
|
|
433
400
|
"arn:aws:s3:::your-bucket-name",
|
|
434
401
|
"arn:aws:s3:::your-bucket-name/*"
|
|
@@ -443,10 +410,7 @@ For Glacier mode, add:
|
|
|
443
410
|
```json
|
|
444
411
|
{
|
|
445
412
|
"Effect": "Allow",
|
|
446
|
-
"Action": [
|
|
447
|
-
"glacier:UploadArchive",
|
|
448
|
-
"glacier:DescribeVault"
|
|
449
|
-
],
|
|
413
|
+
"Action": ["glacier:UploadArchive", "glacier:DescribeVault"],
|
|
450
414
|
"Resource": "arn:aws:glacier:*:*:vaults/your-vault-name"
|
|
451
415
|
}
|
|
452
416
|
```
|
|
@@ -487,9 +451,9 @@ The more context you capture now, the better your models will be:
|
|
|
487
451
|
|
|
488
452
|
```typescript
|
|
489
453
|
// Good: Rich context for future ML
|
|
490
|
-
await mlCache.
|
|
491
|
-
|
|
492
|
-
|
|
454
|
+
await mlCache.cache({
|
|
455
|
+
data: {
|
|
456
|
+
action: 'product_viewed',
|
|
493
457
|
productId: 'SKU-123',
|
|
494
458
|
category: 'electronics',
|
|
495
459
|
price: 299.99,
|
|
@@ -499,28 +463,14 @@ await mlCache.track({
|
|
|
499
463
|
},
|
|
500
464
|
context: {
|
|
501
465
|
user: { userId: 'user-456', traits: { segment: 'high-value' } },
|
|
502
|
-
page: { referrer: 'google.com'
|
|
466
|
+
page: { referrer: 'google.com' },
|
|
503
467
|
device: { deviceType: 'mobile', os: 'iOS' },
|
|
468
|
+
custom: { searchQuery: 'best headphones' },
|
|
504
469
|
},
|
|
505
470
|
});
|
|
506
471
|
```
|
|
507
472
|
|
|
508
|
-
### 2.
|
|
509
|
-
|
|
510
|
-
Establish naming conventions early:
|
|
511
|
-
|
|
512
|
-
```typescript
|
|
513
|
-
// Use snake_case for event types
|
|
514
|
-
'user_signed_up' // Good
|
|
515
|
-
'userSignedUp' // Avoid
|
|
516
|
-
'User Signed Up' // Avoid
|
|
517
|
-
|
|
518
|
-
// Be specific
|
|
519
|
-
'checkout_started' // Good
|
|
520
|
-
'checkout' // Too vague
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
### 3. Graceful Shutdown
|
|
473
|
+
### 2. Graceful Shutdown
|
|
524
474
|
|
|
525
475
|
Always flush events before application exit:
|
|
526
476
|
|
|
@@ -531,7 +481,7 @@ process.on('SIGTERM', async () => {
|
|
|
531
481
|
});
|
|
532
482
|
```
|
|
533
483
|
|
|
534
|
-
###
|
|
484
|
+
### 3. Monitor Queue Size
|
|
535
485
|
|
|
536
486
|
Prevent memory issues in high-traffic scenarios:
|
|
537
487
|
|
|
@@ -550,14 +500,14 @@ setInterval(() => {
|
|
|
550
500
|
|
|
551
501
|
The data you collect today can power tomorrow's AI features:
|
|
552
502
|
|
|
553
|
-
|
|
|
554
|
-
|
|
555
|
-
|
|
|
556
|
-
|
|
|
557
|
-
|
|
|
558
|
-
|
|
|
559
|
-
|
|
|
560
|
-
|
|
|
503
|
+
| Data Type | Future ML Application |
|
|
504
|
+
| --------------------- | ---------------------------------------------- |
|
|
505
|
+
| Purchase data | Recommendation engine, demand forecasting |
|
|
506
|
+
| Page views | Content personalization, A/B test analysis |
|
|
507
|
+
| Search queries | Search ranking, query understanding |
|
|
508
|
+
| Support interactions | Automated responses, sentiment analysis |
|
|
509
|
+
| User behavior | Churn prediction, engagement scoring |
|
|
510
|
+
| Product interactions | Dynamic pricing, inventory optimization |
|
|
561
511
|
|
|
562
512
|
---
|
|
563
513
|
|
|
@@ -565,19 +515,40 @@ The data you collect today can power tomorrow's AI features:
|
|
|
565
515
|
|
|
566
516
|
### MLCacheClient
|
|
567
517
|
|
|
568
|
-
| Method
|
|
569
|
-
|
|
570
|
-
| `
|
|
571
|
-
| `
|
|
572
|
-
| `
|
|
573
|
-
| `
|
|
574
|
-
| `
|
|
575
|
-
| `
|
|
576
|
-
| `
|
|
577
|
-
| `
|
|
578
|
-
| `
|
|
579
|
-
|
|
580
|
-
|
|
518
|
+
| Method | Description |
|
|
519
|
+
| ------------------- | ---------------------------------- |
|
|
520
|
+
| `cache(event)` | Cache data for ML training |
|
|
521
|
+
| `flush()` | Manually flush the event queue |
|
|
522
|
+
| `getHealth()` | Get SDK health status |
|
|
523
|
+
| `getQueueSize()` | Get current queue size |
|
|
524
|
+
| `getVersion()` | Get SDK version |
|
|
525
|
+
| `shutdown()` | Gracefully shutdown the client |
|
|
526
|
+
| `onEvent(callback)` | Register event callback |
|
|
527
|
+
| `onError(callback)` | Register error callback |
|
|
528
|
+
| `onFlush(callback)` | Register flush callback |
|
|
529
|
+
|
|
530
|
+
### Event Structure
|
|
531
|
+
|
|
532
|
+
```typescript
|
|
533
|
+
interface MLCacheEvent {
|
|
534
|
+
// Auto-generated if not provided
|
|
535
|
+
eventId?: string;
|
|
536
|
+
timestamp?: string;
|
|
537
|
+
|
|
538
|
+
// Your business data
|
|
539
|
+
data?: Record<string, unknown>;
|
|
540
|
+
|
|
541
|
+
// Rich context
|
|
542
|
+
context?: {
|
|
543
|
+
user?: { userId?: string; anonymousId?: string; traits?: Record<string, unknown> };
|
|
544
|
+
device?: { userAgent?: string; deviceType?: string; os?: string; /* ... */ };
|
|
545
|
+
page?: { url?: string; path?: string; title?: string; referrer?: string };
|
|
546
|
+
campaign?: { source?: string; medium?: string; name?: string; /* ... */ };
|
|
547
|
+
app?: { name?: string; version?: string; build?: string };
|
|
548
|
+
custom?: Record<string, unknown>;
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
```
|
|
581
552
|
|
|
582
553
|
---
|
|
583
554
|
|
package/dist/client.d.ts
CHANGED
|
@@ -20,12 +20,14 @@ import type { MLCacheConfig, MLCacheEvent, TrackResult, FlushResult, HealthStatu
|
|
|
20
20
|
* storageMode: 'S3',
|
|
21
21
|
* });
|
|
22
22
|
*
|
|
23
|
-
* await client.
|
|
24
|
-
*
|
|
25
|
-
* properties: {
|
|
23
|
+
* await client.cache({
|
|
24
|
+
* data: {
|
|
26
25
|
* productId: '12345',
|
|
27
26
|
* amount: 99.99,
|
|
28
27
|
* },
|
|
28
|
+
* context: {
|
|
29
|
+
* user: { userId: 'user-123' },
|
|
30
|
+
* },
|
|
29
31
|
* });
|
|
30
32
|
* ```
|
|
31
33
|
*/
|
|
@@ -85,52 +87,32 @@ export declare class MLCacheClient {
|
|
|
85
87
|
*/
|
|
86
88
|
private storeEventsWithRetry;
|
|
87
89
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @param {MLCacheEvent} event - Event to
|
|
90
|
-
* @returns {Promise<TrackResult>}
|
|
90
|
+
* Caches an event for ML training
|
|
91
|
+
* @param {MLCacheEvent} event - Event to cache
|
|
92
|
+
* @returns {Promise<TrackResult>} Cache result
|
|
91
93
|
* @example
|
|
92
94
|
* ```typescript
|
|
93
|
-
* const result = await client.
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
95
|
+
* const result = await client.cache({
|
|
96
|
+
* data: {
|
|
97
|
+
* productId: 'SKU-12345',
|
|
98
|
+
* productName: 'Premium Widget',
|
|
99
|
+
* price: 99.99,
|
|
100
|
+
* currency: 'USD',
|
|
101
|
+
* quantity: 2,
|
|
98
102
|
* },
|
|
99
103
|
* context: {
|
|
100
|
-
* user: {
|
|
104
|
+
* user: {
|
|
105
|
+
* userId: 'user-789',
|
|
106
|
+
* traits: {
|
|
107
|
+
* plan: 'premium',
|
|
108
|
+
* signupDate: '2024-01-15',
|
|
109
|
+
* },
|
|
110
|
+
* },
|
|
101
111
|
* },
|
|
102
112
|
* });
|
|
103
113
|
* ```
|
|
104
114
|
*/
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Identifies a user with traits
|
|
108
|
-
* @param {string} userId - User identifier
|
|
109
|
-
* @param {Record<string, unknown>} [traits] - User traits
|
|
110
|
-
* @returns {Promise<TrackResult>} Track result
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* await client.identify('user123', {
|
|
114
|
-
* email: 'user@example.com',
|
|
115
|
-
* plan: 'premium',
|
|
116
|
-
* });
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
identify(userId: string, traits?: Record<string, unknown>): Promise<TrackResult>;
|
|
120
|
-
/**
|
|
121
|
-
* Tracks a page view
|
|
122
|
-
* @param {string} name - Page name
|
|
123
|
-
* @param {Record<string, unknown>} [properties] - Page properties
|
|
124
|
-
* @returns {Promise<TrackResult>} Track result
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* await client.page('Home', {
|
|
128
|
-
* url: 'https://example.com',
|
|
129
|
-
* title: 'Welcome Home',
|
|
130
|
-
* });
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
page(name: string, properties?: Record<string, unknown>): Promise<TrackResult>;
|
|
115
|
+
cache(event: MLCacheEvent): Promise<TrackResult>;
|
|
134
116
|
/**
|
|
135
117
|
* Flushes all queued events
|
|
136
118
|
* @returns {Promise<FlushResult>} Flush result
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EAId,MAAM,SAAS,CAAC;AAoBjB
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EAId,MAAM,SAAS,CAAC;AAoBjB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,aAAa;IACxB,eAAe;IACf,OAAO,CAAC,MAAM,CAAgB;IAE9B,eAAe;IACf,OAAO,CAAC,WAAW,CAAc;IAEjC,eAAe;IACf,OAAO,CAAC,WAAW,CAAc;IAEjC,eAAe;IACf,OAAO,CAAC,MAAM,CAAS;IAEvB,eAAe;IACf,OAAO,CAAC,SAAS,CAA0B;IAE3C,eAAe;IACf,OAAO,CAAC,cAAc,CAA+B;IAErD,eAAe;IACf,OAAO,CAAC,KAAK,CAAa;IAE1B,eAAe;IACf,OAAO,CAAC,aAAa,CAAS;IAE9B,eAAe;IACf,OAAO,CAAC,cAAc,CAAS;IAE/B,eAAe;IACf,OAAO,CAAC,SAAS,CAAqB;IAEtC,eAAe;IACf,OAAO,CAAC,SAAS,CAAuB;IAExC,eAAe;IACf,OAAO,CAAC,cAAc,CAAuB;IAE7C,eAAe;IACf,OAAO,CAAC,cAAc,CAAuB;IAE7C,eAAe;IACf,OAAO,CAAC,cAAc,CAAuB;IAE7C;;;;OAIG;gBACS,MAAM,EAAE,aAAa;IA2BjC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;;;;OAKG;YACW,gBAAgB;IAU9B;;;;;;OAMG;YACW,oBAAoB;IA4FlC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAuDtD;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;IAuBnC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IAuBxC;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAItC;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAItC;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAItC;;;OAGG;IACH,YAAY,IAAI,MAAM;IAItB;;;OAGG;IACH,UAAU,IAAI,MAAM;IAIpB;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAmBhC"}
|
package/dist/client.js
CHANGED
|
@@ -27,12 +27,14 @@ const queue_1 = require("./queue");
|
|
|
27
27
|
* storageMode: 'S3',
|
|
28
28
|
* });
|
|
29
29
|
*
|
|
30
|
-
* await client.
|
|
31
|
-
*
|
|
32
|
-
* properties: {
|
|
30
|
+
* await client.cache({
|
|
31
|
+
* data: {
|
|
33
32
|
* productId: '12345',
|
|
34
33
|
* amount: 99.99,
|
|
35
34
|
* },
|
|
35
|
+
* context: {
|
|
36
|
+
* user: { userId: 'user-123' },
|
|
37
|
+
* },
|
|
36
38
|
* });
|
|
37
39
|
* ```
|
|
38
40
|
*/
|
|
@@ -86,8 +88,7 @@ class MLCacheClient {
|
|
|
86
88
|
* @private
|
|
87
89
|
*/
|
|
88
90
|
initializeStorage() {
|
|
89
|
-
if (this.config.storageMode === 'S3' ||
|
|
90
|
-
this.config.storageMode === 'S3_TO_GLACIER') {
|
|
91
|
+
if (this.config.storageMode === 'S3' || this.config.storageMode === 'S3_TO_GLACIER') {
|
|
91
92
|
if (this.config.s3) {
|
|
92
93
|
this.s3Storage = new s3_storage_1.S3Storage(this.config.s3, this.config.credentials, this.logger.child('s3'));
|
|
93
94
|
}
|
|
@@ -197,24 +198,32 @@ class MLCacheClient {
|
|
|
197
198
|
return result;
|
|
198
199
|
}
|
|
199
200
|
/**
|
|
200
|
-
*
|
|
201
|
-
* @param {MLCacheEvent} event - Event to
|
|
202
|
-
* @returns {Promise<TrackResult>}
|
|
201
|
+
* Caches an event for ML training
|
|
202
|
+
* @param {MLCacheEvent} event - Event to cache
|
|
203
|
+
* @returns {Promise<TrackResult>} Cache result
|
|
203
204
|
* @example
|
|
204
205
|
* ```typescript
|
|
205
|
-
* const result = await client.
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
206
|
+
* const result = await client.cache({
|
|
207
|
+
* data: {
|
|
208
|
+
* productId: 'SKU-12345',
|
|
209
|
+
* productName: 'Premium Widget',
|
|
210
|
+
* price: 99.99,
|
|
211
|
+
* currency: 'USD',
|
|
212
|
+
* quantity: 2,
|
|
210
213
|
* },
|
|
211
214
|
* context: {
|
|
212
|
-
* user: {
|
|
215
|
+
* user: {
|
|
216
|
+
* userId: 'user-789',
|
|
217
|
+
* traits: {
|
|
218
|
+
* plan: 'premium',
|
|
219
|
+
* signupDate: '2024-01-15',
|
|
220
|
+
* },
|
|
221
|
+
* },
|
|
213
222
|
* },
|
|
214
223
|
* });
|
|
215
224
|
* ```
|
|
216
225
|
*/
|
|
217
|
-
async
|
|
226
|
+
async cache(event) {
|
|
218
227
|
const result = {
|
|
219
228
|
success: false,
|
|
220
229
|
eventId: '',
|
|
@@ -252,60 +261,12 @@ class MLCacheClient {
|
|
|
252
261
|
}
|
|
253
262
|
catch (error) {
|
|
254
263
|
result.error = error instanceof Error ? error.message : String(error);
|
|
255
|
-
this.logger.error('
|
|
256
|
-
eventType: event.eventType,
|
|
264
|
+
this.logger.error('Cache failed', {
|
|
257
265
|
error: result.error,
|
|
258
266
|
});
|
|
259
267
|
return result;
|
|
260
268
|
}
|
|
261
269
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Identifies a user with traits
|
|
264
|
-
* @param {string} userId - User identifier
|
|
265
|
-
* @param {Record<string, unknown>} [traits] - User traits
|
|
266
|
-
* @returns {Promise<TrackResult>} Track result
|
|
267
|
-
* @example
|
|
268
|
-
* ```typescript
|
|
269
|
-
* await client.identify('user123', {
|
|
270
|
-
* email: 'user@example.com',
|
|
271
|
-
* plan: 'premium',
|
|
272
|
-
* });
|
|
273
|
-
* ```
|
|
274
|
-
*/
|
|
275
|
-
async identify(userId, traits) {
|
|
276
|
-
return this.track({
|
|
277
|
-
eventType: 'identify',
|
|
278
|
-
context: {
|
|
279
|
-
user: {
|
|
280
|
-
userId,
|
|
281
|
-
traits,
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
properties: traits,
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Tracks a page view
|
|
289
|
-
* @param {string} name - Page name
|
|
290
|
-
* @param {Record<string, unknown>} [properties] - Page properties
|
|
291
|
-
* @returns {Promise<TrackResult>} Track result
|
|
292
|
-
* @example
|
|
293
|
-
* ```typescript
|
|
294
|
-
* await client.page('Home', {
|
|
295
|
-
* url: 'https://example.com',
|
|
296
|
-
* title: 'Welcome Home',
|
|
297
|
-
* });
|
|
298
|
-
* ```
|
|
299
|
-
*/
|
|
300
|
-
async page(name, properties) {
|
|
301
|
-
return this.track({
|
|
302
|
-
eventType: 'page',
|
|
303
|
-
properties: {
|
|
304
|
-
name,
|
|
305
|
-
...properties,
|
|
306
|
-
},
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
270
|
/**
|
|
310
271
|
* Flushes all queued events
|
|
311
272
|
* @returns {Promise<FlushResult>} Flush result
|
|
@@ -349,8 +310,7 @@ class MLCacheClient {
|
|
|
349
310
|
if (this.glacierStorage) {
|
|
350
311
|
status.glacierConnected = await this.glacierStorage.testConnection();
|
|
351
312
|
}
|
|
352
|
-
status.healthy =
|
|
353
|
-
status.healthy && (status.s3Connected || status.glacierConnected);
|
|
313
|
+
status.healthy = status.healthy && (status.s3Connected || status.glacierConnected);
|
|
354
314
|
return status;
|
|
355
315
|
}
|
|
356
316
|
/**
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH,2CAMqB;AACrB,mCAOiB;AACjB,qDAAiD;AACjD,+DAA2D;AAC3D,mCAAqC;AAErC
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH,2CAMqB;AACrB,mCAOiB;AACjB,qDAAiD;AACjD,+DAA2D;AAC3D,mCAAqC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,aAAa;IA2CxB;;;;OAIG;IACH,YAAY,MAAqB;QAnCjC,eAAe;QACP,cAAS,GAAqB,IAAI,CAAC;QAE3C,eAAe;QACP,mBAAc,GAA0B,IAAI,CAAC;QAKrD,eAAe;QACP,kBAAa,GAAG,KAAK,CAAC;QAE9B,eAAe;QACP,mBAAc,GAAG,KAAK,CAAC;QAE/B,eAAe;QACP,cAAS,GAAgB,IAAI,CAAC;QAEtC,eAAe;QACP,cAAS,GAAkB,IAAI,CAAC;QAExC,eAAe;QACP,mBAAc,GAAoB,EAAE,CAAC;QAE7C,eAAe;QACP,mBAAc,G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|
|
|
74
74
|
*/
|
|
75
75
|
export declare const RESERVED_EVENT_PROPERTIES: readonly string[];
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* Maximum data key length
|
|
78
78
|
* @constant
|
|
79
79
|
*/
|
|
80
|
-
export declare const
|
|
81
|
-
/**
|
|
82
|
-
* Maximum event type length
|
|
83
|
-
* @constant
|
|
84
|
-
*/
|
|
85
|
-
export declare const MAX_EVENT_TYPE_LENGTH = 128;
|
|
86
|
-
/**
|
|
87
|
-
* Maximum property key length
|
|
88
|
-
* @constant
|
|
89
|
-
*/
|
|
90
|
-
export declare const MAX_PROPERTY_KEY_LENGTH = 256;
|
|
80
|
+
export declare const MAX_DATA_KEY_LENGTH = 256;
|
|
91
81
|
/**
|
|
92
82
|
* Health check interval in milliseconds (5 minutes)
|
|
93
83
|
* @constant
|