-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplemented email analytics prioritizing email opens #20914
Conversation
This reverts commit ae15e12.
If we conservatively (somewhat) figure ~2500 events/min, and that the job is on a 5min cron, we should try to keep the loop cycle to ~5 mins or less in order to repeat the fetch logic, which now prioritizes opens. Open data is the only data to update any stats, so we want to make sure if people are pressing refresh that we do our best to keep it up to date. Meanwhile, if we don't find opens, we can move on to filling in the other event data, collecting missed events, and scheduled backfills, in that order.
This effectively forces the jobs to fetch the last run timestamps to set in the db, because this was previously implemented for a period and we didn't null these values when reverting that commit.
…usly with handles reboots to ensure we re-fetch every event to capture missing events
It looks like this PR contains a migration 👀 General requirements
Schema changes
Data changes
|
I'm thinking we may want to include some sort of backstop for the |
- updated batch data to aggregate to one message with timings - updated aggregate queries to log times so we don't need to calculate it - removed trying to run aggregation when we don't have any events, which led to extra logging and is unnecessary The logging in general is quite verbose and more like debug logs. I'm good with that for the moment while we're working on this, but we can still be a bit more concise.
Maybe a silly idea, but could we use a new name for the job, so it wouldn't even look at the same rows if the migration doesn't run/fails for some reason? Maybe we could introduce a concept of job version, so the rows would become e.g. |
While that does work, I don't see a need to version and that makes future migrations to try and clear this out extra messy. I'd personally rather avoid that. |
ghost/core/core/server/services/email-analytics/EmailAnalyticsServiceWrapper.js
Show resolved
Hide resolved
...core/server/data/migrations/versions/5.93/2024-09-03-20-09-40-null-analytics-jobs-timings.js
Outdated
Show resolved
Hide resolved
...core/server/data/migrations/versions/5.93/2024-09-03-20-09-40-null-analytics-jobs-timings.js
Outdated
Show resolved
Hide resolved
I think I'm missing something here, maybe you can help me understand. I'm not sure I see how this avoids us missing events with As I understand this logic, if we fetch 10k opened events, we'll stop there and wait for the job to kick off again. If we end up fetching 10k opened events for a couple iterations in a row, couldn't we fall behind on Again, I'm probably just confused! Maybe we can get on a call tomorrow AM to go over it 😃 |
ghost/core/core/server/services/email-analytics/EmailAnalyticsServiceWrapper.js
Show resolved
Hide resolved
These call the aggregateStats query. There was a bug in the second email set, which was set to a count of 6 but has no fixture data for email recipients, so it was false. This should not be a fixed field but probably dynamic... though this part of the code base is a bit fraught as it is, and I'm reluctant to touch anything in this context.
...core/server/data/migrations/versions/5.94/2024-09-03-20-09-40-null-analytics-jobs-timings.js
Outdated
Show resolved
Hide resolved
…3-20-09-40-null-analytics-jobs-timings.js Co-authored-by: Daniel Lockyer <[email protected]>
ref #20835
We learned a few things with the previous trial run of this. Namely, that event throughput is not as high as we initially saw in the data for particularly large databases. This set of changes is more conservative, while a touch more complicated, in ensuring we capture edge cases for really large newsletter sends (100k+ members).
In general, we want to make sure we're fetching new open events at least every 5 mins, and often much faster than that, unless it's a quiet period (suggesting we haven't had a newsletter send or much outstanding event data).