<commit_before>import maybeLogPageVisit from './log-page-visit'

// Listen for navigations to log them and analyse the pages.
browser.webNavigation.onCommitted.addListener(({url, tabId, frameId}) => {
    // Ignore pages loaded in frames, it is usually noise.
    if (frameId !== 0) {
        return
    }

    maybeLogPageVisit({url, tabId})
})<commit_msg>Fixes indexing of web apps.<commit_after>import maybeLogPageVisit from './log-page-visit'
import debounce from 'lodash/debounce'

// Debounced functions fro each tab are stored here
const tabs = {}

// Listens for url changes of the page
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
    if (changeInfo.url && tab.url) {
        // Check if we already have a debounced function for this tab and cancel it
        if (tabs[tabId]) tabs[tabId].cancel()

        // Create debounced function and call it
        tabs[tabId] = debounce(() => maybeLogPageVisit({url: tab.url, tabId: tabId}), 10000)
        tabs[tabId]()
    }
})
{'fraction_non_alphanumeric': 0.119, 'fraction_numerical': 0.006, 'mean_word_length': 3.3521739130434782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '962119', 'n_tokens_mistral': 315, 'n_tokens_neox': 294, 'n_words': 98}