Skip to content
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
2 changes: 1 addition & 1 deletion svc/pkg/team/worker/src/workers/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ async fn worker(ctx: &OperationContext<team::msg::create::Message>) -> GlobalRes
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.create".into(),
user_id: ctx.owner_user_id,
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"user_id": owner_user_id,
}))?),
..Default::default()
},
Expand Down
4 changes: 2 additions & 2 deletions svc/pkg/team/worker/src/workers/join_request_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ async fn fail(
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.join_request.create_fail".into(),
user_id: Some(user_id.into()),
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"error": error_code as i32,
"user_id": user_id,
}))?),
..Default::default()
}
Expand Down Expand Up @@ -87,9 +87,9 @@ async fn worker(
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.join_request.create".into(),
user_id: ctx.user_id,
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"user_id": user_id,
}))?),
..Default::default()
}
Expand Down
2 changes: 1 addition & 1 deletion svc/pkg/team/worker/src/workers/join_request_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ async fn worker(
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.join_request.resolve".into(),
user_id: Some(user_id.into()),
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"user_id": user_id,
}))?),
..Default::default()
}
Expand Down
4 changes: 2 additions & 2 deletions svc/pkg/team/worker/src/workers/member_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ async fn worker(ctx: &OperationContext<team::msg::member_create::Message>) -> Gl
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.member.create".into(),
user_id: Some(user_id.into()),
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"user_id": user_id,
}))?),
..Default::default()
}
Expand Down Expand Up @@ -127,11 +127,11 @@ async fn fail(
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.invite.consume_fail".into(),
user_id: Some(user_id.into()),
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"code": invitation.code,
"error": invite_error_code as i32,
"user_id": user_id,
}))?),
..Default::default()
}
Expand Down
17 changes: 12 additions & 5 deletions svc/pkg/team/worker/src/workers/member_kick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ async fn worker(ctx: &OperationContext<team::msg::member_kick::Message>) -> Glob

msg!([ctx] team::msg::member_kick_complete(team_id, user_id) { }).await?;

let mut properties = json!({
"team_id": team_id,
"kick_user_id": user_id,
});

if let Some(kicker_user_id) = ctx.kicker_user_id {
properties["user_id"] = json!(kicker_user_id.to_string());
}

let properties_json = Some(serde_json::to_string(&properties)?);

msg!([ctx] analytics::msg::event_create() {
events: vec![
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.member.kick".into(),
user_id: ctx.kicker_user_id,
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"kick_user_id": user_id,
}))?),
properties_json,
..Default::default()
}
],
Expand Down
2 changes: 1 addition & 1 deletion svc/pkg/team/worker/src/workers/member_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ async fn worker(ctx: &OperationContext<team::msg::member_remove::Message>) -> Gl
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.member.remove".into(),
user_id: Some(user_id.into()),
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"user_id": user_id,
}))?),
..Default::default()
}
Expand Down
17 changes: 12 additions & 5 deletions svc/pkg/team/worker/src/workers/user_ban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,23 @@ async fn worker(ctx: &OperationContext<team::msg::user_ban::Message>) -> GlobalR
})
.await?;

let mut properties = json!({
"team_id": team_id,
"ban_user_id": user_id,
});

if let Some(banner_user_id) = ctx.banner_user_id {
properties["user_id"] = json!(banner_user_id.to_string());
}

let properties_json = Some(serde_json::to_string(&properties)?);

msg!([ctx] analytics::msg::event_create() {
events: vec![
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.user.ban".into(),
user_id: ctx.banner_user_id,
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"banned_user_id": user_id,
}))?),
properties_json,
..Default::default()
}
],
Expand Down
17 changes: 12 additions & 5 deletions svc/pkg/team/worker/src/workers/user_unban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@ async fn worker(ctx: &OperationContext<team::msg::user_unban::Message>) -> Globa
})
.await?;

let mut properties = json!({
"team_id": team_id,
"unban_user_id": user_id,
});

if let Some(unbanner_user_id) = ctx.unbanner_user_id {
properties["user_id"] = json!(unbanner_user_id.to_string());
}

let properties_json = Some(serde_json::to_string(&properties)?);

