Adding URL for each event, and removing duplicate URL info from "copy" event
parent
3e4a53e8ba
commit
fb3d497aa3
|
@ -59,11 +59,12 @@ browser.storage.sync.get("clientId").then((result) => {
|
|||
|
||||
function createEventJSON(eventType, data) {
|
||||
const timeStamp = new Date().toISOString();
|
||||
const pageUrl = window.location.href;
|
||||
return {
|
||||
"@version": 1,
|
||||
"type": `browserext.${eventType}`,
|
||||
"TimeStamp": timeStamp,
|
||||
"data": {...data, clientId },
|
||||
"data": {...data, clientId, pageUrl},
|
||||
"@timestamp": timeStamp
|
||||
};
|
||||
}
|
||||
|
@ -187,12 +188,11 @@ function navigateWithPromise(href) {
|
|||
|
||||
document.addEventListener("copy", (event) => {
|
||||
const selectedText = window.getSelection().toString();
|
||||
const pageUrl = window.location.href;
|
||||
|
||||
let outputText = selectedText.length > 50 ? selectedText.substring(0, 49) + '…' : selectedText;
|
||||
|
||||
if (selectedText.length > 0) {
|
||||
const eventData = createEventJSON('copy', { selectedText: outputText, pageUrl, description: "Скопирован текст" });
|
||||
const eventData = createEventJSON('copy', { selectedText: outputText, description: "Скопирован текст" });
|
||||
console.log("Событие copy:", JSON.stringify(eventData));
|
||||
sendDataToServer(eventData);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue