also looking at this
fix(bun-plugin): forward analytics config on the serve path (so plugin/native analytics inject)
#1760
1 file
+15
-0
| @@ -384,6 +384,13 @@ export async function serve(options: ServeOptions): Promise<void> { | ||
| 384 | 384 | stxConfig._pluginComponentDirs = pluginLoaded._pluginComponentDirs |
| 385 | 385 | if (pluginLoaded?._pluginPageDirs) |
| 386 | 386 | stxConfig._pluginPageDirs = pluginLoaded._pluginPageDirs |
| 387 | // A plugin's setup() can mutate the loaded config — e.g. an analytics | |
| 388 | // plugin sets `analytics.{enabled,driver,custom}` so injectAnalytics | |
| 389 | // runs. bunfig's loadConfig above returns the RAW object (pre-setup), so | |
| 390 | // carry the plugin-mutated analytics across, else the tracker is silently | |
| 391 | // dropped on this serve path. | |
| 392 | if (pluginLoaded?.analytics) | |
| 393 | stxConfig.analytics = pluginLoaded.analytics | |
| 387 | 394 | } |
| 388 | 395 | // Preload the default icon collection so <Icon name="..." /> resolves on |
| 389 | 396 | // the FIRST page render. Without this preload, the IconBuiltin returns |
| @@ -1180,6 +1187,10 @@ export async function serve(options: ServeOptions): Promise<void> { | ||
| 1180 | 1187 | ...('defaultDescription' in stxConfig && { defaultDescription: stxConfig.defaultDescription }), |
| 1181 | 1188 | ...('defaultImage' in stxConfig && { defaultImage: stxConfig.defaultImage }), |
| 1182 | 1189 | ...('seo' in stxConfig && { seo: stxConfig.seo }), |
| 1190 | // Forward analytics so injectAnalytics runs on this serve path too — | |
| 1191 | // both native providers (fathom/GA/…) and plugin-injected trackers (the | |
| 1192 | // plugin-mutated analytics is merged onto stxConfig above). | |
| 1193 | ...('analytics' in stxConfig && { analytics: stxConfig.analytics }), | |
| 1183 | 1194 | // Forward plugin-registered component dirs so renderComponentWithSlot |
| 1184 | 1195 | // can resolve tags exposed by stx plugins (e.g. `<Notification>` from |
| 1185 | 1196 | // `@stacksjs/components` via a stx plugin shim). Populated by |
| @@ -1463,6 +1474,10 @@ export async function serve(options: ServeOptions): Promise<void> { | ||
| 1463 | 1474 | ...('defaultDescription' in stxConfig && { defaultDescription: stxConfig.defaultDescription }), |
| 1464 | 1475 | ...('defaultImage' in stxConfig && { defaultImage: stxConfig.defaultImage }), |
| 1465 | 1476 | ...('seo' in stxConfig && { seo: stxConfig.seo }), |
| 1477 | // Forward analytics so injectAnalytics runs on this serve path too — | |
| 1478 | // both native providers (fathom/GA/…) and plugin-injected trackers (the | |
| 1479 | // plugin-mutated analytics is merged onto stxConfig above). | |
| 1480 | ...('analytics' in stxConfig && { analytics: stxConfig.analytics }), | |
| 1466 | 1481 | // Mirror the static-route config: forward plugin-registered component |
| 1467 | 1482 | // dirs so dynamic routes also resolve `<Notification>` etc. |
| 1468 | 1483 | ...('_pluginComponentDirs' in stxConfig && { _pluginComponentDirs: stxConfig._pluginComponentDirs }), |