move sendEventAsync define to util.js

This commit is contained in:
qcrao
2024-07-25 15:33:23 +08:00
parent 88eab68058
commit 123524c629
2 changed files with 33 additions and 33 deletions

View File

@@ -130,37 +130,4 @@ async function waitForElementToDisappear(selector, timeout = 2000) {
throw new Error(`Element ${selector} did not disappear within ${timeout}ms`); throw new Error(`Element ${selector} did not disappear within ${timeout}ms`);
} }
async function sendEventAsync(count) {
try {
const userInfo = await getUserInfo();
const timestamp = new Date().toISOString().replace("T", " ").substr(0, 19);
const data = {
user_id: userInfo.id || "unknown",
timestamp: timestamp,
action: "delete",
count: count,
};
const response = await fetch(
"https://bulk-delete-chatgpt-worker.qcrao.com/send-event",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
}
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
console.log("Event sent successfully");
} catch (error) {
console.error("Error sending event:", error);
}
}
bulkDeleteConversations(); bulkDeleteConversations();

View File

@@ -12,3 +12,36 @@ function getUserInfo() {
}); });
}); });
} }
async function sendEventAsync(count) {
try {
const userInfo = await getUserInfo();
const timestamp = new Date().toISOString().replace("T", " ").substr(0, 19);
const data = {
user_id: userInfo.id || "unknown",
timestamp: timestamp,
action: "delete",
count: count,
};
const response = await fetch(
"https://bulk-delete-chatgpt-worker.qcrao.com/send-event",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
}
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
console.log("Event sent successfully");
} catch (error) {
console.error("Error sending event:", error);
}
}