mem0ai 1.0.10 → 1.0.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.
package/README.md CHANGED
@@ -1,15 +1,16 @@
1
1
  # Mem0 - The Memory layer for your AI apps
2
2
 
3
+
3
4
  Mem0 is a self-improving memory layer for LLM applications, enabling personalized AI experiences that save costs and delight users.
4
5
 
5
6
  Get started with Mem0 Platform in minutes using the Node.js client.
6
7
 
7
8
  ## 1. Installation
8
9
 
9
- Install the Mem0 Node.js package:
10
+ Install the Mem0 package:
10
11
 
11
12
  ```bash
12
- npm install mem0ai
13
+ npm i mem0ai
13
14
  ```
14
15
 
15
16
  ## 2. API Key Setup
@@ -20,15 +21,18 @@ npm install mem0ai
20
21
  ## 3. Instantiate Client
21
22
 
22
23
  ```javascript
23
- const MemoryClient = require('mem0ai');
24
- const client = new MemoryClient('your-api-key');
24
+ import MemoryClient from 'mem0ai';
25
+
26
+ const apiKey = 'your-api-key-here';
27
+ const client = new MemoryClient(apiKey);
25
28
  ```
26
29
 
27
30
  Alternatively, you can set the `MEM0_API_KEY` environment variable and instantiate the client without passing the API key:
28
31
 
29
32
  ```javascript
30
- const MemoryClient = require('mem0ai');
31
- const client = new MemoryClient();
33
+ import MemoryClient from 'mem0ai';
34
+
35
+ const client = new MemoryClient(process.env.MEM0_API_KEY);
32
36
  ```
33
37
 
34
38
  ## 4. Memory Operations
@@ -244,18 +248,19 @@ client.add("Delete all of my food preferences", { user_id: "alex" })
244
248
 
245
249
  ## 5. Error Handling
246
250
 
247
- The MemoryClient throws `APIError` for any API-related errors. You can catch and handle these errors as follows:
251
+ The MemoryClient throws errors for any API-related issues. You can catch and handle these errors as follows:
248
252
 
249
253
  ```javascript
250
- client.add(messages, { user_id: "alex" })
251
- .then(result => console.log(result))
252
- .catch(error => {
253
- if (error.name === 'APIError') {
254
- console.error('API Error:', error.message);
255
- } else {
256
- console.error('Unexpected error:', error);
257
- }
258
- });
254
+ try {
255
+ const result = await client.add(messages, { user_id: "alex" });
256
+ console.log(result);
257
+ } catch (error) {
258
+ if (error.name === 'APIError') {
259
+ console.error('API Error:', error.message);
260
+ } else {
261
+ console.error('Unexpected error:', error);
262
+ }
263
+ }
259
264
  ```
260
265
 
261
266
  ## 6. Using with async/await
@@ -265,16 +270,67 @@ All methods of the MemoryClient return promises, so you can use them with async/
265
270
  ```javascript
266
271
  async function addMemory() {
267
272
  try {
273
+ const messages = [
274
+ { role: "user", content: "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts." },
275
+ { role: "assistant", content: "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions." }
276
+ ];
268
277
  const result = await client.add(messages, { user_id: "alex" });
269
- console.log(result);
278
+ console.log('Memory added:', result);
279
+
280
+ const searchResult = await client.search("What are Alex's dietary restrictions?", { user_id: "alex" });
281
+ console.log('Search result:', searchResult);
270
282
  } catch (error) {
271
- console.error('Error adding memory:', error);
283
+ console.error('Error:', error);
272
284
  }
273
285
  }
274
286
 
275
287
  addMemory();
276
288
  ```
277
289
 
