Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions app/[slug]/PageClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import SEOComponent from '@/app/components/theme/SEOComponent/SEOComponent';
import { detectBrowser } from '@/app/libs/helpers';
import EdgeIcon from '@/app/components/theme/Icon/edgeIcon';
import { useTheme } from '@/app/contexts/themeContext';
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from '@/app/libs/analytics';

const PageClient = ({ slug }: { slug: string }) => {
const [browser, setBrowser] = useState('chrome');
Expand Down Expand Up @@ -51,6 +52,7 @@ const PageClient = ({ slug }: { slug: string }) => {
const currentTool = developmentToolsRoutes.find(
(tool: any) => tool.path === pathname
);
const toolName = meta_data?.meta_title?.split(' - ')?.[0] || pathname;

return (
<>
Expand Down Expand Up @@ -94,7 +96,18 @@ const PageClient = ({ slug }: { slug: string }) => {
Swiftly document and share bugs like never before
</p>
<div className="flex items-center gap-3 mt-6 mb-4">
<Link target="_blank" href={Extension_URL}>
<Link
target="_blank"
href={Extension_URL}
onClick={() =>
trackEvent('add_to_chrome_click', {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
section_name: 'Hero Section',
cta_text: browser === 'edge' ? 'Add to Edge' : 'Add to Chrome',
})
}
>
<Button
className={`btn-primary flex items-center z-20 justify-center gap-3 rounded-full px-4 ${DevelopmentToolsStyles.addToChromeButton}`}
>
Expand Down Expand Up @@ -229,7 +242,17 @@ const PageClient = ({ slug }: { slug: string }) => {
</h2>
</div>
{development_tools_list?.map((tool: any, index: any) => (
<Link key={index} href={tool?.url}>
<Link
key={index}
href={tool?.url}
onClick={() =>
trackEvent('dev_tool_card_click', {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: tool?.tool,
})
}
>
<div
className={`p-3 mb-2 cursor-pointer rounded-xl border-[1px] border-transparent hover:border-1 hover:border-primary bg-black text-white hover:text-primary ${DevelopmentToolsStyles.sidePanelItem}`}
>
Expand Down Expand Up @@ -1076,7 +1099,18 @@ const PageClient = ({ slug }: { slug: string }) => {
Swiftly document and share bugs like never before
</p>
<div className="flex items-center gap-3 mt-6 mb-4">
<Link target="_blank" href={Extension_URL}>
<Link
target="_blank"
href={Extension_URL}
onClick={() =>
trackEvent('add_to_chrome_click', {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
section_name: 'Bottom CTA Section',
cta_text: browser === 'edge' ? 'Add to Edge' : 'Add to Chrome',
})
}
>
<Button
className={`btn-primary flex items-center z-20 justify-center gap-3 rounded-full px-4 ${DevelopmentToolsStyles.addToChromeButton}`}
>
Expand Down
13 changes: 11 additions & 2 deletions app/components/developmentToolsComponent/amIUsingTor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";
import React, { useEffect, useState } from "react";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

const Cmd = ({ children }: { children: string }) => (
<code className="px-2 py-1 rounded bg-black/40 border border-white/10 font-mono text-xs">
Expand Down Expand Up @@ -125,13 +126,21 @@ const AmIUsingTor = () => {
} catch {}
};

const copyResult = () => {
const copyResult = async () => {
const result = `Tor Detection Result: ${torResult.isTor ? 'YES' : 'NO'}
Confidence: ${torResult.confidence}
Details: ${torResult.details}
User Agent: ${navigator.userAgent}
Timestamp: ${new Date().toISOString()}`;
copy(result);
try {
await navigator.clipboard.writeText(result);
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "Am I Using Tor",
tool_action: "Copy",
});
} catch {}
};

const getStatusColor = () => {
Expand Down
13 changes: 12 additions & 1 deletion app/components/developmentToolsComponent/apiKeyGenerator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import React, { useEffect, useRef, useState } from "react";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

type Charset = {
upper: boolean;
Expand Down Expand Up @@ -85,6 +86,16 @@ const ApiKeyGenerator: React.FC = () => {
run();
}, [length, count, groupSize, charset, prefix, suffix, autoUpdate]);

const handleGenerateClick = () => {
run();
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "API Key Generator",
tool_action: "Generate",
});
};

const onCopy = async () => {
try {
await navigator.clipboard.writeText(keys.join("\n"));
Expand Down Expand Up @@ -239,7 +250,7 @@ const ApiKeyGenerator: React.FC = () => {
<div className="flex items-center justify-between">
<label className="font-medium">Generator</label>
<button
onClick={run}
onClick={handleGenerateClick}
className="px-3 py-1 bg-primary hover:bg-primary/80 rounded text-sm transition-colors text-black font-bold"
>
Generate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";
import React, { useState } from "react";
import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

const AsciiToDecimalConverter = () => {
const [input, setInput] = useState<string>("");
Expand All @@ -20,7 +21,16 @@ const AsciiToDecimalConverter = () => {
setOutput("");
return;
}
setOutput(convertAsciiToDecimal(input));
const result = convertAsciiToDecimal(input);
setOutput(result);
if (!result.startsWith("Error")) {
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "ASCII to Decimal Converter",
tool_action: "Convert",
});
}
};

const clearAll = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";
import React, { useState } from "react";
import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

function decodeAsciiEscapesToUnicode(input: string): string {
// Supports sequences like \u0041 and raw ASCII characters
Expand All @@ -20,6 +21,12 @@ const AsciiToUnicodeConverter = () => {
return;
}
setOutput(decodeAsciiEscapesToUnicode(input));
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "ASCII to Unicode",
tool_action: "Convert",
});
};

const clearAll = () => {
Expand Down
9 changes: 9 additions & 0 deletions app/components/developmentToolsComponent/barcodeGenerator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import React, { useEffect, useMemo, useRef, useState } from "react";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

type Symbology =
| "CODE128"
Expand Down Expand Up @@ -524,6 +525,14 @@ const BarcodeGenerator: React.FC = () => {

const onGenerate = () => {
setOutput(result.svg);
if (result.svg) {
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "Barcode Generator",
tool_action: "Generate",
});
}
};

const onCopy = async () => {
Expand Down
7 changes: 7 additions & 0 deletions app/components/developmentToolsComponent/base64Decoder.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";
import React, { useMemo, useRef, useState } from "react";
import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

const Base64Decoder = () => {
const [encodedText, setEncodedText] = useState("");
Expand Down Expand Up @@ -39,6 +40,12 @@ const Base64Decoder = () => {
if (!decodedText) return;
try {
await navigator.clipboard.writeText(decodedText);
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "Base64 Decoder",
tool_action: "Copy",
});
} catch (_) {}
};

Expand Down
7 changes: 7 additions & 0 deletions app/components/developmentToolsComponent/base64Encoder.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";
import React, { useMemo, useRef, useState } from "react";
import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

const Base64Encoder = () => {
const [plainText, setPlainText] = useState("");
Expand Down Expand Up @@ -31,6 +32,12 @@ const Base64Encoder = () => {
if (!encodedText) return;
try {
await navigator.clipboard.writeText(encodedText);
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "Base64 Encoder",
tool_action: "Copy",
});
} catch (_) {}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React, { useEffect, useMemo, useRef, useState } from "react";
import DevelopmentToolsStyles from "../../developmentToolsStyles.module.scss";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

const MAX_DECODED_BYTES = 10 * 1024 * 1024;

Expand Down Expand Up @@ -163,6 +164,12 @@ const Base64ToImageConverter: React.FC = () => {
document.body.appendChild(a);
a.click();
a.remove();
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "Base64 To Image Converter",
tool_action: "Download",
});
};

const copyInput = async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

function parseBcdToDecimal(input: string): string {
const clean = input.replace(/\s+/g, "");
Expand Down Expand Up @@ -45,6 +46,12 @@ const BcdToDecimalConverter: React.FC = () => {
} else {
setError("");
setOutput(res);
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "BCD to Decimal Converter",
tool_action: "Convert",
});
}
}, [input]);

Expand Down
13 changes: 13 additions & 0 deletions app/components/developmentToolsComponent/bcryptGenerator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";
import React, { useState, useMemo } from "react";
import bcrypt from 'bcryptjs';
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

// Custom styles for the range slider
const sliderStyles = `
Expand Down Expand Up @@ -81,6 +82,12 @@ const BcryptGenerator = () => {
try {
const hash = await generateHash(password, saltRounds);
setHashedPassword(hash);
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "Bcrypt Generator",
tool_action: "Generate Hash",
});
} catch (error) {
console.error('Error generating hash:', error);
} finally {
Expand All @@ -95,6 +102,12 @@ const BcryptGenerator = () => {
try {
const isValid = await verifyHash(verifyPassword, verifyHashInput);
setVerificationResult(isValid);
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "Bcrypt Generator",
tool_action: "Verify Password",
});
} catch (error) {
console.error('Error verifying password:', error);
setVerificationResult(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, {
useRef,
useState,
} from "react";
import { trackEvent, PAGE_TYPE, getRuntimePlatform } from "@/app/libs/analytics";

function parseBinary(input: string): number | null {
const clean = input.replace(/\s+/g, "");
Expand Down Expand Up @@ -38,6 +39,18 @@ const BinaryToDecimalConverter: React.FC = () => {
if (autoUpdate) convert();
}, [input, autoUpdate, convert]);

const onConvertClick = useCallback(() => {
convert();
if (parseBinary(input) !== null) {
trackEvent("dev_tool_used", {
page_type: PAGE_TYPE,
platform: getRuntimePlatform(),
tool_name: "Binary to Decimal Converter",
tool_action: "Convert",
});
}
}, [convert, input]);

const onCopy = useCallback(async () => {
try {
await navigator.clipboard.writeText(output);
Expand Down Expand Up @@ -90,7 +103,7 @@ const BinaryToDecimalConverter: React.FC = () => {
Auto-update
</label>
<button
onClick={convert}
onClick={onConvertClick}
className="border border-black/30 px-3 py-1 rounded text-xs sm:text-sm bg-primary hover:bg-primary/90 text-black font-bold"
>
Convert
Expand Down
Loading
Loading