create-sonicjs 2.3.9 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sonicjs",
3
- "version": "2.3.9",
3
+ "version": "2.3.12",
4
4
  "description": "Create a new SonicJS application with zero configuration",
5
5
  "type": "module",
6
6
  "bin": {
@@ -43,8 +43,7 @@
43
43
  "ora": "^8.1.3",
44
44
  "execa": "^9.6.0",
45
45
  "fs-extra": "^11.2.0",
46
- "validate-npm-package-name": "^7.0.0",
47
- "posthog-node": "^4.0.0"
46
+ "validate-npm-package-name": "^7.0.0"
48
47
  },
49
48
  "engines": {
50
49
  "node": ">=18.0.0"
package/src/cli.js CHANGED
@@ -415,7 +415,7 @@ async function copyTemplate(templateName, targetDir, options) {
415
415
 
416
416
  // Add @sonicjs-cms/core dependency
417
417
  packageJson.dependencies = {
418
- '@sonicjs-cms/core': '^2.3.9',
418
+ '@sonicjs-cms/core': '^2.3.12',
419
419
  ...packageJson.dependencies
420
420
  }
421
421
 
package/src/telemetry.js CHANGED
@@ -13,8 +13,7 @@ import fs from 'fs-extra'
13
13
  import path from 'path'
14
14
 
15
15
  const TELEMETRY_ENABLED = process.env.SONICJS_TELEMETRY !== 'false' && process.env.DO_NOT_TRACK !== '1'
16
- const TELEMETRY_API_KEY = process.env.POSTHOG_API_KEY || 'phc_VuhFUIJLXzwyGjlgQ67dbNeSh5x4cp9F8i15hZFIDhs'
17
- const TELEMETRY_HOST = process.env.POSTHOG_HOST || 'https://us.i.posthog.com'
16
+ const TELEMETRY_ENDPOINT = process.env.SONICJS_TELEMETRY_ENDPOINT || 'https://stats.sonicjs.com'
18
17
  const DEBUG = process.env.DEBUG === 'true'
19
18
 
20
19
  /**
@@ -51,7 +50,6 @@ function getInstallationId() {
51
50
  /**
52
51
  * Initialize telemetry
53
52
  */
54
- let telemetryClient = null
55
53
  let installationId = null
56
54
 
57
55
  async function initTelemetry() {
@@ -65,23 +63,11 @@ async function initTelemetry() {
65
63
  try {
66
64
  installationId = getInstallationId()
67
65
 
68
- // Initialize PostHog
69
- if (TELEMETRY_API_KEY) {
70
- const { PostHog } = await import('posthog-node')
71
- telemetryClient = new PostHog(TELEMETRY_API_KEY, {
72
- host: TELEMETRY_HOST,
73
- flushAt: 1, // Flush immediately for CLI
74
- flushInterval: 1000
75
- })
76
-
77
- if (DEBUG) {
78
- console.log('[Telemetry] Initialized with ID:', installationId)
79
- }
80
- } else if (DEBUG) {
81
- console.log('[Telemetry] No API key, tracking will be logged only')
66
+ if (DEBUG) {
67
+ console.log('[Telemetry] Initialized with ID:', installationId)
82
68
  }
83
69
 
84
- return { client: telemetryClient, installationId }
70
+ return { installationId }
85
71
  } catch (error) {
86
72
  if (DEBUG) {
87
73
  console.error('[Telemetry] Initialization failed:', error)
@@ -91,7 +77,7 @@ async function initTelemetry() {
91
77
  }
92
78
 
93
79
  /**
94
- * Track an event
80
+ * Track an event using custom SonicJS stats endpoint
95
81
  */
96
82
  async function track(event, properties = {}) {
97
83
  if (!TELEMETRY_ENABLED) return
@@ -101,25 +87,33 @@ async function track(event, properties = {}) {
101
87
  await initTelemetry()
102
88
  }
103
89
 
104
- const enrichedProperties = {
105
- ...properties,
106
- timestamp: new Date().toISOString(),
107
- os: os.platform(),
108
- nodeVersion: process.version.split('.').slice(0, 2).join('.'), // e.g., "v18.0"
90
+ if (!installationId) return
91
+
92
+ const timestamp = new Date().toISOString()
93
+
94
+ // Use standard SonicJS collection API
95
+ const payload = {
96
+ data: {
97
+ installation_id: installationId,
98
+ event_type: event,
99
+ properties: {
100
+ ...properties,
101
+ os: os.platform(),
102
+ nodeVersion: process.version.split('.').slice(0, 2).join('.'), // e.g., "v18.0"
103
+ },
104
+ timestamp
105
+ }
109
106
  }
110
107
 
111
- if (telemetryClient && installationId) {
112
- telemetryClient.capture({
113
- distinctId: installationId,
114
- event,
115
- properties: enrichedProperties
116
- })
108
+ // Fire and forget - don't block on response
109
+ fetch(`${TELEMETRY_ENDPOINT}/v1/events`, {
110
+ method: 'POST',
111
+ headers: { 'Content-Type': 'application/json' },
112
+ body: JSON.stringify(payload)
113
+ }).catch(() => {}) // Silent fail
117
114
 
118
- if (DEBUG) {
119
- console.log('[Telemetry] Tracked:', event, enrichedProperties)
120
- }
121
- } else if (DEBUG) {
122
- console.log('[Telemetry] Event (no client):', event, enrichedProperties)
115
+ if (DEBUG) {
116
+ console.log('[Telemetry] Tracked:', event, payload)
123
117
  }
124
118
  } catch (error) {
125
119
  // Silent fail - telemetry should never break the CLI
@@ -130,18 +124,10 @@ async function track(event, properties = {}) {
130
124
  }
131
125
 
132
126
  /**
133
- * Shutdown telemetry (flush pending events)
127
+ * Shutdown telemetry (no-op for fetch-based telemetry)
134
128
  */
135
129
  async function shutdown() {
136
- if (telemetryClient) {
137
- try {
138
- await telemetryClient.shutdown()
139
- } catch (error) {
140
- if (DEBUG) {
141
- console.error('[Telemetry] Shutdown failed:', error)
142
- }
143
- }
144
- }
130
+ // No-op - fetch requests are fire and forget
145
131
  }
146
132
 
147
133
  /**
@@ -19,16 +19,16 @@
19
19
  },
20
20
  "dependencies": {},
21
21
  "devDependencies": {
22
- "@cloudflare/workers-types": "^4.20251014.0",
23
- "@types/node": "^24.9.2",
24
- "drizzle-kit": "^0.30.3",
22
+ "@cloudflare/workers-types": "^4.20251202.0",
23
+ "@types/node": "^24.10.1",
24
+ "drizzle-kit": "^0.31.7",
25
25
  "drizzle-orm": "^0.44.7",
26
- "hono": "^4.10.4",
27
- "tsx": "^4.20.3",
26
+ "hono": "^4.10.7",
27
+ "tsx": "^4.21.0",
28
28
  "typescript": "^5.9.3",
29
- "vitest": "^4.0.5",
30
- "wrangler": "^3.110.4",
31
- "zod": "^4.1.12"
29
+ "vitest": "^4.0.15",
30
+ "wrangler": "^4.52.1",
31
+ "zod": "^4.1.13"
32
32
  },
33
33
  "engines": {
34
34
  "node": ">=18.0.0"
@@ -4,13 +4,23 @@
4
4
  * Entry point for your SonicJS headless CMS application
5
5
  */
6
6
 
7
- import { createSonicJSApp } from '@sonicjs-cms/core'
7
+ import { createSonicJSApp, registerCollections } from '@sonicjs-cms/core'
8
8
  import type { SonicJSConfig } from '@sonicjs-cms/core'
9
9
 
10
+ // Import your collection configurations
11
+ // Add new collections here after creating them in src/collections/
12
+ import blogPostsCollection from './collections/blog-posts.collection'
13
+
14
+ // Register collections BEFORE creating the app
15
+ // This ensures they are synced to the database on startup
16
+ registerCollections([
17
+ blogPostsCollection,
18
+ // Add more collections here as you create them
19
+ ])
20
+
10
21
  // Application configuration
11
22
  const config: SonicJSConfig = {
12
23
  collections: {
13
- directory: './src/collections',
14
24
  autoSync: true
15
25
  },
16
26
  plugins: {