1import { Controller } from "@hotwired/stimulus"; 2 3export default class extends Controller { 4 static targets = ["searchInput"]; 5 static values = { 6 delay: { type: Number, default: 1000 }, // Delay before tracking search 7 }; 8 9 connect() { 10 this.searchTimeout = null; 11 } 12 13 trackSearch(event) { 14 const query = event.target.value.trim(); 15 16 // Clear any existing timeout 17 clearTimeout(this.searchTimeout); 18 19 // Only track if there's a query 20 if (query.length > 0) { 21 this.searchTimeout = setTimeout(() => { 22 if (typeof fathom !== "undefined") { 23 fathom.trackEvent("component search"); 24 } 25 26 // Track with PostHog 27 if (typeof posthog !== "undefined") { 28 posthog.capture("component search", { 29 query: query, 30 query_length: query.length, 31 }); 32 } 33 }, this.delayValue); 34 } 35 } 36};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.