Skip to content
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

fix(events): Ensure Event timestamp is sent as epoch milliseconds #201

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
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: 6 additions & 0 deletions .changeset/moody-lions-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"eppo_core": patch
"ruby-sdk": patch
---

[Unstable] Event Ingestion: Fix JSON serialization of Event timestamp field
11 changes: 9 additions & 2 deletions eppo_core/src/event_ingestion/event.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
use crate::timestamp::Timestamp;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use crate::timestamp::Timestamp;

#[serde_as]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need serde_as if we don't use serde_as attribute below (we're using serde(with))

Suggested change
#[serde_as]

pub(super) struct Event {
pub uuid: uuid::Uuid,

#[serde(with = "chrono::serde::ts_milliseconds")]
pub timestamp: Timestamp,

#[serde(rename = "type")]
pub event_type: String,

pub payload: serde_json::Value,
}
}
2 changes: 1 addition & 1 deletion eppo_core/src/event_ingestion/event_delivery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod tests {
.and(body_json(&json!({
"eppo_events": [{
"uuid": uuid,
"timestamp": timestamp,
"timestamp": timestamp.timestamp_millis(),
"type": "test",
"payload": {
"user_id": "user123",
Expand Down
2 changes: 1 addition & 1 deletion eppo_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ pub mod configuration_fetcher;
pub mod configuration_poller;
pub mod configuration_store;
pub mod eval;
mod sdk_key;
#[cfg(feature = "event_ingestion")]
pub mod event_ingestion;
pub mod events;
Expand All @@ -70,6 +69,7 @@ mod configuration;
mod error;
mod obfuscation;
mod precomputed;
mod sdk_key;
mod sdk_metadata;
mod str;

Expand Down
Loading