"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var path_1 = require("path");
var base_path_1 = __importDefault(require("lib/base-path"));
var use_customize_1 = __importDefault(require("lib/use-customize"));
function GoogleAnalytics() {
    var googleAnalytics = (0, use_customize_1.default)().googleAnalytics;
    var GA_TRACKING_ID = googleAnalytics;
    if (!GA_TRACKING_ID)
        return [];
    var ga = "window.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', '".concat(GA_TRACKING_ID, "');");
    return [
        (0, jsx_runtime_1.jsx)("script", { async: true, defer: true, src: "https://www.googletagmanager.com/gtag/js?id=".concat(GA_TRACKING_ID) }, "google-analytics-0"),
        (0, jsx_runtime_1.jsx)("script", { dangerouslySetInnerHTML: { __html: ga } }, "google-analytics-1"),
    ];
}
function CoCalcAnalytics() {
    return [
        (0, jsx_runtime_1.jsx)("script", { async: true, defer: true, src: (0, path_1.join)(base_path_1.default, "analytics.js") }, "cocalc-analytics"),
    ];
}
// Why so careful not to nest things?  See
//    https://nextjs.org/docs/api-reference/next/head
// NOTE:  Analytics can't be in Head because of script tags! https://github.com/vercel/next.js/pull/26253
function Analytics() {
    return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: GoogleAnalytics().concat(CoCalcAnalytics()) });
}
exports.default = Analytics;
//# sourceMappingURL=analytics.js.map