Skip to content

Commit 44aa669

Browse files
committed
chore: version tracking added to config
1 parent 51e3cb5 commit 44aa669

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/config/contentful.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ClientOptions } from 'contentful-management';
22
import { env } from '../config/env.js';
3+
import { getVersion } from '../utils/getVersion.js';
34

45
/**
56
* Creates a default Contentful client configuration without actually initializing it.
@@ -14,7 +15,7 @@ export function getDefaultClientConfig(): ClientOptions {
1415
host: env.data.CONTENTFUL_HOST,
1516
space: env.data.SPACE_ID,
1617
headers: {
17-
'X-Contentful-User-Agent-Tool': 'contentful-mcp/0.0.1', //Include user agent header for telemetry tracking
18+
'X-Contentful-User-Agent-Tool': `contentful-mcp/${getVersion()}`, //Include user agent header for telemetry tracking
1819
},
1920
};
2021

src/utils/getVersion.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { readFileSync } from 'node:fs';
2+
import { join } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
import { dirname } from 'node:path';
5+
6+
export const getVersion = () => {
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = dirname(__filename);
9+
const packageJsonPath = join(__dirname, '../../package.json');
10+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
11+
return packageJson.version;
12+
};

0 commit comments

Comments
 (0)