mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
923c522778
fixes https://github.com/TryGhost/Team/issues/2562 New event fetching loops: - Reworked the analytics fetching algorithm. Instead of starting again where we stopped during the last fetching minus 30 minutes, we now just continue where we stopped. But with ms precision (because no longer database dependent after first fetch), and we stop at NOW - 1 minute to reduce chance of missing events. - Apart from that, a missing fetching loop is introduced. This fetches events that are older than 30 minutes, and just processes all events a second time to make sure we didn't skip any because of storage delays in the Mailgun API. - A new scheduled fetching loop, that allows us to schedule between a given start/end date (currently only persisted in memory, so stops after a reboot) UI and endpoint changes: - New UI to show the state of the analytics 'loops' - New endpoint to request the analytics loop status - New endpoint to schedule analytics - New endpoint to cancel scheduled analytics - Some number formatting improvements, and introduction of 'opened' count in debug screen - Live reload of data in the debug screen Other changes: - This also improves the support for maxEvents. We can now stop a fetching loop after x events without worrying about lost events. This is used to reduce the fetched events in the missing and scheduled event loop (e.g. when the main one is fetching lots of events, we skip the other loops). - Prevents fetching the same events over and over again if no new events come in (because we always started at the same begin timestamp). The code increases the begin timestamp with 1 second if it is safe to do so, to prevent the API from returning the same events over and over again. - Some optimisations in handing the processing results (less merges to reduce CPU usage in cases we have lots of events). Testing: - You can test with lots of events using the new mailgun mocking server (Toolbox repo `scripts/mailgun-mock-server`). This can also simulate events that are only returned after x minutes because of storage delays.
65 lines
1.7 KiB
JSON
65 lines
1.7 KiB
JSON
{
|
|
"items": [
|
|
{
|
|
"event": "delivered",
|
|
"recipient": "recipient1@gmail.com",
|
|
"user-variables": {
|
|
"email-id": "5fbe5d9607bdfa3765dc3819"
|
|
},
|
|
"message": {
|
|
"headers": {
|
|
"message-id": "0201125133533.1.C55897076DBD42F2@domain.com"
|
|
}
|
|
},
|
|
"timestamp": 1606399301.266528
|
|
},
|
|
{
|
|
"event": "failed",
|
|
"severity": "temporary",
|
|
"recipient": "recipient2@gmail.com",
|
|
"user-variables": {
|
|
"email-id": "5fbe5d9607bdfa3765dc3819"
|
|
},
|
|
"message": {
|
|
"headers": {
|
|
"message-id": "0201125133533.1.C55897076DBD42F2@domain.com"
|
|
}
|
|
},
|
|
"timestamp": 1606399301.266528
|
|
},
|
|
{
|
|
"event": "failed",
|
|
"severity": "permanent",
|
|
"recipient": "recipient3@gmail.com",
|
|
"user-variables": {
|
|
"email-id": "5fbe5d9607bdfa3765dc3819"
|
|
},
|
|
"message": {
|
|
"headers": {
|
|
"message-id": "0201125133533.1.C55897076DBD42F2@domain.com"
|
|
}
|
|
},
|
|
"timestamp": 1606399301.266528
|
|
},
|
|
{
|
|
"event": "unsubscribed",
|
|
"recipient": "recipient4@gmail.com",
|
|
"user-variables": {
|
|
"email-id": "5fbe5d9607bdfa3765dc3819"
|
|
},
|
|
"message": {
|
|
"headers": {
|
|
"message-id": "0201125133533.1.C55897076DBD42F2@domain.com"
|
|
}
|
|
},
|
|
"timestamp": 1606399301.366528
|
|
}
|
|
],
|
|
"paging": {
|
|
"previous": "https://api.mailgun.net/v3/domain.com/events/all-1-previous",
|
|
"first": "https://api.mailgun.net/v3/domain.com/events/all-1-first",
|
|
"last": "https://api.mailgun.net/v3/domain.com/events/all-1-last",
|
|
"next": "https://api.mailgun.net/v3/domain.com/events/all-1-next"
|
|
}
|
|
}
|