290
+ ## 7. Testing the Client
291
+
292
+ To test the MemoryClient in a Node.js environment, you can create a simple script:
293
+
294
+ ```javascript
295
+ // test-mem0.js
296
+ import MemoryClient from 'mem0ai';
297
+
298
+ const apiKey = 'your-api-key-here';
299
+ const client = new MemoryClient(apiKey);
300
+
301
+ async function testMemoryOperations() {
302
+ try {
303
+ // Add a memory
304
+ const addResult = await client.add([
305
+ { role: "user", content: "My favorite color is blue." }
306
+ ], { user_id: "test-user" });
307
+ console.log('Memory added:', addResult);
308
+
309
+ // Search for memories
310
+ const searchResult = await client.search("What's my favorite color?", { user_id: "test-user" });
311
+ console.log('Search result:', searchResult);
312
+
313
+ // Get all memories
314
+ const allMemories = await client.getAll({ user_id: "test-user" });
315
+ console.log('All memories:', allMemories);
316
+ } catch (error) {
317
+ console.error('Error:', error);
318
+ }
319
+ }
320
+
321
+ testMemoryOperations();
322
+ ```
323
+
324
+ Run this script using Node.js:
325
+
326
+ ```bash
327
+ node test-mem0.js
328
+ ```
329
+
330
+ This will perform basic operations (add, search, getAll) and log the results, allowing you to verify that the client is working correctly with your API key.
331
+
332
+ Remember to replace 'your-api-key-here' with your actual Mem0 API key when testing.
333
+
278
334
  ## Getting Help
279
335
 
280
336
  If you have any questions or need assistance, please reach out to us:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mem0ai",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "The Memory layer for your AI apps",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -19,11 +19,12 @@
19
19
  "author": "Deshraj Yadav",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "axios": "^0.21.1"
22
+ "posthog-js": "^1.167.0"
23
23
  },
24
24
  "files": [
25
25
  "src/",
26
26
  "package.json",
27
27
  "README.md"
28
- ]
28
+ ],
29
+ "module": "dist/index.mjs"
29
30
  }
package/src/index.d.ts CHANGED
@@ -1,30 +1,61 @@
1
1
  declare module 'mem0ai' {
2
- export interface MemoryOptions {
3
- user_id?: string;
4
- }
5
-
6
- export interface SearchOptions extends MemoryOptions {
7
- api_version?: 'v1' | 'v2';
8
- }
9
-
10
- export interface Memory {
11
- id: string;
12
- messages: Array<{ role: string; content: string }>;
13
- }
14
-
15
- export class MemoryClient {
16
- constructor(apiKey: string, host?: string);
17
-
18
- add(messages: string | Array<{ role: string; content: string }>, options?: MemoryOptions): Promise<Memory>;
19
- get(memoryId: string): Promise<Memory>;
20
- getAll(options?: MemoryOptions): Promise<{ results: Memory[] }>;
21
- search(query: string, options?: SearchOptions): Promise<{ results: Memory[] }>;
22
- delete(memoryId: string): Promise<any>;
23
- deleteAll(options?: MemoryOptions): Promise<any>;
24
- history(memoryId: string): Promise<any>;
25
- users(): Promise<any>;
26
- deleteUsers(): Promise<{ message: string }>;
27
- }
28
-
29
- export default MemoryClient;
30
- }
2
+ export interface MemoryOptions {
3
+ user_id?: string;
4
+ agent_id?: string;
5
+ app_id?: string;
6
+ metadata?: Record<string, any>;
7
+ filters?: Record<string, any>;
8
+ }
9
+
10
+ export interface SearchOptions extends MemoryOptions {
11
+ api_version?: 'v1' | 'v2';
12
+ limit?: number;
13
+ }
14
+
15
+ export interface Memory {
16
+ id: string;
17
+ messages: Array<{ role: string; content: string }>;
18
+ }
19
+
20
+ export class MemoryClient {
21
+ constructor(
22
+ apiKey: string,
23
+ host?: string,
24
+ organizationName?: string,
25
+ projectName?: string
26
+ );
27
+
28
+ add(
29
+ messages: string | Array<{ role: string; content: string }>,
30
+ options?: MemoryOptions
31
+ ): Promise<Memory>;
32
+
33
+ get(memoryId: string): Promise<Memory>;
34
+
35
+ getAll(options?: MemoryOptions & { api_version?: 'v1' | 'v2' }): Promise<{ results: Memory[] }>;
36
+
37
+ search(query: string, options?: SearchOptions): Promise<{ results: Memory[] }>;
38
+
39
+ delete(memoryId: string): Promise<any>;
40
+
41
+ deleteAll(options?: MemoryOptions): Promise<any>;
42
+
43
+ history(memoryId: string): Promise<any>;
44
+
45
+ users(): Promise<any>;
46
+
47
+ deleteUsers(): Promise<{ message: string }>;
48
+
49
+ private _validateApiKey(): Promise<void>;
50
+
51
+ private _preparePayload(
52
+ messages: string | Array<{ role: string; content: string }>,
53
+ options: MemoryOptions
54
+ ): object;
55
+
56
+ private _prepareParams(options: MemoryOptions): object;
57
+ }
58
+
59
+ export { MemoryClient };
60
+ export default MemoryClient;
61
+ }
package/src/index.js CHANGED
@@ -1,209 +1,220 @@
1
- const axios = require('axios');
2
-
3
- /**
4
- * @typedef {Object} MemoryOptions
5
- * @property {string} [user_id]
6
- *
7
- * @typedef {Object} SearchOptions
8
- * @property {string} [user_id]
9
- * @property {('v1'|'v2')} [api_version]
10
- *
11
- * @typedef {Object} Memory
12
- * @property {string} id
13
- * @property {Array<{role: string, content: string}>} messages
14
- */
1
+ import { telemetry, captureClientEvent } from './telemetry.js';
2
+ import crypto from 'crypto';
15
3
 
