1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// this file is @generated
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct Event {
/// Billable metric code. Max 512 characters.
pub code: String,
/// Meteroid customer ID or external customer alias.
pub customer_id: String,
/// Unique event identifier. Max 255 characters. A UUID or ULID is recommended.
pub event_id: String,
/// Arbitrary string key-value pairs used by billable metrics for filtering and aggregation.
#[serde(skip_serializing_if = "Option::is_none")]
pub properties: Option<std::collections::HashMap<String, String>>,
/// RFC 3339 timestamp. Defaults to ingestion time if omitted.
/// Must be between 24 hours ago and 1 hour from now. Set `allow_backfilling` to remove the past limit.
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
/// Properties this version of the SDK does not know, sent back as received.
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
impl Event {
/// Creates a value from its required fields.
#[must_use]
pub fn new(
code: impl Into<String>,
customer_id: impl Into<String>,
event_id: impl Into<String>,
) -> Self {
Self {
code: code.into(),
customer_id: customer_id.into(),
event_id: event_id.into(),
properties: None,
timestamp: None,
extra: serde_json::Map::new(),
}
}
/// Sets `properties`.
#[must_use]
pub fn properties(
mut self,
properties: impl Into<std::collections::HashMap<String, String>>,
) -> Self {
self.properties = Some(properties.into());
self
}
/// Sets `timestamp`.
#[must_use]
pub fn timestamp(mut self, timestamp: impl Into<chrono::DateTime<chrono::Utc>>) -> Self {
self.timestamp = Some(timestamp.into());
self
}
}