1-- session_stats.lua
2-- Tracks emails received, read, and sent during your session.
3
4local matcha = require("matcha")
5
6local stats = { received = 0, read = 0, sent = 0 }
7
8matcha.on("email_received", function(email)
9 stats.received = stats.received + 1
10end)
11
12matcha.on("email_viewed", function(email)
13 stats.read = stats.read + 1
14end)
15
16matcha.on("email_send_after", function()
17 stats.sent = stats.sent + 1
18end)
19
20matcha.on("shutdown", function()
21 matcha.log("Session stats: "
22 .. stats.received .. " received, "
23 .. stats.read .. " read, "
24 .. stats.sent .. " sent")
25end)