16
4
  class APIError extends Error {
17
- constructor(message) {
18
- super(message);
19
- this.name = 'APIError';
20
- }
21
- }
22
-
23
- /**
24
- * @template T
25
- * @param {(...args: any[]) => Promise<T>} fn
26
- * @returns {(...args: any[]) => Promise<T>}
27
- */
28
- function apiErrorHandler(fn) {
29
- return async function (...args) {
30
- try {
31
- return await fn.apply(this, args);
32
- } catch (error) {
33
- if (error.response) {
34
- throw new APIError(`API request failed: ${error.response.data}`);
35
- } else if (error.request) {
36
- throw new APIError(`Request failed: ${error.message}`);
37
- } else {
38
- throw error;
39
- }
40
- }
41
- };
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'APIError';
8
+ }
42
9
  }
43
10
 
44
11
  /**
45
12
  * MemoryClient for interacting with the mem0ai API
46
13
  */
47
14
  class MemoryClient {
48
- /**
49
- * @param {string} apiKey
50
- * @param {string} [host]
51
- */
52
- constructor(apiKey, host = 'https://api.mem0.ai') {
53
- this.apiKey = apiKey || process.env.MEM0_API_KEY;
54
- this.host = host;
55
-
56
- if (!this.apiKey) {
57
- throw new Error('API Key not provided. Please provide an API Key.');
58
- }
59
-
60
- this.client = axios.create({
61
- baseURL: this.host,
62
- headers: { Authorization: `Token ${this.apiKey}` },
63
- timeout: 60000,
64
- });
65
-
66
- this._validateApiKey();
67
-
68
- // Apply error handler to methods
69
- this.add = apiErrorHandler(this.add.bind(this));
70
- this.get = apiErrorHandler(this.get.bind(this));
71
- this.getAll = apiErrorHandler(this.getAll.bind(this));
72
- this.search = apiErrorHandler(this.search.bind(this));
73
- this.delete = apiErrorHandler(this.delete.bind(this));
74
- this.deleteAll = apiErrorHandler(this.deleteAll.bind(this));
75
- this.history = apiErrorHandler(this.history.bind(this));
76
- this.deleteUsers = apiErrorHandler(this.deleteUsers.bind(this));
77
- }
78
-
79
- async _validateApiKey() {
80
- try {
81
- await this.client.get('/v1/memories/', { params: { user_id: 'test' } });
82
- } catch (error) {
83
- throw new Error('Invalid API Key. Please get a valid API Key from https://app.mem0.ai');
84
- }
85
- }
86
-
87
- /**
88
- * @param {string|Array<{role: string, content: string}>} messages
89
- * @param {MemoryOptions} [options]
90
- * @returns {Promise<Memory>}
91
- */
92
- async add(messages, options = {}) {
93
- const payload = this._preparePayload(messages, options);
94
- const response = await this.client.post('/v1/memories/', payload);
95
- return response.data;
96
- }
97
-
98
- /**
99
- * @param {string} memoryId
100
- * @returns {Promise<Memory>}
101
- */
102
- async get(memoryId) {
103
- const response = await this.client.get(`/v1/memories/${memoryId}/`);
104
- return response.data;
105
- }
106
-
107
- /**
108
- * @param {MemoryOptions} [options]
109
- * @returns {Promise<{results: Memory[]}>}
110
- */
111
- async getAll(options = {}) {
112
- const { api_version, ...otherOptions } = options;
113
- const endpoint = api_version === 'v2' ? '/v2/memories/' : '/v1/memories/';
114
-
115
- if (api_version === 'v2') {
116
- const response = await this.client.post(endpoint, otherOptions);
117
- return response.data;
118
- } else {
119
- const params = this._prepareParams(otherOptions);
120
- const response = await this.client.get(endpoint, { params });
121
- return response.data;
122
- }
123
- }
124
-
125
- /**
126
- * @param {string} query
127
- * @param {SearchOptions} [options]
128
- * @returns {Promise<{results: Memory[]}>}
129
- */
130
- async search(query, options = {}) {
131
- const { api_version, ...otherOptions } = options;
132
- const payload = { query, ...otherOptions };
133
- const endpoint = api_version === 'v2' ? '/v2/memories/search/' : '/v1/memories/search/';
134
- const response = await this.client.post(endpoint, payload);
135
- return response.data;
136
- }
137
-
138
- /**
139
- * @param {string} memoryId
140
- * @returns {Promise<any>}
141
- */
142
- async delete(memoryId) {
143
- const response = await this.client.delete(`/v1/memories/${memoryId}/`);
144
- return response.data;
145
- }
146
-
147
- /**
148
- * @param {MemoryOptions} [options]
149
- * @returns {Promise<any>}
150
- */
151
- async deleteAll(options = {}) {
152
- const params = this._prepareParams(options);
153
- const response = await this.client.delete('/v1/memories/', { params });
154
- return response.data;
155
- }
156
-
157
- /**
158
- * @param {string} memoryId
159
- * @returns {Promise<any>}
160
- */
161
- async history(memoryId) {
162
- const response = await this.client.get(`/v1/memories/${memoryId}/history/`);
163
- return response.data;
164
- }
165
-
166
- /**
167
- * @returns {Promise<any>}
168
- */
169
- async users() {
170
- const response = await this.client.get('/v1/entities/');
171
- return response.data;
172
- }
173
-
174
- /**
175
- * @returns {Promise<{message: string}>}
176
- */
177
- async deleteUsers() {
178
- const entities = await this.users();
179
- for (const entity of entities.results) {
180
- await this.client.delete(`/entities/${entity.type}/${entity.id}/`);
181
- }
182
- return { message: "All users, agents, and sessions deleted." };
183
- }
184
-
185
- /**
186
- * @param {string|Array<{role: string, content: string}>} messages
187
- * @param {MemoryOptions} options
188
- * @returns {Object}
189
- */
190
- _preparePayload(messages, options) {
191
- const payload = {};
192
- if (typeof messages === 'string') {
193
- payload.messages = [{ role: 'user', content: messages }];
194
- } else if (Array.isArray(messages)) {
195
- payload.messages = messages;
196
- }
197
- return { ...payload, ...options };
198
- }
199
-
200
- /**
201
- * @param {MemoryOptions} options
202
- * @returns {Object}
203
- */
204
- _prepareParams(options) {
205
- return Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null));
206
- }
15
+ /**
16
+ * @param {string} apiKey
17
+ * @param {string} [host]
18
+ * @param {string} [organizationName]
19
+ * @param {string} [projectName]
20
+ */
21
+ constructor(apiKey, host = 'https://api.mem0.ai', organizationName = null, projectName = null) {
22
+ this.apiKey = apiKey;
23
+ this.host = host;
24
+ this.organizationName = organizationName;
25
+ this.projectName = projectName;
26
+ this.telemetryId = crypto.createHash('md5').update(this.apiKey).digest('hex');
27
+
28
+ this.headers = {
29
+ 'Authorization': `Token ${this.apiKey}`,
30
+ 'Content-Type': 'application/json'
31
+ };
32
+
33
+ this._validateApiKey();
34
+
35
+ captureClientEvent('init', this, {
36
+ host: this.host,
37
+ organization_name: this.organizationName,
38
+ project_name: this.projectName,
39
+ });
40
+
41
+ this._wrapMethods();
42
+ }
43
+
44
+ _validateApiKey() {
45
+ if (!this.apiKey) {
46
+ throw new Error('Mem0 API key is required');
47
+ }
48
+ if (typeof this.apiKey !== 'string') {
49
+ throw new Error('Mem0 API key must be a string');
50
+ }
51
+ if (this.apiKey.trim() === '') {
52
+ throw new Error('Mem0 API key cannot be empty');
53
+ }
54
+ }
55
+
56
+ async _fetchWithErrorHandling(url, options) {
57
+ const response = await fetch(url, options);
58
+ if (!response.ok) {
59
+ const errorData = await response.text();
60
+ throw new APIError(`API request failed: ${errorData}`);
61
+ }
62
+ return response.json();
63
+ }
64
+
65
+ async add(messages, options = {}) {
66
+ options.organization_name = this.organizationName;
67
+ options.project_name = this.projectName;
68
+ const payload = this._preparePayload(messages, options);
69
+ const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/`, {
70
+ method: 'POST',
71
+ headers: this.headers,
72
+ body: JSON.stringify(payload)
73
+ });
74
+ captureClientEvent('add', this, { messages_count: messages.length });
75
+ return response;
76
+ }
77
+
78
+ async get(memoryId) {
79
+ return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {
80
+ headers: this.headers
81
+ });
82
+ }
83
+
84
+ async getAll(options = {}) {
85
+ const { api_version, ...otherOptions } = options;
86
+
87
+ otherOptions.organization_name = this.organizationName;
88
+ otherOptions.project_name = this.projectName;
89
+
90
+ if (api_version === 'v2') {
91
+ return this._fetchWithErrorHandling(`${this.host}/v2/memories/`, {
92
+ method: 'POST',
93
+ headers: this.headers,
94
+ body: JSON.stringify(otherOptions)
95
+ });
96
+ } else {
97
+ const params = new URLSearchParams(this._prepareParams(otherOptions));
98
+ return this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {
99
+ headers: this.headers
100
+ });
101
+ }
102
+ }
103
+
104
+ async search(query, options = {}) {
105
+ const { api_version, ...otherOptions } = options;
106
+ const payload = { query, ...otherOptions };
107
+ payload.organization_name = this.organizationName;
108
+ payload.project_name = this.projectName;
109
+ const endpoint = api_version === 'v2' ? '/v2/memories/search/' : '/v1/memories/search/';
110
+ const response = await this._fetchWithErrorHandling(`${this.host}${endpoint}`, {
111
+ method: 'POST',
112
+ headers: this.headers,
113
+ body: JSON.stringify(payload)
114
+ });
115
+ captureClientEvent('search', this, { query_length: query.length });
116
+ return response;
117
+ }
118
+
119
+ async delete(memoryId) {
120
+ return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {
121
+ method: 'DELETE',
122
+ headers: this.headers
123
+ });
124
+ }
125
+
126
+ async deleteAll(options = {}) {
127
+ options.organization_name = this.organizationName;
128
+ options.project_name = this.projectName;
129
+ const params = new URLSearchParams(this._prepareParams(options));
130
+ const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {
131
+ method: 'DELETE',
132
+ headers: this.headers
133
+ });
134
+ return response;
135
+ }
136
+
137
+ async history(memoryId) {
138
+ return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/history/`, {
139
+ headers: this.headers
140
+ });
141
+ }
142
+
143
+ async users() {
144
+ const params = new URLSearchParams({
145
+ organization_name: this.organizationName,
146
+ project_name: this.projectName
147
+ });
148
+ return this._fetchWithErrorHandling(`${this.host}/v1/entities/?${params}`, {
149
+ headers: this.headers
150
+ });
151
+ }
152
+
153
+ async deleteUsers() {
154
+ const entities = await this.users();
155
+ for (const entity of entities.results) {
156
+ const params = {
157
+ organization_name: this.organizationName,
158
+ project_name: this.projectName
159
+ };
160
+ await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params });
161
+ }
162
+ return { message: "All users, agents, and sessions deleted." };
163
+ }
164
+
165
+ /**
166
+ * @param {string|Array<{role: string, content: string}>} messages
167
+ * @param {MemoryOptions} options
168
+ * @returns {Object}
169
+ */
170
+ _preparePayload(messages, options) {
171
+ const payload = {};
172
+ if (typeof messages === 'string') {
173
+ payload.messages = [{ role: 'user', content: messages }];
174
+ } else if (Array.isArray(messages)) {
175
+ payload.messages = messages;
176
+ }
177
+ return { ...payload, ...options };
178
+ }
179
+
180
+ /**
181
+ * @param {MemoryOptions} options
182
+ * @returns {Object}
183
+ */
184
+ _prepareParams(options) {
185
+ return Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null));
186
+ }
187
+
188
+ _wrapMethods() {
189
+ // Apply error handler and telemetry to methods
190
+ this.add = this._wrapMethod('add', this.add.bind(this));
191
+ this.get = this._wrapMethod('get', this.get.bind(this));
192
+ this.getAll = this._wrapMethod('get_all', this.getAll.bind(this));
193
+ this.search = this._wrapMethod('search', this.search.bind(this));
194
+ this.delete = this._wrapMethod('delete', this.delete.bind(this));
195
+ this.deleteAll = this._wrapMethod('delete_all', this.deleteAll.bind(this));
196
+ this.history = this._wrapMethod('history', this.history.bind(this));
197
+ this.deleteUsers = this._wrapMethod('delete_users', this.deleteUsers.bind(this));
198
+ }
199
+
200
+ _wrapMethod(methodName, method) {
201
+ return async (...args) => {
202
+ console.log('Calling method:', methodName);
203
+ try {
204
+ const result = await method(...args);
205
+ captureClientEvent(methodName, this, { success: true });
206
+ return result;
207
+ } catch (error) {
208
+ captureClientEvent(methodName, this, { success: false, error: error.message });
209
+ throw error;
210
+ }
211
+ };
212
+ }
207
213
  }
