Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

vite.config.js: inject PostHog analytics on all non-embed pages

nirholascd602a7abd85
diff --git a/vite.config.js b/vite.config.js
index 95d028b2c..49ed5403d 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -629,6 +629,22 @@ const appConfig = {
});
},
},
+ {
+ name: 'posthog-analytics',
+ transformIndexHtml: {
+ order: 'pre',
+ handler(_html, ctx) {
+ const EMBED_FILES = new Set([
+ 'widget.html', 'embed.html', 'avatar-embed.html',
+ 'agent-embed.html', 'a-embed.html',
+ ]);
+ const filename = (ctx.filename || ctx.path || '').replace(/\\/g, '/').split('/').pop();
+ if (EMBED_FILES.has(filename)) return [];
+ const SNIPPET = `!function(t,e){var o,n,p,r;e.__SV||(window.posthog&&window.posthog.__loaded)||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias set_config reset opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing get_distinct_id get_session_id get_session_replay_url register register_once unregister on onFeatureFlags reloadFeatureFlags getFeatureFlag getFeatureFlagPayload isFeatureEnabled addExceptionStep captureException".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);posthog.init('phc_kvi8nrXqrNkLNy2NhaiwkbGyj77XpSJo54P5k2ZHYo9n',{api_host:'https://us.i.posthog.com',defaults:'2026-01-30',person_profiles:'identified_only'})`;
+ return [{ tag: 'script', children: SNIPPET, injectTo: 'head' }];
+ },
+ },
+ },
{
// Stamp every Vite-processed HTML page so footer.js can detect that
// Three.js is already bundled and skip loading the model-viewer CDN script.