Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions openhands/posthog-init.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@
!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="init zr Wr fi Br Gr ci Nr Hr capture Ui calculateEventProperties Kr register register_once register_for_session unregister unregister_for_session Zr getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSurveysLoaded onSessionId getSurveys getActiveMatchingSurveys renderSurvey displaySurvey cancelPendingSurvey canRenderSurvey canRenderSurveyAsync identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty Xr Jr createPersonProfile Qr jr ts opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing get_explicit_consent_status is_capturing clear_opt_in_out_capturing Vr debug O Yr getPageViewId captureTraceFeedback captureTraceMetric Or".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_BgzfxKdgsYMLFTmJqt424ZoyVHvKFfrwttLimzdYTKFK', {
api_host: 'https://z.openhands.dev',
ui_host: 'https://us.posthog.com',
defaults: '2025-11-30',
person_profiles: 'always',
});
// PostHog initialization.
//
// Mintlify auto-includes every .js file in the content directory on every page,
// so this script runs on both the production custom domain and preview
// deployments with no per-environment env-var layer available. To keep preview
// traffic out of the production PostHog project, we select the project key at
// runtime based on the hostname:
//
// - docs.openhands.dev -> PROD_KEY (production custom domain)
// - *.mintlify.site / .app -> STAGING_KEY (PR preview deployments)
// - localhost / 127.0.0.1 -> STAGING_KEY (local dev)
//
// The api_host / ui_host / defaults stay the same for both environments.

var PROD_KEY = 'phc_BgzfxKdgsYMLFTmJqt424ZoyVHvKFfrwttLimzdYTKFK';
var STAGING_KEY = 'phc_kBtz5nKmxVRRQ7HtPwr2QX9eMC5j65zE86QKocVNwb4U';

var POSTHOG_CONFIG = {
api_host: 'https://z.openhands.dev',
ui_host: 'https://us.posthog.com',
defaults: '2025-11-30',
person_profiles: 'always',
};

var PRODUCTION_HOSTNAMES = ['docs.openhands.dev'];

function isStagingHostname(hostname) {
if (PRODUCTION_HOSTNAMES.indexOf(hostname) !== -1) return false;
// Mintlify preview deployments are served from *.mintlify.site or *.mintlify.app.
return (
/\.mintlify\.site$/.test(hostname) ||
/\.mintlify\.app$/.test(hostname) ||
hostname === 'localhost' ||
hostname === '127.0.0.1' ||
hostname === '0.0.0.0'
);
}

(function () {
var hostname = (window.location && window.location.hostname) || '';
var apiKey = isStagingHostname(hostname) ? STAGING_KEY : PROD_KEY;

posthog.init(apiKey, POSTHOG_CONFIG);
})();
Loading