Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ document
"{{platform.os}}": platformInfo.os || "unknown",
"{{platform.version}}": platformInfo.version,
"{{triggeredAt}}": new Date().toISOString(),
"{{identifier}}": webhook.identifier || ""
"{{identifier}}": webhook.identifier || "",
"{{currentUnixTimestamp}}": Math.floor(Date.now() / 1000),
"{{currentUnixTimestampMiliseconds}}": Date.now(),
"{{currentIsoDate}}": new Date().toISOString().slice(0, 10),
"{{currentIsoDateTime}}": new Date().toISOString(),
};
Comment on lines +178 to 181

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low: For efficiency and consistency, it's better to avoid multiple calls to Date.now() and new Date(). You can get the timestamp and ISO string once and reuse them.

A more efficient way to write this would be to declare now and isoNow variables before the placeholders object.

const now = Date.now();
const isoNow = new Date(now).toISOString();
//...
"{{currentUnixTimestamp}}": Math.floor(now / 1000),
"{{currentUnixTimestampMiliseconds}}": now,
"{{currentIsoDate}}": isoNow.slice(0, 10),
"{{currentIsoDateTime}}": isoNow,

This would require refactoring the surrounding code slightly, but would improve performance and make the code cleaner.


// Replace placeholders in custom payload
Expand Down
Loading