[dyad] Adding a tracking tab to show tracking tools - wrote 4 file(s)
This commit is contained in:
@@ -32,6 +32,10 @@ export interface DetectedSystem {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface DetectedTracker {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export async function extractMetaData(url: string, keyword?: string) {
|
||||
if (!url) {
|
||||
return { error: "URL is required." };
|
||||
@@ -229,8 +233,8 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
links.push({ href: absoluteUrl, text, type, rel });
|
||||
});
|
||||
|
||||
const detectedSystems: DetectedSystem[] = [];
|
||||
const htmlContent = $.html();
|
||||
const detectedSystems: DetectedSystem[] = [];
|
||||
const uniqueSystems = new Set<string>();
|
||||
|
||||
// WordPress
|
||||
@@ -283,6 +287,70 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
detectedSystems.push({ name: system });
|
||||
});
|
||||
|
||||
const detectedTrackers: DetectedTracker[] = [];
|
||||
const uniqueTrackers = new Set<string>();
|
||||
|
||||
// Google Analytics / Tag Manager
|
||||
if (
|
||||
htmlContent.includes("googletagmanager.com/gtag/js") ||
|
||||
htmlContent.includes("google-analytics.com/analytics.js")
|
||||
) {
|
||||
uniqueTrackers.add("Google Analytics");
|
||||
}
|
||||
if (htmlContent.includes("googletagmanager.com/gtm.js")) {
|
||||
uniqueTrackers.add("Google Tag Manager");
|
||||
}
|
||||
|
||||
// Facebook Pixel
|
||||
if (
|
||||
htmlContent.includes("connect.facebook.net") ||
|
||||
htmlContent.includes("fbq('init'")
|
||||
) {
|
||||
uniqueTrackers.add("Facebook Pixel");
|
||||
}
|
||||
|
||||
// Hotjar
|
||||
if (
|
||||
htmlContent.includes("static.hotjar.com") ||
|
||||
htmlContent.includes("window.hj=window.hj||function()")
|
||||
) {
|
||||
uniqueTrackers.add("Hotjar");
|
||||
}
|
||||
|
||||
// HubSpot
|
||||
if (htmlContent.includes("js.hs-scripts.com")) {
|
||||
uniqueTrackers.add("HubSpot");
|
||||
}
|
||||
|
||||
// Segment
|
||||
if (htmlContent.includes("cdn.segment.com")) {
|
||||
uniqueTrackers.add("Segment");
|
||||
}
|
||||
|
||||
// Mixpanel
|
||||
if (htmlContent.includes("cdn.mxpnl.com")) {
|
||||
uniqueTrackers.add("Mixpanel");
|
||||
}
|
||||
|
||||
// Vercel Analytics
|
||||
if (htmlContent.includes("/_vercel/insights/")) {
|
||||
uniqueTrackers.add("Vercel Analytics");
|
||||
}
|
||||
|
||||
// Plausible
|
||||
if (htmlContent.includes("plausible.io/js/")) {
|
||||
uniqueTrackers.add("Plausible");
|
||||
}
|
||||
|
||||
// Microsoft Clarity
|
||||
if (htmlContent.includes("clarity.ms/tag/")) {
|
||||
uniqueTrackers.add("Microsoft Clarity");
|
||||
}
|
||||
|
||||
uniqueTrackers.forEach((tracker) => {
|
||||
detectedTrackers.push({ name: tracker });
|
||||
});
|
||||
|
||||
return {
|
||||
data: {
|
||||
title,
|
||||
@@ -300,6 +368,7 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
images: imageAltData.length > 0 ? imageAltData : null,
|
||||
links: links.length > 0 ? links : null,
|
||||
systems: detectedSystems.length > 0 ? detectedSystems : null,
|
||||
trackers: detectedTrackers.length > 0 ? detectedTrackers : null,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user