diff --git a/src/components/Table/TableHeader/Extensions/index.tsx b/src/components/Table/TableHeader/Extensions/index.tsx index 4f23ca0f..b4d4441f 100644 --- a/src/components/Table/TableHeader/Extensions/index.tsx +++ b/src/components/Table/TableHeader/Extensions/index.tsx @@ -18,13 +18,13 @@ import { useConfirmation } from "components/ConfirmationDialog"; import { useSnackLogContext } from "contexts/SnackLogContext"; import { emptyExtensionObject, IExtension, IExtensionType } from "./utils"; -import { SETTINGS } from "config/dbPaths"; -import WIKI_LINKS from "constants/wikiLinks"; import { name } from "@root/package.json"; +import { RunRoutes } from "@src/constants/runRoutes"; +import { analytics } from "@src/analytics"; export default function ExtensionsEditor() { const { enqueueSnackbar } = useSnackbar(); - const { tableState, tableActions } = useProjectContext(); + const { tableState, tableActions, rowyRun } = useProjectContext(); const appContext = useAppContext(); const { requestConfirmation } = useConfirmation(); const currentextensionObjects = (tableState?.config.extensionObjects ?? @@ -84,41 +84,16 @@ export default function ExtensionsEditor() { const handleSaveDeploy = async () => { handleSaveExtensions(); - const settingsDoc = await db.doc(SETTINGS).get(); - const buildUrl = settingsDoc.get("rowyRunUrl"); - if (!buildUrl) { - enqueueSnackbar(`${name} Run is not set up`, { - variant: "error", - action: ( - - ), - }); - } - - // request GCP build - const userTokenInfo = await appContext?.currentUser?.getIdTokenResult(); - const userToken = userTokenInfo?.token; try { snackLogContext.requestSnackLog(); - const response = await fetch(buildUrl, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - configPath: tableState?.config.tableConfig.path, - token: userToken, - }), - }); - const data = await response.json(); + if (rowyRun) + rowyRun({ + route: RunRoutes.buildFunction, + body: { + triggerPath: "", + }, + }); + analytics.logEvent("deployed_extensions"); } catch (e) { console.error(e); } @@ -126,6 +101,7 @@ export default function ExtensionsEditor() { const handleAddExtension = (extensionObject: IExtension) => { setLocalExtensionsObjects([...localExtensionsObjects, extensionObject]); + analytics.logEvent("created_extension", { type: extensionObject.type }); setExtensionModal(null); }; @@ -142,6 +118,7 @@ export default function ExtensionsEditor() { } }) ); + analytics.logEvent("updated_extension", { type: extensionObject.type }); setExtensionModal(null); }; @@ -171,6 +148,9 @@ export default function ExtensionsEditor() { lastEditor: currentEditor(), }, ]); + analytics.logEvent("duplicated_extension", { + type: localExtensionsObjects[index].type, + }); }; const handleEdit = (index: number) => {