mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-19 05:40:44 +00:00
CE-1123 - Update google analytics to work with events as well as page views; add calls to it to most actual pages.
This commit is contained in:
@ -31,8 +31,6 @@ import Box from "@mui/material/Box";
|
||||
import Card from "@mui/material/Card";
|
||||
import Divider from "@mui/material/Divider";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import React, {useContext, useEffect, useState} from "react";
|
||||
import {Link, useLocation} from "react-router-dom";
|
||||
import QContext from "QContext";
|
||||
import colors from "qqq/assets/theme/base/colors";
|
||||
import MDTypography from "qqq/components/legacy/MDTypography";
|
||||
@ -41,6 +39,8 @@ import DashboardWidgets from "qqq/components/widgets/DashboardWidgets";
|
||||
import MiniStatisticsCard from "qqq/components/widgets/statistics/MiniStatisticsCard";
|
||||
import BaseLayout from "qqq/layouts/BaseLayout";
|
||||
import Client from "qqq/utils/qqq/Client";
|
||||
import React, {useContext, useEffect, useState} from "react";
|
||||
import {Link, useLocation} from "react-router-dom";
|
||||
|
||||
const qController = Client.getInstance();
|
||||
|
||||
@ -62,7 +62,7 @@ function AppHome({app}: Props): JSX.Element
|
||||
const [updatedTableCounts, setUpdatedTableCounts] = useState(new Date());
|
||||
const [widgets, setWidgets] = useState([] as any[]);
|
||||
|
||||
const {pageHeader, setPageHeader} = useContext(QContext);
|
||||
const {pageHeader, recordAnalytics, setPageHeader} = useContext(QContext);
|
||||
|
||||
const location = useLocation();
|
||||
|
||||
@ -86,8 +86,9 @@ function AppHome({app}: Props): JSX.Element
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
// setPageHeader(app.label);
|
||||
setPageHeader(null);
|
||||
recordAnalytics({location: window.location, title: "App: " + app.label});
|
||||
recordAnalytics({category: "appEvents", action: "loadAppScreen", label: app.label});
|
||||
|
||||
if (!qInstance)
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
||||
const [showErrorDetail, setShowErrorDetail] = useState(false);
|
||||
const [showFullHelpText, setShowFullHelpText] = useState(false);
|
||||
|
||||
const {pageHeader, setPageHeader} = useContext(QContext);
|
||||
const {pageHeader, recordAnalytics, setPageHeader} = useContext(QContext);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// for setting the processError state - call this function, which will also set the isUserFacingError state //
|
||||
@ -1146,6 +1146,10 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
||||
const processMetaData = await Client.getInstance().loadProcessMetaData(processName);
|
||||
setProcessMetaData(processMetaData);
|
||||
setSteps(processMetaData.frontendSteps);
|
||||
|
||||
recordAnalytics({location: window.location, title: "Process: " + processMetaData?.label});
|
||||
recordAnalytics({category: "processEvents", action: "startProcess", label: processMetaData?.label});
|
||||
|
||||
if (processMetaData.tableName && !tableMetaData)
|
||||
{
|
||||
try
|
||||
@ -1251,6 +1255,8 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
||||
|
||||
setTimeout(async () =>
|
||||
{
|
||||
recordAnalytics({category: "processEvents", action: "processStep", label: activeStep.label});
|
||||
|
||||
const processResponse = await Client.getInstance().processStep(
|
||||
processName,
|
||||
processUUID,
|
||||
|
@ -338,7 +338,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
/////////////////////////////
|
||||
// page context references //
|
||||
/////////////////////////////
|
||||
const {accentColor, accentColorLight, setPageHeader, dotMenuOpen, keyboardHelpOpen} = useContext(QContext);
|
||||
const {accentColor, accentColorLight, setPageHeader, recordAnalytics, dotMenuOpen, keyboardHelpOpen} = useContext(QContext);
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// we use our own header - so clear out the context page header //
|
||||
@ -875,6 +875,8 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
return;
|
||||
}
|
||||
|
||||
recordAnalytics({category: "tableEvents", action: "query", label: tableMetaData.label});
|
||||
|
||||
console.log(`In updateTable for ${reason} ${JSON.stringify(queryFilter)}`);
|
||||
setLoading(true);
|
||||
setRows([]);
|
||||
@ -1642,6 +1644,8 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
{
|
||||
if (selectedSavedViewId != null)
|
||||
{
|
||||
recordAnalytics({category: "tableEvents", action: "activateSavedView", label: tableMetaData.label});
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// fetch, then activate the selected filter //
|
||||
//////////////////////////////////////////////
|
||||
@ -1657,6 +1661,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
/////////////////////////////////
|
||||
// this is 'new view' - right? //
|
||||
/////////////////////////////////
|
||||
recordAnalytics({category: "tableEvents", action: "activateNewView", label: tableMetaData.label});
|
||||
|
||||
//////////////////////////////
|
||||
// wipe away the saved view //
|
||||
@ -2327,6 +2332,8 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
setTableMetaData(tableMetaData);
|
||||
setTableLabel(tableMetaData.label);
|
||||
|
||||
recordAnalytics({location: window.location, title: "Query: " + tableMetaData.label});
|
||||
|
||||
setTableProcesses(ProcessUtils.getProcessesForTable(metaData, tableName)); // these are the ones to show in the dropdown
|
||||
setAllTableProcesses(ProcessUtils.getProcessesForTable(metaData, tableName, true)); // these include hidden ones (e.g., to find the bulks)
|
||||
|
||||
|
@ -69,13 +69,9 @@ function RecordDeveloperView({table}: Props): JSX.Element
|
||||
const [associatedScripts, setAssociatedScripts] = useState([] as any[]);
|
||||
const [notFoundMessage, setNotFoundMessage] = useState(null);
|
||||
|
||||
const [selectedTabs, setSelectedTabs] = useState({} as any);
|
||||
const [viewingRevisions, setViewingRevisions] = useState({} as any);
|
||||
const [scriptLogs, setScriptLogs] = useState({} as any);
|
||||
|
||||
const [alertText, setAlertText] = useState(null as string);
|
||||
|
||||
const {setPageHeader} = useContext(QContext);
|
||||
const {setPageHeader, recordAnalytics} = useContext(QContext);
|
||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||
|
||||
if (!asyncLoadInited)
|
||||
@ -90,6 +86,8 @@ function RecordDeveloperView({table}: Props): JSX.Element
|
||||
const tableMetaData = await qController.loadTableMetaData(tableName);
|
||||
setTableMetaData(tableMetaData);
|
||||
|
||||
recordAnalytics({location: window.location, title: "Developer Mode: " + tableMetaData.label});
|
||||
|
||||
//////////////////////////////
|
||||
// load top-level meta-data //
|
||||
//////////////////////////////
|
||||
|
@ -121,7 +121,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
const openActionsMenu = (event: any) => setActionsMenu(event.currentTarget);
|
||||
const closeActionsMenu = () => setActionsMenu(null);
|
||||
|
||||
const {accentColor, setPageHeader, tableMetaData, setTableMetaData, tableProcesses, setTableProcesses, dotMenuOpen, keyboardHelpOpen, helpHelpActive} = useContext(QContext);
|
||||
const {accentColor, setPageHeader, tableMetaData, setTableMetaData, tableProcesses, setTableProcesses, dotMenuOpen, keyboardHelpOpen, helpHelpActive, recordAnalytics} = useContext(QContext);
|
||||
|
||||
if (localStorage.getItem(tableVariantLocalStorageKey))
|
||||
{
|
||||
@ -384,6 +384,8 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
const tableMetaData = await qController.loadTableMetaData(tableName);
|
||||
setTableMetaData(tableMetaData);
|
||||
|
||||
recordAnalytics({location: window.location, title: "View: " + tableMetaData.label});
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// load top-level meta-data (e.g., to find processes for table) //
|
||||
//////////////////////////////////////////////////////////////////
|
||||
@ -430,6 +432,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
{
|
||||
record = await qController.get(tableName, id, tableVariant, null, queryJoins);
|
||||
setRecord(record);
|
||||
recordAnalytics({category: "tableEvents", action: "view", label: tableMetaData?.label + " / " + record?.recordLabel});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
@ -631,6 +634,8 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
event?.preventDefault();
|
||||
(async () =>
|
||||
{
|
||||
recordAnalytics({category: "tableEvents", action: "delete", label: tableMetaData?.label + " / " + record?.recordLabel});
|
||||
|
||||
await qController.delete(tableName, id)
|
||||
.then(() =>
|
||||
{
|
||||
|
Reference in New Issue
Block a user