@eventcatalog/core 2.7.10 → 2.7.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.7.11
4
+
5
+ ### Patch Changes
6
+
7
+ - b106e34: chore(core): added logs for builds
8
+
3
9
  ## 2.7.10
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eventcatalog/core",
3
3
  "type": "module",
4
- "version": "2.7.10",
4
+ "version": "2.7.11",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -16,7 +16,7 @@
16
16
  "test": "vitest --config vitest.config.ts",
17
17
  "test:ci": "node scripts/ci/test.js",
18
18
  "start": "astro dev",
19
- "build": "npm run scripts:hydrate-content && astro check --minimumSeverity error && astro build",
19
+ "build": "npm run scripts:hydrate-content && node scripts/analytics/log-build.js && astro check --minimumSeverity error && astro build",
20
20
  "build:cd": "node scripts/build-ci.js",
21
21
  "preview": "astro preview",
22
22
  "astro": "astro",
@@ -49,6 +49,7 @@
49
49
  "astro-expressive-code": "^0.36.1",
50
50
  "astro-pagefind": "^1.6.0",
51
51
  "astro-seo": "^0.8.4",
52
+ "axios": "^1.7.7",
52
53
  "dagre": "^0.8.5",
53
54
  "diff": "^7.0.0",
54
55
  "diff2html": "^3.4.48",
@@ -0,0 +1,45 @@
1
+ import axios from 'axios';
2
+ import os from 'os';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+
6
+ async function getVersion() {
7
+ try {
8
+ const pkg = await fs.readFileSync(path.join(process.env.CATALOG_DIR, 'package.json'));
9
+ const parsed = JSON.parse(pkg);
10
+ return parsed.version;
11
+ } catch (error) {
12
+ console.log(error);
13
+ return 'unknown';
14
+ }
15
+ }
16
+
17
+ async function raiseEvent(eventData) {
18
+ const version = await getVersion();
19
+
20
+ const url = 'https://queue.simpleanalyticscdn.com/events';
21
+ const userAgent = `@eventcatalog/eventcatalog@${version} (${os.platform()}; ${os.arch()}; Node/${process.version})`;
22
+ const headers = {
23
+ 'Content-Type': 'application/json',
24
+ };
25
+
26
+ const payload = {
27
+ type: 'event',
28
+ hostname: 'eventcatalog.dev',
29
+ event: '@eventcatalog/eventcatalog',
30
+ metadata: {
31
+ ...eventData,
32
+ t: `t;${new Date().toISOString()}`,
33
+ ua: userAgent,
34
+ },
35
+ ua: userAgent,
36
+ };
37
+
38
+ try {
39
+ await axios.post(url, payload, { headers });
40
+ } catch (error) {
41
+ // swallow the error
42
+ }
43
+ }
44
+
45
+ export { raiseEvent };
@@ -0,0 +1,22 @@
1
+ import { getEventCatalogConfigFile, verifyRequiredFieldsAreInCatalogConfigFile } from '../eventcatalog-config-file-utils.js';
2
+ import { raiseEvent } from './analytics.js';
3
+
4
+ const main = async () => {
5
+ if (process.env.NODE_ENV === 'CI') return;
6
+ try {
7
+ await verifyRequiredFieldsAreInCatalogConfigFile(process.env.PROJECT_DIR);
8
+ const configFile = await getEventCatalogConfigFile(process.env.PROJECT_DIR);
9
+ const { cId, organizationName, generators = [] } = configFile;
10
+ const generatorNames = generators.length > 0 ? generators.map((generator) => generator[0]) : ['none'];
11
+ await raiseEvent({
12
+ command: 'build',
13
+ org: organizationName,
14
+ cId,
15
+ generators: generatorNames.toString(),
16
+ });
17
+ } catch (error) {
18
+ // Just swallow the error
19
+ }
20
+ };
21
+
22
+ main();