Reverted all changes back to version f51d90d9cc
This commit is contained in:
@@ -34,7 +34,6 @@ export interface DetectedSystem {
|
||||
|
||||
export interface DetectedTracker {
|
||||
name: string;
|
||||
id?: string | null;
|
||||
}
|
||||
|
||||
export async function extractMetaData(url: string, keyword?: string) {
|
||||
@@ -289,33 +288,17 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
});
|
||||
|
||||
const detectedTrackers: DetectedTracker[] = [];
|
||||
const uniqueTrackers = new Map<string, DetectedTracker>();
|
||||
const uniqueTrackers = new Set<string>();
|
||||
|
||||
const addTracker = (name: string, id: string | null = null) => {
|
||||
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
|
||||
// Google Analytics / Tag Manager
|
||||
if (
|
||||
htmlContent.includes("googletagmanager.com/gtag/js") ||
|
||||
htmlContent.includes("google-analytics.com/analytics.js")
|
||||
) {
|
||||
const gaIdMatch = htmlContent.match(/(G|UA)-[A-Z0-9-]+/);
|
||||
addTracker("Google Analytics", gaIdMatch ? gaIdMatch[0] : null);
|
||||
uniqueTrackers.add("Google Analytics");
|
||||
}
|
||||
|
||||
// Google Tag Manager
|
||||
if (htmlContent.includes("googletagmanager.com/gtm.js")) {
|
||||
const gtmIdMatch = htmlContent.match(/GTM-[A-Z0-9]+/);
|
||||
addTracker("Google Tag Manager", gtmIdMatch ? gtmIdMatch[0] : null);
|
||||
uniqueTrackers.add("Google Tag Manager");
|
||||
}
|
||||
|
||||
// Facebook Pixel
|
||||
@@ -323,8 +306,7 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
htmlContent.includes("connect.facebook.net") ||
|
||||
htmlContent.includes("fbq('init'")
|
||||
) {
|
||||
const fbIdMatch = htmlContent.match(/fbq\('init', '(\d+)'\)/);
|
||||
addTracker("Facebook Pixel", fbIdMatch ? fbIdMatch[1] : null);
|
||||
uniqueTrackers.add("Facebook Pixel");
|
||||
}
|
||||
|
||||
// Hotjar
|
||||
@@ -332,52 +314,42 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
htmlContent.includes("static.hotjar.com") ||
|
||||
htmlContent.includes("window.hj=window.hj||function()")
|
||||
) {
|
||||
const hjIdMatch = htmlContent.match(/hjid:(\d+)/);
|
||||
addTracker("Hotjar", hjIdMatch ? hjIdMatch[1] : null);
|
||||
uniqueTrackers.add("Hotjar");
|
||||
}
|
||||
|
||||
// HubSpot
|
||||
if (htmlContent.includes("js.hs-scripts.com")) {
|
||||
const hsIdMatch = htmlContent.match(/js\.hs-scripts\.com\/(\d+)\.js/);
|
||||
addTracker("HubSpot", hsIdMatch ? hsIdMatch[1] : null);
|
||||
uniqueTrackers.add("HubSpot");
|
||||
}
|
||||
|
||||
// Segment
|
||||
if (htmlContent.includes("cdn.segment.com")) {
|
||||
const segmentIdMatch = htmlContent.match(/analytics\.load\("([^"]+)"\)/);
|
||||
addTracker("Segment", segmentIdMatch ? segmentIdMatch[1] : null);
|
||||
uniqueTrackers.add("Segment");
|
||||
}
|
||||
|
||||
// Mixpanel
|
||||
if (htmlContent.includes("cdn.mxpnl.com")) {
|
||||
const mixpanelIdMatch = htmlContent.match(/mixpanel\.init\("([^"]+)"\)/);
|
||||
addTracker("Mixpanel", mixpanelIdMatch ? mixpanelIdMatch[1] : null);
|
||||
uniqueTrackers.add("Mixpanel");
|
||||
}
|
||||
|
||||
// Vercel Analytics
|
||||
if (htmlContent.includes("/_vercel/insights/")) {
|
||||
addTracker("Vercel Analytics");
|
||||
uniqueTrackers.add("Vercel Analytics");
|
||||
}
|
||||
|
||||
// Plausible
|
||||
if (htmlContent.includes("plausible.io/js/")) {
|
||||
const plausibleDomainMatch = htmlContent.match(/data-domain="([^"]+)"/);
|
||||
addTracker(
|
||||
"Plausible",
|
||||
plausibleDomainMatch ? plausibleDomainMatch[1] : null
|
||||
);
|
||||
uniqueTrackers.add("Plausible");
|
||||
}
|
||||
|
||||
// Microsoft Clarity
|
||||
if (htmlContent.includes("clarity.ms/tag/")) {
|
||||
const clarityIdMatch = htmlContent.match(/clarity\.ms\/tag\/([a-z0-9]+)/);
|
||||
addTracker(
|
||||
"Microsoft Clarity",
|
||||
clarityIdMatch ? clarityIdMatch[1] : null
|
||||
);
|
||||
uniqueTrackers.add("Microsoft Clarity");
|
||||
}
|
||||
|
||||
detectedTrackers.push(...Array.from(uniqueTrackers.values()));
|
||||
uniqueTrackers.forEach((tracker) => {
|
||||
detectedTrackers.push({ name: tracker });
|
||||
});
|
||||
|
||||
return {
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user