ml-cache 1.0.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/LICENSE +21 -0
- package/README.md +599 -0
- package/dist/client.d.ts +175 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +411 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +184 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +236 -0
- package/dist/constants.js.map +1 -0
- package/dist/esm/client.d.ts +175 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +407 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/constants.d.ts +184 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +233 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +58 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/queue.d.ts +106 -0
- package/dist/esm/queue.d.ts.map +1 -0
- package/dist/esm/queue.js +207 -0
- package/dist/esm/queue.js.map +1 -0
- package/dist/esm/storage/glacier-storage.d.ts +77 -0
- package/dist/esm/storage/glacier-storage.d.ts.map +1 -0
- package/dist/esm/storage/glacier-storage.js +133 -0
- package/dist/esm/storage/glacier-storage.js.map +1 -0
- package/dist/esm/storage/index.d.ts +7 -0
- package/dist/esm/storage/index.d.ts.map +1 -0
- package/dist/esm/storage/index.js +7 -0
- package/dist/esm/storage/index.js.map +1 -0
- package/dist/esm/storage/s3-storage.d.ts +89 -0
- package/dist/esm/storage/s3-storage.d.ts.map +1 -0
- package/dist/esm/storage/s3-storage.js +161 -0
- package/dist/esm/storage/s3-storage.js.map +1 -0
- package/dist/esm/types/index.d.ts +337 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +6 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/utils/helpers.d.ts +132 -0
- package/dist/esm/utils/helpers.d.ts.map +1 -0
- package/dist/esm/utils/helpers.js +198 -0
- package/dist/esm/utils/helpers.js.map +1 -0
- package/dist/esm/utils/index.d.ts +8 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +8 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/logger.d.ts +110 -0
- package/dist/esm/utils/logger.d.ts.map +1 -0
- package/dist/esm/utils/logger.js +177 -0
- package/dist/esm/utils/logger.js.map +1 -0
- package/dist/esm/utils/validator.d.ts +77 -0
- package/dist/esm/utils/validator.d.ts.map +1 -0
- package/dist/esm/utils/validator.js +208 -0
- package/dist/esm/utils/validator.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +72 -0
- package/dist/queue.d.ts +106 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +211 -0
- package/dist/queue.js.map +1 -0
- package/dist/storage/glacier-storage.d.ts +77 -0
- package/dist/storage/glacier-storage.d.ts.map +1 -0
- package/dist/storage/glacier-storage.js +137 -0
- package/dist/storage/glacier-storage.js.map +1 -0
- package/dist/storage/index.d.ts +7 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +12 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/s3-storage.d.ts +89 -0
- package/dist/storage/s3-storage.d.ts.map +1 -0
- package/dist/storage/s3-storage.js +165 -0
- package/dist/storage/s3-storage.js.map +1 -0
- package/dist/types/index.d.ts +337 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/helpers.d.ts +132 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +215 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +110 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +181 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/validator.d.ts +77 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +221 -0
- package/dist/utils/validator.js.map +1 -0
- package/package.json +64 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main ML Cache SDK client
|
|
3
|
+
* @module ml-cache/client
|
|
4
|
+
*/
|
|
5
|
+
import type { MLCacheConfig, MLCacheEvent, TrackResult, FlushResult, HealthStatus, EventCallback, ErrorCallback, FlushCallback } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* ML Cache SDK client for collecting and storing events for future ML training
|
|
8
|
+
* @class MLCacheClient
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const client = new MLCacheClient({
|
|
12
|
+
* credentials: {
|
|
13
|
+
* accessKeyId: 'YOUR_ACCESS_KEY',
|
|
14
|
+
* secretAccessKey: 'YOUR_SECRET_KEY',
|
|
15
|
+
* },
|
|
16
|
+
* s3: {
|
|
17
|
+
* bucket: 'my-ml-data-bucket',
|
|
18
|
+
* region: 'us-east-1',
|
|
19
|
+
* },
|
|
20
|
+
* storageMode: 'S3',
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* await client.track({
|
|
24
|
+
* eventType: 'purchase',
|
|
25
|
+
* properties: {
|
|
26
|
+
* productId: '12345',
|
|
27
|
+
* amount: 99.99,
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class MLCacheClient {
|
|
33
|
+
/** @private */
|
|
34
|
+
private config;
|
|
35
|
+
/** @private */
|
|
36
|
+
private batchConfig;
|
|
37
|
+
/** @private */
|
|
38
|
+
private retryConfig;
|
|
39
|
+
/** @private */
|
|
40
|
+
private logger;
|
|
41
|
+
/** @private */
|
|
42
|
+
private s3Storage;
|
|
43
|
+
/** @private */
|
|
44
|
+
private glacierStorage;
|
|
45
|
+
/** @private */
|
|
46
|
+
private queue;
|
|
47
|
+
/** @private */
|
|
48
|
+
private isInitialized;
|
|
49
|
+
/** @private */
|
|
50
|
+
private isShuttingDown;
|
|
51
|
+
/** @private */
|
|
52
|
+
private lastFlush;
|
|
53
|
+
/** @private */
|
|
54
|
+
private lastError;
|
|
55
|
+
/** @private */
|
|
56
|
+
private eventCallbacks;
|
|
57
|
+
/** @private */
|
|
58
|
+
private errorCallbacks;
|
|
59
|
+
/** @private */
|
|
60
|
+
private flushCallbacks;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new MLCacheClient instance
|
|
63
|
+
* @param {MLCacheConfig} config - SDK configuration
|
|
64
|
+
* @throws {ValidationError} If configuration is invalid
|
|
65
|
+
*/
|
|
66
|
+
constructor(config: MLCacheConfig);
|
|
67
|
+
/**
|
|
68
|
+
* Initializes storage providers based on configuration
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private initializeStorage;
|
|
72
|
+
/**
|
|
73
|
+
* Handles a batch of events ready for storage
|
|
74
|
+
* @private
|
|
75
|
+
* @param {MLCacheEvent[]} events - Events to store
|
|
76
|
+
* @param {string} batchId - Batch identifier
|
|
77
|
+
*/
|
|
78
|
+
private handleBatchReady;
|
|
79
|
+
/**
|
|
80
|
+
* Stores events with retry logic
|
|
81
|
+
* @private
|
|
82
|
+
* @param {MLCacheEvent[]} events - Events to store
|
|
83
|
+
* @param {string} batchId - Batch identifier
|
|
84
|
+
* @returns {Promise<FlushResult>} Flush result
|
|
85
|
+
*/
|
|
86
|
+
private storeEventsWithRetry;
|
|
87
|
+
/**
|
|
88
|
+
* Tracks an event
|
|
89
|
+
* @param {MLCacheEvent} event - Event to track
|
|
90
|
+
* @returns {Promise<TrackResult>} Track result
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const result = await client.track({
|
|
94
|
+
* eventType: 'page_view',
|
|
95
|
+
* properties: {
|
|
96
|
+
* page: '/home',
|
|
97
|
+
* referrer: 'google.com',
|
|
98
|
+
* },
|
|
99
|
+
* context: {
|
|
100
|
+
* user: { userId: 'user123' },
|
|
101
|
+
* },
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
track(event: MLCacheEvent): Promise<TrackResult>;
|
|
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>;
|
|
134
|
+
/**
|
|
135
|
+
* Flushes all queued events
|
|
136
|
+
* @returns {Promise<FlushResult>} Flush result
|
|
137
|
+
*/
|
|
138
|
+
flush(): Promise<FlushResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Gets the health status of the client
|
|
141
|
+
* @returns {Promise<HealthStatus>} Health status
|
|
142
|
+
*/
|
|
143
|
+
getHealth(): Promise<HealthStatus>;
|
|
144
|
+
/**
|
|
145
|
+
* Registers an event callback
|
|
146
|
+
* @param {EventCallback} callback - Callback function
|
|
147
|
+
*/
|
|
148
|
+
onEvent(callback: EventCallback): void;
|
|
149
|
+
/**
|
|
150
|
+
* Registers an error callback
|
|
151
|
+
* @param {ErrorCallback} callback - Callback function
|
|
152
|
+
*/
|
|
153
|
+
onError(callback: ErrorCallback): void;
|
|
154
|
+
/**
|
|
155
|
+
* Registers a flush callback
|
|
156
|
+
* @param {FlushCallback} callback - Callback function
|
|
157
|
+
*/
|
|
158
|
+
onFlush(callback: FlushCallback): void;
|
|
159
|
+
/**
|
|
160
|
+
* Gets the current queue size
|
|
161
|
+
* @returns {number} Queue size
|
|
162
|
+
*/
|
|
163
|
+
getQueueSize(): number;
|
|
164
|
+
/**
|
|
165
|
+
* Gets the SDK version
|
|
166
|
+
* @returns {string} SDK version
|
|
167
|
+
*/
|
|
168
|
+
getVersion(): string;
|
|
169
|
+
/**
|
|
170
|
+
* Shuts down the client gracefully
|
|
171
|
+
* @returns {Promise<void>}
|
|
172
|
+
*/
|
|
173
|
+
shutdown(): Promise<void>;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;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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;;;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
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Main ML Cache SDK client
|
|
4
|
+
* @module ml-cache/client
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MLCacheClient = void 0;
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
const s3_storage_1 = require("./storage/s3-storage");
|
|
11
|
+
const glacier_storage_1 = require("./storage/glacier-storage");
|
|
12
|
+
const queue_1 = require("./queue");
|
|
13
|
+
/**
|
|
14
|
+
* ML Cache SDK client for collecting and storing events for future ML training
|
|
15
|
+
* @class MLCacheClient
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const client = new MLCacheClient({
|
|
19
|
+
* credentials: {
|
|
20
|
+
* accessKeyId: 'YOUR_ACCESS_KEY',
|
|
21
|
+
* secretAccessKey: 'YOUR_SECRET_KEY',
|
|
22
|
+
* },
|
|
23
|
+
* s3: {
|
|
24
|
+
* bucket: 'my-ml-data-bucket',
|
|
25
|
+
* region: 'us-east-1',
|
|
26
|
+
* },
|
|
27
|
+
* storageMode: 'S3',
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* await client.track({
|
|
31
|
+
* eventType: 'purchase',
|
|
32
|
+
* properties: {
|
|
33
|
+
* productId: '12345',
|
|
34
|
+
* amount: 99.99,
|
|
35
|
+
* },
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
class MLCacheClient {
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new MLCacheClient instance
|
|
42
|
+
* @param {MLCacheConfig} config - SDK configuration
|
|
43
|
+
* @throws {ValidationError} If configuration is invalid
|
|
44
|
+
*/
|
|
45
|
+
constructor(config) {
|
|
46
|
+
/** @private */
|
|
47
|
+
this.s3Storage = null;
|
|
48
|
+
/** @private */
|
|
49
|
+
this.glacierStorage = null;
|
|
50
|
+
/** @private */
|
|
51
|
+
this.isInitialized = false;
|
|
52
|
+
/** @private */
|
|
53
|
+
this.isShuttingDown = false;
|
|
54
|
+
/** @private */
|
|
55
|
+
this.lastFlush = null;
|
|
56
|
+
/** @private */
|
|
57
|
+
this.lastError = null;
|
|
58
|
+
/** @private */
|
|
59
|
+
this.eventCallbacks = [];
|
|
60
|
+
/** @private */
|
|
61
|
+
this.errorCallbacks = [];
|
|
62
|
+
/** @private */
|
|
63
|
+
this.flushCallbacks = [];
|
|
64
|
+
(0, utils_1.validateConfig)(config);
|
|
65
|
+
this.config = config;
|
|
66
|
+
this.batchConfig = { ...constants_1.DEFAULT_BATCH_CONFIG, ...config.batch };
|
|
67
|
+
this.retryConfig = { ...constants_1.DEFAULT_RETRY_CONFIG, ...config.retry };
|
|
68
|
+
const logConfig = {
|
|
69
|
+
...constants_1.DEFAULT_LOG_CONFIG,
|
|
70
|
+
...config.log,
|
|
71
|
+
level: config.debug ? 'debug' : config.log?.level || 'info',
|
|
72
|
+
};
|
|
73
|
+
this.logger = new utils_1.Logger(logConfig);
|
|
74
|
+
this.queue = new queue_1.EventQueue(this.batchConfig, this.logger);
|
|
75
|
+
this.queue.setOnBatchReady(this.handleBatchReady.bind(this));
|
|
76
|
+
this.initializeStorage();
|
|
77
|
+
this.isInitialized = true;
|
|
78
|
+
this.logger.info('MLCacheClient initialized', {
|
|
79
|
+
storageMode: config.storageMode,
|
|
80
|
+
batchEnabled: this.batchConfig.enabled,
|
|
81
|
+
version: constants_1.SDK_VERSION,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Initializes storage providers based on configuration
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
initializeStorage() {
|
|
89
|
+
if (this.config.storageMode === 'S3' ||
|
|
90
|
+
this.config.storageMode === 'S3_TO_GLACIER') {
|
|
91
|
+
if (this.config.s3) {
|
|
92
|
+
this.s3Storage = new s3_storage_1.S3Storage(this.config.s3, this.config.credentials, this.logger.child('s3'));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (this.config.storageMode === 'GLACIER') {
|
|
96
|
+
if (this.config.glacier) {
|
|
97
|
+
this.glacierStorage = new glacier_storage_1.GlacierStorage(this.config.glacier, this.config.credentials, this.logger.child('glacier'));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Handles a batch of events ready for storage
|
|
103
|
+
* @private
|
|
104
|
+
* @param {MLCacheEvent[]} events - Events to store
|
|
105
|
+
* @param {string} batchId - Batch identifier
|
|
106
|
+
*/
|
|
107
|
+
async handleBatchReady(events, batchId) {
|
|
108
|
+
const result = await this.storeEventsWithRetry(events, batchId);
|
|
109
|
+
this.flushCallbacks.forEach((callback) => callback(result));
|
|
110
|
+
if (result.success) {
|
|
111
|
+
this.lastFlush = new Date();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Stores events with retry logic
|
|
116
|
+
* @private
|
|
117
|
+
* @param {MLCacheEvent[]} events - Events to store
|
|
118
|
+
* @param {string} batchId - Batch identifier
|
|
119
|
+
* @returns {Promise<FlushResult>} Flush result
|
|
120
|
+
*/
|
|
121
|
+
async storeEventsWithRetry(events, batchId) {
|
|
122
|
+
const result = {
|
|
123
|
+
success: false,
|
|
124
|
+
eventCount: events.length,
|
|
125
|
+
storageLocations: [],
|
|
126
|
+
failedEventIds: [],
|
|
127
|
+
errors: [],
|
|
128
|
+
};
|
|
129
|
+
for (let attempt = 0; attempt <= this.retryConfig.maxRetries; attempt++) {
|
|
130
|
+
try {
|
|
131
|
+
if (this.s3Storage) {
|
|
132
|
+
const s3Result = await this.s3Storage.storeBatch(events, batchId);
|
|
133
|
+
if (s3Result.success) {
|
|
134
|
+
result.success = true;
|
|
135
|
+
result.storageLocations.push(`s3://${s3Result.bucket}/${s3Result.key}`);
|
|
136
|
+
this.logger.info('Batch stored successfully', {
|
|
137
|
+
batchId,
|
|
138
|
+
eventCount: events.length,
|
|
139
|
+
location: result.storageLocations[0],
|
|
140
|
+
});
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
throw new Error(s3Result.error || 'S3 storage failed');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (this.glacierStorage) {
|
|
148
|
+
const glacierResult = await this.glacierStorage.archiveEvents(events, batchId);
|
|
149
|
+
if (glacierResult.success) {
|
|
150
|
+
result.success = true;
|
|
151
|
+
result.storageLocations.push(`glacier://${glacierResult.vaultName}/${glacierResult.archiveId}`);
|
|
152
|
+
this.logger.info('Batch archived successfully', {
|
|
153
|
+
batchId,
|
|
154
|
+
eventCount: events.length,
|
|
155
|
+
archiveId: glacierResult.archiveId,
|
|
156
|
+
});
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
throw new Error(glacierResult.error || 'Glacier storage failed');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
throw new Error('No storage provider configured');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
169
|
+
result.errors.push(errorMessage);
|
|
170
|
+
this.lastError = errorMessage;
|
|
171
|
+
if (attempt < this.retryConfig.maxRetries) {
|
|
172
|
+
const delay = (0, utils_1.calculateRetryDelay)(attempt, this.retryConfig.initialDelayMs, this.retryConfig.maxDelayMs, this.retryConfig.exponentialBackoff);
|
|
173
|
+
this.logger.warn('Storage failed, retrying', {
|
|
174
|
+
batchId,
|
|
175
|
+
attempt: attempt + 1,
|
|
176
|
+
maxRetries: this.retryConfig.maxRetries,
|
|
177
|
+
delayMs: delay,
|
|
178
|
+
error: errorMessage,
|
|
179
|
+
});
|
|
180
|
+
await (0, utils_1.sleep)(delay);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.logger.error('Storage failed after all retries', {
|
|
184
|
+
batchId,
|
|
185
|
+
eventCount: events.length,
|
|
186
|
+
errors: result.errors,
|
|
187
|
+
});
|
|
188
|
+
result.failedEventIds = events
|
|
189
|
+
.map((e) => e.eventId)
|
|
190
|
+
.filter((id) => id !== undefined);
|
|
191
|
+
events.forEach((event) => {
|
|
192
|
+
this.errorCallbacks.forEach((callback) => callback(new Error(errorMessage), event));
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Tracks an event
|
|
201
|
+
* @param {MLCacheEvent} event - Event to track
|
|
202
|
+
* @returns {Promise<TrackResult>} Track result
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const result = await client.track({
|
|
206
|
+
* eventType: 'page_view',
|
|
207
|
+
* properties: {
|
|
208
|
+
* page: '/home',
|
|
209
|
+
* referrer: 'google.com',
|
|
210
|
+
* },
|
|
211
|
+
* context: {
|
|
212
|
+
* user: { userId: 'user123' },
|
|
213
|
+
* },
|
|
214
|
+
* });
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
async track(event) {
|
|
218
|
+
const result = {
|
|
219
|
+
success: false,
|
|
220
|
+
eventId: '',
|
|
221
|
+
queued: false,
|
|
222
|
+
};
|
|
223
|
+
if (this.isShuttingDown) {
|
|
224
|
+
result.error = 'Client is shutting down';
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
(0, utils_1.validateEvent)(event);
|
|
229
|
+
const enrichedEvent = (0, utils_1.enrichEvent)(event, {
|
|
230
|
+
sourceApp: this.config.sourceApp,
|
|
231
|
+
environment: this.config.environment,
|
|
232
|
+
});
|
|
233
|
+
result.eventId = enrichedEvent.eventId || '';
|
|
234
|
+
this.eventCallbacks.forEach((callback) => callback(enrichedEvent));
|
|
235
|
+
if (this.batchConfig.enabled) {
|
|
236
|
+
const enqueued = this.queue.enqueue(enrichedEvent);
|
|
237
|
+
result.success = enqueued;
|
|
238
|
+
result.queued = enqueued;
|
|
239
|
+
if (!enqueued) {
|
|
240
|
+
result.error = 'Queue is full';
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
const flushResult = await this.storeEventsWithRetry([enrichedEvent], enrichedEvent.eventId || '');
|
|
245
|
+
result.success = flushResult.success;
|
|
246
|
+
result.storageLocation = flushResult.storageLocations[0];
|
|
247
|
+
if (!result.success) {
|
|
248
|
+
result.error = flushResult.errors.join('; ');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return result;
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
result.error = error instanceof Error ? error.message : String(error);
|
|
255
|
+
this.logger.error('Track failed', {
|
|
256
|
+
eventType: event.eventType,
|
|
257
|
+
error: result.error,
|
|
258
|
+
});
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
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
|
+
/**
|
|
310
|
+
* Flushes all queued events
|
|
311
|
+
* @returns {Promise<FlushResult>} Flush result
|
|
312
|
+
*/
|
|
313
|
+
async flush() {
|
|
314
|
+
this.logger.debug('Manual flush triggered');
|
|
315
|
+
const events = await this.queue.flush();
|
|
316
|
+
if (events.length === 0) {
|
|
317
|
+
return {
|
|
318
|
+
success: true,
|
|
319
|
+
eventCount: 0,
|
|
320
|
+
storageLocations: [],
|
|
321
|
+
failedEventIds: [],
|
|
322
|
+
errors: [],
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
success: true,
|
|
327
|
+
eventCount: events.length,
|
|
328
|
+
storageLocations: [],
|
|
329
|
+
failedEventIds: [],
|
|
330
|
+
errors: [],
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Gets the health status of the client
|
|
335
|
+
* @returns {Promise<HealthStatus>} Health status
|
|
336
|
+
*/
|
|
337
|
+
async getHealth() {
|
|
338
|
+
const status = {
|
|
339
|
+
healthy: this.isInitialized && !this.isShuttingDown,
|
|
340
|
+
s3Connected: false,
|
|
341
|
+
glacierConnected: false,
|
|
342
|
+
queueSize: this.queue.size(),
|
|
343
|
+
lastFlush: this.lastFlush?.toISOString(),
|
|
344
|
+
lastError: this.lastError || undefined,
|
|
345
|
+
};
|
|
346
|
+
if (this.s3Storage) {
|
|
347
|
+
status.s3Connected = await this.s3Storage.testConnection();
|
|
348
|
+
}
|
|
349
|
+
if (this.glacierStorage) {
|
|
350
|
+
status.glacierConnected = await this.glacierStorage.testConnection();
|
|
351
|
+
}
|
|
352
|
+
status.healthy =
|
|
353
|
+
status.healthy && (status.s3Connected || status.glacierConnected);
|
|
354
|
+
return status;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Registers an event callback
|
|
358
|
+
* @param {EventCallback} callback - Callback function
|
|
359
|
+
*/
|
|
360
|
+
onEvent(callback) {
|
|
361
|
+
this.eventCallbacks.push(callback);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Registers an error callback
|
|
365
|
+
* @param {ErrorCallback} callback - Callback function
|
|
366
|
+
*/
|
|
367
|
+
onError(callback) {
|
|
368
|
+
this.errorCallbacks.push(callback);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Registers a flush callback
|
|
372
|
+
* @param {FlushCallback} callback - Callback function
|
|
373
|
+
*/
|
|
374
|
+
onFlush(callback) {
|
|
375
|
+
this.flushCallbacks.push(callback);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Gets the current queue size
|
|
379
|
+
* @returns {number} Queue size
|
|
380
|
+
*/
|
|
381
|
+
getQueueSize() {
|
|
382
|
+
return this.queue.size();
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Gets the SDK version
|
|
386
|
+
* @returns {string} SDK version
|
|
387
|
+
*/
|
|
388
|
+
getVersion() {
|
|
389
|
+
return constants_1.SDK_VERSION;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Shuts down the client gracefully
|
|
393
|
+
* @returns {Promise<void>}
|
|
394
|
+
*/
|
|
395
|
+
async shutdown() {
|
|
396
|
+
if (this.isShuttingDown) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
this.logger.info('Shutting down MLCacheClient');
|
|
400
|
+
this.isShuttingDown = true;
|
|
401
|
+
const shutdownPromise = this.flush();
|
|
402
|
+
const timeoutPromise = (0, utils_1.sleep)(constants_1.SHUTDOWN_GRACE_PERIOD_MS);
|
|
403
|
+
await Promise.race([shutdownPromise, timeoutPromise]);
|
|
404
|
+
this.queue.destroy();
|
|
405
|
+
this.s3Storage?.destroy();
|
|
406
|
+
this.glacierStorage?.destroy();
|
|
407
|
+
this.logger.info('MLCacheClient shut down complete');
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
exports.MLCacheClient = MLCacheClient;
|
|
411
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;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,GAAoB,EAAE,CAAC;QAE7C,eAAe;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