Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

fix(ts-sdk): inject SDK version into telemetry at build time (#4897)

Saket Aryan7b6790bafb54
diff --git a/mem0-ts/jest.config.js b/mem0-ts/jest.config.js
index ce23df670..8dde54857 100644
--- a/mem0-ts/jest.config.js
+++ b/mem0-ts/jest.config.js
@@ -18,7 +18,7 @@ module.exports = {
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
},
- setupFiles: ["dotenv/config"],
+ setupFiles: ["dotenv/config", "<rootDir>/jest.setup.ts"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
globals: {
diff --git a/mem0-ts/jest.setup.ts b/mem0-ts/jest.setup.ts
new file mode 100644
index 000000000..20ab6570b
--- /dev/null
+++ b/mem0-ts/jest.setup.ts
@@ -0,0 +1,3 @@
+import pkg from "./package.json";
+
+(globalThis as any).__MEM0_SDK_VERSION__ = pkg.version;
diff --git a/mem0-ts/package.json b/mem0-ts/package.json
index fdc06c930..f0cd2994a 100644
--- a/mem0-ts/package.json
+++ b/mem0-ts/package.json
@@ -1,6 +1,6 @@
{
"name": "mem0ai",
- "version": "3.0.0",
+ "version": "3.0.1",
"description": "The Memory Layer For Your AI Apps",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
diff --git a/mem0-ts/src/client/telemetry.ts b/mem0-ts/src/client/telemetry.ts
index 27992332b..0062c2326 100644
--- a/mem0-ts/src/client/telemetry.ts
+++ b/mem0-ts/src/client/telemetry.ts
@@ -1,7 +1,7 @@
// @ts-nocheck
import type { TelemetryClient, TelemetryOptions } from "./telemetry.types";
-let version = "2.1.36";
+let version = __MEM0_SDK_VERSION__;
// Safely check for process.env in different environments
let MEM0_TELEMETRY = true;
diff --git a/mem0-ts/src/global.d.ts b/mem0-ts/src/global.d.ts
new file mode 100644
index 000000000..2ac217fb8
--- /dev/null
+++ b/mem0-ts/src/global.d.ts
@@ -0,0 +1 @@
+declare const __MEM0_SDK_VERSION__: string;
diff --git a/mem0-ts/src/oss/src/utils/telemetry.ts b/mem0-ts/src/oss/src/utils/telemetry.ts
index b94353760..0fff8be95 100644
--- a/mem0-ts/src/oss/src/utils/telemetry.ts
+++ b/mem0-ts/src/oss/src/utils/telemetry.ts
@@ -4,7 +4,7 @@ import type {
TelemetryEventData,
} from "./telemetry.types";
-let version = "2.1.34";
+let version = __MEM0_SDK_VERSION__;
// Safely check for process.env in different environments
let MEM0_TELEMETRY = true;
diff --git a/mem0-ts/tsup.config.ts b/mem0-ts/tsup.config.ts
index 3ea5c8094..76ea4e777 100644
--- a/mem0-ts/tsup.config.ts
+++ b/mem0-ts/tsup.config.ts
@@ -1,4 +1,5 @@
import { defineConfig } from "tsup";
+import pkg from "./package.json";
const external = [
"openai",
@@ -23,6 +24,10 @@ const external = [
"natural",
];
+const define = {
+ __MEM0_SDK_VERSION__: JSON.stringify(pkg.version),
+};
+
export default defineConfig([
{
entry: ["src/client/index.ts"],
@@ -30,6 +35,7 @@ export default defineConfig([
dts: true,
sourcemap: true,
external,
+ define,
},
{
entry: ["src/oss/src/index.ts"],
@@ -38,5 +44,6 @@ export default defineConfig([
dts: true,
sourcemap: true,
external,
+ define,
},
]);