Skip to content

Commit

Permalink
Country Code To Snowflake (#20875)
Browse files Browse the repository at this point in the history
Release Notes:

- N/A

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
  • Loading branch information
ConradIrwin and nathansobo authored Nov 19, 2024
1 parent 1c2b3ad commit ea5131c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/collab/src/api/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ pub async fn post_events(
if let Some(kinesis_client) = app.kinesis_client.clone() {
if let Some(stream) = app.config.kinesis_stream.clone() {
let mut request = kinesis_client.put_records().stream_name(stream);
for row in for_snowflake(request_body.clone(), first_event_at) {
for row in for_snowflake(request_body.clone(), first_event_at, country_code.clone()) {
if let Some(data) = serde_json::to_vec(&row).log_err() {
request = request.records(
aws_sdk_kinesis::types::PutRecordsRequestEntry::builder()
Expand Down Expand Up @@ -1381,6 +1381,7 @@ pub fn calculate_json_checksum(app: Arc<AppState>, json: &impl AsRef<[u8]>) -> O
fn for_snowflake(
body: EventRequestBody,
first_event_at: chrono::DateTime<chrono::Utc>,
country_code: Option<String>,
) -> impl Iterator<Item = SnowflakeRow> {
body.events.into_iter().flat_map(move |event| {
let timestamp =
Expand Down Expand Up @@ -1553,6 +1554,9 @@ fn for_snowflake(
body.release_channel.clone().into(),
);
map.insert("signed_in".to_string(), event.signed_in.into());
if let Some(country_code) = country_code.as_ref() {
map.insert("country_code".to_string(), country_code.clone().into());
}
}

let user_properties = Some(serde_json::json!({
Expand Down

0 comments on commit ea5131c

Please sign in to comment.