refactor sendEventAsync, add action parameters
This commit is contained in:
@@ -11,6 +11,8 @@ async function bulkArchiveConversations() {
|
|||||||
|
|
||||||
console.log("Selected Conversations:", selectedConversations);
|
console.log("Selected Conversations:", selectedConversations);
|
||||||
|
|
||||||
|
sendEventAsync("archive", selectedConversations.length);
|
||||||
|
|
||||||
for (const element of selectedConversations) {
|
for (const element of selectedConversations) {
|
||||||
await archiveConversation(element);
|
await archiveConversation(element);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ async function bulkDeleteConversations() {
|
|||||||
|
|
||||||
console.log("Selected Conversations:", selectedConversations.length);
|
console.log("Selected Conversations:", selectedConversations.length);
|
||||||
|
|
||||||
sendEventAsync(selectedConversations.length);
|
sendEventAsync("delete", selectedConversations.length);
|
||||||
|
|
||||||
for (let i = 0; i < selectedConversations.length; i++) {
|
for (let i = 0; i < selectedConversations.length; i++) {
|
||||||
await deleteConversation(selectedConversations[i]);
|
await deleteConversation(selectedConversations[i]);
|
||||||
|
|||||||
8
utils.js
8
utils.js
@@ -13,7 +13,7 @@ function getUserInfo() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendEventAsync(count) {
|
async function sendEventAsync(action, count) {
|
||||||
try {
|
try {
|
||||||
const userInfo = await getUserInfo();
|
const userInfo = await getUserInfo();
|
||||||
const timestamp = new Date().toISOString().replace("T", " ").substr(0, 19);
|
const timestamp = new Date().toISOString().replace("T", " ").substr(0, 19);
|
||||||
@@ -21,7 +21,7 @@ async function sendEventAsync(count) {
|
|||||||
const data = {
|
const data = {
|
||||||
user_id: userInfo.id || "unknown",
|
user_id: userInfo.id || "unknown",
|
||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
action: "delete",
|
action: action,
|
||||||
count: count,
|
count: count,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,8 +40,8 @@ async function sendEventAsync(count) {
|
|||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Event sent successfully");
|
console.log(`Event '${action}' sent successfully`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error sending event:", error);
|
console.error(`Error sending '${action}' event:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user