import { ApolloProvider } from "@apollo/client";
import { ConfigProvider } from "antd";
import enLocale from "antd/es/locale/en_US";
import LogRocket from "logrocket";
import moment from "moment";
import React from "react";
import { useTranslation } from "react-i18next";
import GlobalLoadingBar from "../components/global-loading-bar/global-loading-bar.component";
import client from "../utils/GraphQLClient";
import App from "./App";
import trackerGraphQL from "@openreplay/tracker-graphql";
//import trackerRedux from "@openreplay/tracker-redux";
import Tracker from "@openreplay/tracker";
//import trackerAssist from "@openreplay/tracker-assist";
moment.locale("en-US");

export const tracker = new Tracker({
  projectKey: "trDmOZlEXUpjGsMtHroA",
  ingestPoint: "https://replay.imex.online/ingest",
  ...(process.env.NODE_ENV === null || process.env.NODE_ENV === "development"
    ? { __DISABLE_SECURE_MODE: true }
    : {}),
  // beaconSize: 10485760,
  onStart: ({ sessionID }) => console.log("ORS SESSION ", sessionID),
});

// tracker.use(
//   trackerAssist({ confirmText: "Technical support is about to assist you." })
// ); // check the list of available options below
export const recordGraphQL = tracker.use(trackerGraphQL());
tracker.start();
if (process.env.NODE_ENV === "production") LogRocket.init("gvfvfw/bodyshopapp");

export default function AppContainer() {
  const { t } = useTranslation();

  return (
    <ApolloProvider client={client}>
      <ConfigProvider
        //componentSize="small"
        input={{ autoComplete: "new-password" }}
        locale={enLocale}
        form={{
          validateMessages: {
            // eslint-disable-next-line no-template-curly-in-string
            required: t("general.validation.required", { label: "${label}" }),
          },
        }}
      >
        <GlobalLoadingBar />
        <App />
      </ConfigProvider>
    </ApolloProvider>
  );
}
