import posthog from "posthog-js";
import useElectron from "../use-electron";
var posthogMock = {
  opt_in_capturing: function opt_in_capturing() {
    return null;
  },
  opt_out_capturing: function opt_out_capturing() {
    return null;
  },
  init: function init() {
    return null;
  },
  reset: function reset() {
    return null;
  },
  capture: function capture() {
    return null;
  },
  capture_forms: function capture_forms() {
    return null;
  },
  capture_pageview: function capture_pageview() {
    return null;
  },
  register: function register() {
    return null;
  },
  register_once: function register_once() {
    return null;
  },
  unregister: function unregister() {
    return null;
  },
  identify: function identify() {
    return "mock";
  },
  alias: function alias() {
    return null;
  },
  set_config: function set_config() {
    return null;
  },
  get_config: function get_config() {
    return null;
  },
  get_property: function get_property() {
    return null;
  },
  get_distinct_id: function get_distinct_id() {
    return null;
  },
  has_opted_out_capturing: function has_opted_out_capturing() {
    return true;
  },
  has_opted_in_capturing: function has_opted_in_capturing() {
    return false;
  },
  disable_all_events: function disable_all_events() {
    return null;
  },
  people: {
    set: function set() {
      return null;
    },
    set_once: function set_once() {
      return null;
    }
  }
};
window.posthogInitialized = false;
export default (function () {
  var isDesktop = Boolean(useElectron());

  if (window.Cypress) {
    window.posthogInitialized = true;
    window.posthog = posthogMock;
  }

  if (!window.posthogInitialized) {
    posthog.init("dSrx1PbFd02XsxlLd7qNbeTxKZwwao2sclVmapyYlT4", {
      api_host: "https://posthog.universaldatatool.com",
      autocapture: false
    });
    window.posthog = posthog;
    var domain = isDesktop ? "https://desktop.universaldatatool.com" : window.location.origin;
    posthog.capture("domain", {
      domain: domain
    });
    posthog.capture("is_desktop", {
      isDesktop: isDesktop
    });
    posthog.people.set({
      is_desktop: isDesktop,
      domain: domain
    });
    window.posthogInitialized = true;
  }

  return window.posthog;
});