Reverted all changes back to version f51d90d9cc
This commit is contained in:
@@ -34,7 +34,6 @@ export interface DetectedSystem {
|
|||||||
|
|
||||||
export interface DetectedTracker {
|
export interface DetectedTracker {
|
||||||
name: string;
|
name: string;
|
||||||
id?: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extractMetaData(url: string, keyword?: string) {
|
export async function extractMetaData(url: string, keyword?: string) {
|
||||||
@@ -289,33 +288,17 @@ export async function extractMetaData(url: string, keyword?: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const detectedTrackers: DetectedTracker[] = [];
|
const detectedTrackers: DetectedTracker[] = [];
|
||||||
const uniqueTrackers = new Map<string, DetectedTracker>();
|
const uniqueTrackers = new Set<string>();
|
||||||
|
|
||||||
const addTracker = (name: string, id: string | null = null) => {
|
// Google Analytics / Tag Manager
|
||||||
if (!uniqueTrackers.has(name)) {
|
|
||||||
uniqueTrackers.set(name, { name, id });
|
|
||||||
} else {
|
|
||||||
const existing = uniqueTrackers.get(name)!;
|
|
||||||
if (!existing.id && id) {
|
|
||||||
existing.id = id;
|
|
||||||
uniqueTrackers.set(name, existing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Google Analytics
|
|
||||||
if (
|
if (
|
||||||
htmlContent.includes("googletagmanager.com/gtag/js") ||
|
htmlContent.includes("googletagmanager.com/gtag/js") ||
|
||||||
htmlContent.includes("google-analytics.com/analytics.js")
|
htmlContent.includes("google-analytics.com/analytics.js")
|
||||||
) {
|
) {
|
||||||
const gaIdMatch = htmlContent.match(/(G|UA)-[A-Z0-9-]+/);
|
uniqueTrackers.add("Google Analytics");
|
||||||
addTracker("Google Analytics", gaIdMatch ? gaIdMatch[0] : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Google Tag Manager
|
|
||||||
if (htmlContent.includes("googletagmanager.com/gtm.js")) {
|
if (htmlContent.includes("googletagmanager.com/gtm.js")) {
|
||||||
const gtmIdMatch = htmlContent.match(/GTM-[A-Z0-9]+/);
|
uniqueTrackers.add("Google Tag Manager");
|
||||||
addTracker("Google Tag Manager", gtmIdMatch ? gtmIdMatch[0] : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Facebook Pixel
|
// Facebook Pixel
|
||||||
@@ -323,8 +306,7 @@ export async function extractMetaData(url: string, keyword?: string) {
|
|||||||
htmlContent.includes("connect.facebook.net") ||
|
htmlContent.includes("connect.facebook.net") ||
|
||||||
htmlContent.includes("fbq('init'")
|
htmlContent.includes("fbq('init'")
|
||||||
) {
|
) {
|
||||||
const fbIdMatch = htmlContent.match(/fbq\('init', '(\d+)'\)/);
|
uniqueTrackers.add("Facebook Pixel");
|
||||||
addTracker("Facebook Pixel", fbIdMatch ? fbIdMatch[1] : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hotjar
|
// Hotjar
|
||||||
@@ -332,52 +314,42 @@ export async function extractMetaData(url: string, keyword?: string) {
|
|||||||
htmlContent.includes("static.hotjar.com") ||
|
htmlContent.includes("static.hotjar.com") ||
|
||||||
htmlContent.includes("window.hj=window.hj||function()")
|
htmlContent.includes("window.hj=window.hj||function()")
|
||||||
) {
|
) {
|
||||||
const hjIdMatch = htmlContent.match(/hjid:(\d+)/);
|
uniqueTrackers.add("Hotjar");
|
||||||
addTracker("Hotjar", hjIdMatch ? hjIdMatch[1] : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HubSpot
|
// HubSpot
|
||||||
if (htmlContent.includes("js.hs-scripts.com")) {
|
if (htmlContent.includes("js.hs-scripts.com")) {
|
||||||
const hsIdMatch = htmlContent.match(/js\.hs-scripts\.com\/(\d+)\.js/);
|
uniqueTrackers.add("HubSpot");
|
||||||
addTracker("HubSpot", hsIdMatch ? hsIdMatch[1] : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Segment
|
// Segment
|
||||||
if (htmlContent.includes("cdn.segment.com")) {
|
if (htmlContent.includes("cdn.segment.com")) {
|
||||||
const segmentIdMatch = htmlContent.match(/analytics\.load\("([^"]+)"\)/);
|
uniqueTrackers.add("Segment");
|
||||||
addTracker("Segment", segmentIdMatch ? segmentIdMatch[1] : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mixpanel
|
// Mixpanel
|
||||||
if (htmlContent.includes("cdn.mxpnl.com")) {
|
if (htmlContent.includes("cdn.mxpnl.com")) {
|
||||||
const mixpanelIdMatch = htmlContent.match(/mixpanel\.init\("([^"]+)"\)/);
|
uniqueTrackers.add("Mixpanel");
|
||||||
addTracker("Mixpanel", mixpanelIdMatch ? mixpanelIdMatch[1] : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vercel Analytics
|
// Vercel Analytics
|
||||||
if (htmlContent.includes("/_vercel/insights/")) {
|
if (htmlContent.includes("/_vercel/insights/")) {
|
||||||
addTracker("Vercel Analytics");
|
uniqueTrackers.add("Vercel Analytics");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plausible
|
// Plausible
|
||||||
if (htmlContent.includes("plausible.io/js/")) {
|
if (htmlContent.includes("plausible.io/js/")) {
|
||||||
const plausibleDomainMatch = htmlContent.match(/data-domain="([^"]+)"/);
|
uniqueTrackers.add("Plausible");
|
||||||
addTracker(
|
|
||||||
"Plausible",
|
|
||||||
plausibleDomainMatch ? plausibleDomainMatch[1] : null
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Microsoft Clarity
|
// Microsoft Clarity
|
||||||
if (htmlContent.includes("clarity.ms/tag/")) {
|
if (htmlContent.includes("clarity.ms/tag/")) {
|
||||||
const clarityIdMatch = htmlContent.match(/clarity\.ms\/tag\/([a-z0-9]+)/);
|
uniqueTrackers.add("Microsoft Clarity");
|
||||||
addTracker(
|
|
||||||
"Microsoft Clarity",
|
|
||||||
clarityIdMatch ? clarityIdMatch[1] : null
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detectedTrackers.push(...Array.from(uniqueTrackers.values()));
|
uniqueTrackers.forEach((tracker) => {
|
||||||
|
detectedTrackers.push({ name: tracker });
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
Code,
|
Code,
|
||||||
Eye,
|
Eye,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { CopyButton } from "@/components/copy-button";
|
|
||||||
|
|
||||||
interface TrackingDisplayProps {
|
interface TrackingDisplayProps {
|
||||||
trackers: DetectedTracker[];
|
trackers: DetectedTracker[];
|
||||||
@@ -102,19 +101,11 @@ export function TrackingDisplay({ trackers }: TrackingDisplayProps) {
|
|||||||
<div className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-lg bg-primary text-primary-foreground">
|
<div className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-lg bg-primary text-primary-foreground">
|
||||||
<Icon className="h-6 w-6" />
|
<Icon className="h-6 w-6" />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-grow">
|
<div>
|
||||||
<h4 className="font-semibold text-lg">{tracker.name}</h4>
|
<h4 className="font-semibold text-lg">{tracker.name}</h4>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
{info.description}
|
{info.description}
|
||||||
</p>
|
</p>
|
||||||
{tracker.id && (
|
|
||||||
<div className="mt-3 flex items-center gap-2 p-2 rounded-md bg-background border">
|
|
||||||
<p className="font-mono text-sm text-foreground flex-grow break-all">
|
|
||||||
{tracker.id}
|
|
||||||
</p>
|
|
||||||
<CopyButton textToCopy={tracker.id} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user