MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / track

Method track

src/segment/src/lib.rs:110–142  ·  view source on GitHub ↗

Sends a new [track event] to Segment. Delivery happens asynchronously on a background thread. It is best effort. There is no guarantee that the event will be delivered to Segment. Events may be dropped when the client is backlogged. Errors are logged but not returned. [track event]: https://segment.com/docs/connections/spec/track/

(
        &self,
        user_id: Uuid,
        event: S,
        properties: serde_json::Value,
        context: Option<serde_json::Value>,
        timestamp: Option<DateTime<Utc>>,
    )

Source from the content-addressed store, hash-verified

108 ///
109 /// [track event]: https://segment.com/docs/connections/spec/track/
110 pub fn track<S>(
111 &self,
112 user_id: Uuid,
113 event: S,
114 properties: serde_json::Value,
115 context: Option<serde_json::Value>,
116 timestamp: Option<DateTime<Utc>>,
117 ) where
118 S: Into<String>,
119 {
120 let timestamp = match timestamp {
121 None => None,
122 Some(t) => match OffsetDateTime::from_unix_timestamp(t.timestamp())
123 .and_then(|odt| odt.replace_nanosecond(t.timestamp_subsec_nanos()))
124 {
125 Ok(timestamp) => Some(timestamp),
126 Err(e) => {
127 error!(%e, "failed to convert timestamp for Segment event");
128 return;
129 }
130 },
131 };
132 self.send(BatchMessage::Track(Track {
133 user: User::UserId {
134 user_id: user_id.to_string(),
135 },
136 event: event.into(),
137 properties,
138 context,
139 timestamp,
140 ..Default::default()
141 }));
142 }
143
144 /// Sends a new [group event] to Segment.
145 ///

Callers 2

segment.tsFile · 0.80
environment_trackMethod · 0.80

Calls 3

timestampMethod · 0.45
sendMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected