import ReactGA from "react-ga4";
import Config from "../../config";
export var EventCategory;
(function (EventCategory) {
    EventCategory["Home"] = "Home";
    EventCategory["ProductsTable"] = "Products Table";
    EventCategory["UsersTable"] = "Users Table";
    EventCategory["CustomUserTable"] = "Custom User Table";
    EventCategory["Table"] = "Table";
    EventCategory["NPMPackage"] = "NPM Package";
    EventCategory["TableCRUD"] = "Table CRUD";
    EventCategory["TableProps"] = "Table Props Page";
})(EventCategory || (EventCategory = {}));
export var EventAction;
(function (EventAction) {
    EventAction["Click"] = "Click";
    EventAction["View"] = "View";
    EventAction["Open"] = "Open";
    EventAction["Submit"] = "Submit";
    EventAction["Copy"] = "Copy";
    EventAction["Export"] = "Export";
    EventAction["Delete"] = "Delete";
    EventAction["Create"] = "Create";
    EventAction["Edit"] = "Edit";
    EventAction["Save"] = "Save";
    EventAction["Cancel"] = "Cancel";
    EventAction["Navigate"] = "Navigate";
    EventAction["ThemeToggle"] = "Theme Toggle";
    EventAction["RowActionsClick"] = "Row Actions Click";
    EventAction["CodeSnippetCopy"] = "CodeSnippet Copy";
})(EventAction || (EventAction = {}));
export var initGoogleAnalytics = function () {
    var TRACKING_ID = Config.GOOGLE_ANALYTICS_TRACKING_ID;
    var ENV = Config.ENV;
    if (TRACKING_ID && ENV === "production") {
        ReactGA.initialize(TRACKING_ID);
    }
};
export var sendGoogleAnalyticsPageView = function (pathname) {
    ReactGA.set({ page: pathname });
    ReactGA.send({ hitType: "pageview", page: pathname, title: document.title });
};
export var trackEvent = function (_a) {
    var category = _a.category, action = _a.action, label = _a.label, _b = _a.debug, debug = _b === void 0 ? false : _b;
    if (debug) {
        console.log("trackEvent | Google Analytics", { category: category, action: action, label: label });
    }
    ReactGA.event({
        category: category,
        action: action,
        label: label,
    });
};
