strapi-google-analytics-dashboard
Version:
A plug-and-play Google Analytics 4 dashboard for Strapi 5.x. No code required — just install, configure your credentials, and instantly start tracking GA metrics directly in your admin panel.
79 lines (78 loc) • 2.35 kB
JavaScript
import { useRef, useEffect } from "react";
import { jsx } from "react/jsx-runtime";
import { PresentationChart } from "@strapi/icons";
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
const v = glob[path];
if (v) {
return typeof v === "function" ? v() : Promise.resolve(v);
}
return new Promise((_, reject) => {
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
reject.bind(
null,
new Error(
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
)
)
);
});
};
const PLUGIN_ID = "strapi-google-analytics-dashboard";
const Initializer = ({ setPlugin }) => {
const ref = useRef(setPlugin);
useEffect(() => {
ref.current(PLUGIN_ID);
}, []);
return null;
};
const PluginIcon = () => /* @__PURE__ */ jsx(PresentationChart, { style: { width: 24, height: 24 } });
const index = {
register(app) {
app.addMenuLink({
to: `plugins/${PLUGIN_ID}`,
icon: PluginIcon,
intlLabel: {
id: `${PLUGIN_ID}.plugin.name`,
defaultMessage: "Google Analytics"
},
Component: async () => {
const Home = await import("../_chunks/HomePage-D_Up2cKb.mjs");
return Home;
}
});
app.addSettingsLink("global", {
id: PLUGIN_ID,
intlLabel: {
id: `${PLUGIN_ID}.plugin.name`,
defaultMessage: "Google Analytics"
},
to: `/settings/${PLUGIN_ID}`,
icon: PluginIcon,
Component: async () => {
const Settings = await import("../_chunks/Settings-Bq7xGj7K.mjs");
return Settings;
}
});
app.registerPlugin({
id: PLUGIN_ID,
initializer: Initializer,
isReady: false,
name: "Google Analytics"
});
},
async registerTrads({ locales }) {
return Promise.all(
locales.map(async (locale) => {
try {
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-Byx4XI2L.mjs") }), `./translations/${locale}.json`, 3);
return { data, locale };
} catch {
return { data: {}, locale };
}
})
);
}
};
export {
index as default
};