diff --git a/apps/roboshield/src/components/Finish/Finish.tsx b/apps/roboshield/src/components/Finish/Finish.tsx index a9d04d428..6e19d28ec 100644 --- a/apps/roboshield/src/components/Finish/Finish.tsx +++ b/apps/roboshield/src/components/Finish/Finish.tsx @@ -1,15 +1,16 @@ import { Box, Snackbar } from "@mui/material"; +import { sendGAEvent } from "@next/third-parties/google"; import { useEffect, useState } from "react"; -import Code from "../Code"; +import Code from "@/roboshield/components/Code"; import StepperNav from "@/roboshield/components/StepperNav"; +import SkipToLastStep from "@/roboshield/components/SkipToLastStep"; +import StepHint from "@/roboshield/components/StepHint"; import { useGlobalState } from "@/roboshield/context/GlobalContext"; import { generateRobots } from "@/roboshield/lib/robots"; import { StepComponent } from "@/roboshield/types/stepComponent"; import { downloadFile } from "@/roboshield/utils/file"; -import SkipToLastStep from "@/roboshield/components/SkipToLastStep"; -import StepHint from "@/roboshield/components/StepHint"; interface Props extends StepComponent { handleReset: () => void; @@ -37,27 +38,28 @@ export default function Finish({ }); } - const getCopyMetadata = () => { - const date = new Date().toISOString(); - const url = window.location.href; - return `${code}\n\n\n# Generated on: ${date}\n# URL: ${url}\n\n`; + const reportShieldEvent = (event: string) => { + const value = new Date().toISOString(); + sendGAEvent("event", event, { value: "xyz" }); }; const handleDownload = async () => { + reportShieldEvent("download"); const filename = "robots.txt"; if (!saved) { await saveData(); setSaved(true); } - await downloadFile(filename, getCopyMetadata()); + await downloadFile(filename, code); }; const handleCopy = async () => { + reportShieldEvent("copy"); if (!saved) { await saveData(); setSaved(true); } - navigator.clipboard.writeText(getCopyMetadata()); + navigator.clipboard.writeText(code); setShowSnackbar(true); }; diff --git a/apps/roboshield/src/lib/config.ts b/apps/roboshield/src/lib/config.ts index efece1104..599d13103 100644 --- a/apps/roboshield/src/lib/config.ts +++ b/apps/roboshield/src/lib/config.ts @@ -85,7 +85,7 @@ export const platforms: Platform[] = [ export const configureCrawlDelay = (delay: number) => { const comment = - "#Crawl-delay Specifies the minimum interval (in seconds)\n#for a robot to wait after loading one page, before starting to load another.\n"; + "# Crawl-delay Specifies the minimum interval (in seconds)\n#for a robot to wait after loading one page, before starting to load another.\n"; return `${comment}Crawl-delay: ${delay}\n\n`; }; diff --git a/apps/roboshield/src/lib/robots.ts b/apps/roboshield/src/lib/robots.ts index 2178f8691..8b4cd50d5 100644 --- a/apps/roboshield/src/lib/robots.ts +++ b/apps/roboshield/src/lib/robots.ts @@ -29,7 +29,8 @@ const mergeAndSortBots = (existingBots: Robot[], newBots: Robot[]) => { }; export async function generateRobots(state: GlobalState) { - let robots = ``; + let robots = ` + `; if (state.crawlDelay && state.crawlDelay > 0) { robots += configureCrawlDelay(state.crawlDelay); @@ -73,8 +74,7 @@ export async function generateRobots(state: GlobalState) { robots += configureSitemaps(validSitemaps); } } - - return robots; + return `${robots}\n# Generatedy by RoboShield (https://roboshield.trustlab.africa)\n`; } export const validateRobots = (robots: string) => {