5001: Do not send empty edit document by function r=Kerollmops a=irevoire

# Pull Request

We realized that we had a huge usage of the feature from user who didn’t enable the feature at all. That shouldn’t be possible.
After a big investigation with `@gmourier` 
![image](https://github.com/user-attachments/assets/eae3e851-dc5b-4616-80ee-7237a4871522)
We found the issue, it was in the engine

## What does this PR do?
- Do not send the edit by function event to segment if no event was received during this batch

Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
meili-bors[bot] 2024-10-11 08:27:16 +00:00 committed by GitHub
commit a90563df3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1572,6 +1572,10 @@ impl EditDocumentsByFunctionAggregator {
pub fn into_event(self, user: &User, event_name: &str) -> Option<Track> { pub fn into_event(self, user: &User, event_name: &str) -> Option<Track> {
let Self { timestamp, user_agents, index_creation, filtered, with_context } = self; let Self { timestamp, user_agents, index_creation, filtered, with_context } = self;
// if we had no timestamp it means we never encountered any events and
// thus we don't need to send this event.
let timestamp = timestamp?;
let properties = json!({ let properties = json!({
"user-agent": user_agents, "user-agent": user_agents,
"filtered": filtered, "filtered": filtered,
@ -1580,7 +1584,7 @@ impl EditDocumentsByFunctionAggregator {
}); });
Some(Track { Some(Track {
timestamp, timestamp: Some(timestamp),
user: user.clone(), user: user.clone(),
event: event_name.to_string(), event: event_name.to_string(),
properties, properties,