[dyad] Improved tracking ID detection with more flexible patterns - wrote 1 file(s)

This commit is contained in:
[dyad]
2026-01-21 08:11:17 +01:00
parent 28f5b5bc54
commit 9c9ecf5050

View File

@@ -323,7 +323,9 @@ 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+)'\)/); const fbIdMatch = htmlContent.match(
/fbq\(\s*['"]init['"]\s*,\s*['"](\d+)['"]\s*\)/
);
addTracker("Facebook Pixel", fbIdMatch ? fbIdMatch[1] : null); addTracker("Facebook Pixel", fbIdMatch ? fbIdMatch[1] : null);
} }
@@ -332,7 +334,7 @@ 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+)/); const hjIdMatch = htmlContent.match(/hjid\s*:\s*(\d+)/);
addTracker("Hotjar", hjIdMatch ? hjIdMatch[1] : null); addTracker("Hotjar", hjIdMatch ? hjIdMatch[1] : null);
} }
@@ -344,13 +346,17 @@ export async function extractMetaData(url: string, keyword?: string) {
// Segment // Segment
if (htmlContent.includes("cdn.segment.com")) { if (htmlContent.includes("cdn.segment.com")) {
const segmentIdMatch = htmlContent.match(/analytics\.load\("([^"]+)"\)/); const segmentIdMatch = htmlContent.match(
/analytics\.load\(\s*['"]([^"']+)['"]\s*\)/
);
addTracker("Segment", segmentIdMatch ? segmentIdMatch[1] : null); 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\("([^"]+)"\)/); const mixpanelIdMatch = htmlContent.match(
/mixpanel\.init\(\s*['"]([^"']+)['"]\s*\)/
);
addTracker("Mixpanel", mixpanelIdMatch ? mixpanelIdMatch[1] : null); addTracker("Mixpanel", mixpanelIdMatch ? mixpanelIdMatch[1] : null);
} }
@@ -361,7 +367,9 @@ export async function extractMetaData(url: string, keyword?: string) {
// Plausible // Plausible
if (htmlContent.includes("plausible.io/js/")) { if (htmlContent.includes("plausible.io/js/")) {
const plausibleDomainMatch = htmlContent.match(/data-domain="([^"]+)"/); const plausibleDomainMatch = htmlContent.match(
/data-domain\s*=\s*['"]([^"']+)['"]/
);
addTracker( addTracker(
"Plausible", "Plausible",
plausibleDomainMatch ? plausibleDomainMatch[1] : null plausibleDomainMatch ? plausibleDomainMatch[1] : null