Skip to content

Incremental engine for long horizon agents 🌟 Star if you like it!

838 B
Raw Blame
---
---
<script>
  import { POSTHOG_KEY, POSTHOG_HOST, MIXPANEL_TOKEN } from '../consts';

  // Built previews have PROD=true too; only the canonical site sends events.
  const PROD = import.meta.env.PROD && location.hostname === 'cocoindex.io';
  const start = () => {
    if (!PROD) return;
    if (POSTHOG_KEY) {
      import('posthog-js').then(({ default: posthog }) => {
        posthog.init(POSTHOG_KEY, { api_host: POSTHOG_HOST });
      });
    }
    if (MIXPANEL_TOKEN) {
      import('mixpanel-browser').then(({ default: mixpanel }) => {
        mixpanel.init(MIXPANEL_TOKEN, { track_pageview: true });
      });
    }
  };
  const w = window as Window & { requestIdleCallback?: (cb: () => void) => number };
  if (w.requestIdleCallback) {
    w.requestIdleCallback(start);
  } else {
    setTimeout(start, 1000);
  }
</script>