msg!([ctx] analytics::msg::event_create() {
events: vec![
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "team.user.unban".into(),
user_id: ctx.unbanner_user_id,
properties_json: Some(serde_json::to_string(&json!({
"team_id": team_id,
"unban_user_id": user_id,
}))?),
properties_json,
..Default::default()
}
],
Expand Down
4 changes: 2 additions & 2 deletions svc/pkg/user-follow/ops/toggle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ async fn handle(
events: vec![ analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user_follow.create".into(),
user_id: Some(follower_user_id.into()),
properties_json: Some(serde_json::to_string(&json!({
"follower": follower_user_id,
"following": following_user_id,
"became_mutual": mutual,
"user_id": follower_user_id,
}))?),
..Default::default()
} ],
Expand Down Expand Up @@ -125,11 +125,11 @@ async fn handle(
events: vec![analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user_follow.delete".into(),
user_id: Some(follower_user_id.into()),
properties_json: Some(serde_json::to_string(&json!({
"follower": follower_user_id,
"following": following_user_id,
"was_mutual": mutual,
"user_id": follower_user_id,
}))?),
..Default::default()
}],
Expand Down
6 changes: 2 additions & 4 deletions svc/pkg/user-identity/ops/create/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ async fn handle(
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user_identity.create".into(),
user_id: Some(user_id.into()),
namespace_id: None,
properties_json: Some(serde_json::to_string(&json!({
"identity_email": email.email,
"user_id": user_id,
}))?),
..Default::default()
}
Expand All @@ -61,10 +60,9 @@ async fn handle(
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user_identity.create".into(),
user_id: Some(user_id.into()),
namespace_id: None,
properties_json: Some(serde_json::to_string(&json!({
"identity_access_token": access_token.name,
"user_id": user_id,
}))?),
..Default::default()
}
Expand Down
5 changes: 4 additions & 1 deletion svc/pkg/user/ops/avatar-upload-complete/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use proto::backend::pkg::*;
use rivet_operation::prelude::*;
use serde_json::json;

#[operation(name = "user-avatar-upload-complete")]
async fn handle(
Expand Down Expand Up @@ -38,7 +39,9 @@ async fn handle(
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user.avatar_set".into(),
user_id: Some(user_id.into()),
properties_json: Some(serde_json::to_string(&json!({
"user_id": user_id,
}))?),
..Default::default()
}
],
Expand Down
18 changes: 12 additions & 6 deletions svc/pkg/user/worker/src/workers/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,28 @@ async fn worker(ctx: &OperationContext<user::msg::create::Message>) -> GlobalRes
})
.await?;

let mut properties = json!({
"user_id": user_id,
});

if let Some(display_name) = display_name {
properties["display_name"] = json!(display_name);
}

let properties_json = Some(serde_json::to_string(&properties)?);

msg!([ctx] analytics::msg::event_create() {
events: vec![
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user.create".into(),
user_id: Some(user_id.into()),
namespace_id: ctx.namespace_id,
properties_json: Some(serde_json::to_string(&json!({
}))?),
properties_json: properties_json.clone(),
..Default::default()
},
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user.profile_set".into(),
user_id: Some(user_id.into()),
namespace_id: ctx.namespace_id,
properties_json,
..Default::default()
},
],
Expand Down
2 changes: 0 additions & 2 deletions svc/pkg/user/worker/src/workers/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ async fn worker(ctx: &OperationContext<user::msg::delete::Message>) -> GlobalRes
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user.delete".into(),
user_id: None,
namespace_id: None,
properties_json: Some(serde_json::to_string(&json!({
"deleted_user_id": user_id
}))?),
Expand Down
5 changes: 4 additions & 1 deletion svc/pkg/user/worker/src/workers/profile_set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use chirp_worker::prelude::*;
use proto::backend::pkg::*;
use serde_json::json;

#[worker(name = "user-profile-set")]
async fn worker(ctx: &OperationContext<user::msg::profile_set::Message>) -> GlobalResult<()> {
Expand Down Expand Up @@ -92,7 +93,9 @@ async fn worker(ctx: &OperationContext<user::msg::profile_set::Message>) -> Glob
analytics::msg::event_create::Event {
event_id: Some(Uuid::new_v4().into()),
name: "user.profile_set".into(),
user_id: Some(*user_id),
properties_json: Some(serde_json::to_string(&json!({
"user_id": user_id.to_string()
}))?),
..Default::default()
},
],
Expand Down