208
214
 
209
- module.exports = MemoryClient;
215
+ export default MemoryClient;
216
+
217
+ // Add a way to manually shutdown telemetry if needed
218
+ MemoryClient.shutdownTelemetry = async () => {
219
+ await telemetry.shutdown();
220
+ };
@@ -0,0 +1,36 @@
1
+ import posthog from 'posthog-js';
2
+
3
+ posthog.init('phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX', { api_host: 'https://us.i.posthog.com' });
4
+
5
+ class AnonymousTelemetry {
6
+
7
+ async captureEvent(distinctId, eventName, properties = {}) {
8
+ if (eventName === 'client.init') {
9
+ posthog.identify(distinctId);
10
+ }
11
+ const eventProperties = {
12
+ client_source: 'js',
13
+ ...properties
14
+ };
15
+
16
+ posthog.capture(eventName, {
17
+ properties: eventProperties
18
+ });
19
+ }
20
+
21
+ async shutdown() {
22
+ await posthog.shutdown();
23
+ }
24
+ }
25
+
26
+ const telemetry = new AnonymousTelemetry();
27
+
28
+ async function captureClientEvent(eventName, instance, additionalData = {}) {
29
+ const eventData = {
30
+ function: `${instance.constructor.name}`,
31
+ ...additionalData
32
+ };
33
+ await telemetry.captureEvent(instance.telemetryId, `client.${eventName}`, eventData);
34
+ }
35
+
36
+ export { telemetry, captureClientEvent };