perf(api-server): batch route tracking through local outbox
This commit is contained in:
@@ -585,6 +585,35 @@ impl SpacetimeClient {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn record_tracking_events(
|
||||
&self,
|
||||
events: Vec<module_runtime::RuntimeTrackingEventInput>,
|
||||
) -> Result<u32, SpacetimeClientError> {
|
||||
if events.is_empty() {
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
let procedure_inputs = events
|
||||
.into_iter()
|
||||
.map(crate::module_bindings::RuntimeTrackingEventInput::from)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
self.call_after_connect(
|
||||
"record_tracking_events_and_return",
|
||||
move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.record_tracking_events_and_return_then(procedure_inputs, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(SpacetimeClientError::from_sdk_error)
|
||||
.and_then(map_runtime_tracking_event_batch_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_profile_task_center(
|
||||
&self,
|
||||
user_id: String,
|
||||
|
||||
Reference in New Issue
Block a user