Recording clicks and keystrokes to a csv

I’m attempting to make a Chrome extension that records the number of clicks, keystrokes, and time spent within a certain period of time on a given website (e.g., 45 clicks, 296 keystrokes, and 129 minutes spent on Facebook within one week). I’ve never coded before and the course I’m writing this code for did not cover Chrome extensions.

So far, I’ve figured out how to make a simple message appear in the console log when I click the webpage (code given below), but that’s about it. How would I export the number of clicks to a .csv?

manifest.json

    "name": "Social Media Consumption Tracker",
    "version": "1.0",
    "manifest_version": 2,
    "content_scripts": [
        {
            "matches": ["https://www.facebook.com/*",
            "http://www.facebook.com/*"],
            "js": ["content.js"]
        }
    ],
  "permissions": ["tabs"]
}

content.js

document.addEventListener("click", e=> {
    console.log("Hey there")
})

Thank you in advance for your help.