diff --git a/gen/secrets.baseline.json b/gen/secrets.baseline.json index a140b8b84d..7bd8626248 100644 --- a/gen/secrets.baseline.json +++ b/gen/secrets.baseline.json @@ -79,6 +79,10 @@ "path": "detect_secrets.filters.common.is_baseline_file", "filename": "gen/secrets.baseline.json" }, + { + "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", + "min_level": 2 + }, { "path": "detect_secrets.filters.gibberish.should_exclude_secret", "limit": 3.7 @@ -186,7 +190,7 @@ "filename": "svc/pkg/email-verification/ops/create/src/lib.rs", "hashed_secret": "670988a3ad6d12dc80cb21cf98d44dd470e653d1", "is_verified": false, - "line_number": 107 + "line_number": 108 } ], "svc/pkg/telemetry/standalone/beacon/src/lib.rs": [ @@ -199,5 +203,5 @@ } ] }, - "generated_at": "2023-11-09T20:53:32Z" + "generated_at": "2024-01-08T08:54:04Z" } diff --git a/lib/global-error/src/error.rs b/lib/global-error/src/error.rs index 5a81641913..3a40d0d1ca 100644 --- a/lib/global-error/src/error.rs +++ b/lib/global-error/src/error.rs @@ -125,7 +125,9 @@ impl GlobalError { pub fn documentation(&self) -> Option<&str> { match self { GlobalError::Internal { .. } => None, - GlobalError::BadRequest { code, .. } => Some(formatted_error::parse(code).documentation()), + GlobalError::BadRequest { code, .. } => { + Some(formatted_error::parse(code).documentation()) + } } } @@ -162,11 +164,7 @@ impl From for chirp::response::Err { retry_immediately: _, } => chirp::response::Err { kind: Some(chirp::response::err::Kind::Internal( - chirp::response::err::Internal { - ty, - message, - debug, - }, + chirp::response::err::Internal { ty, message, debug }, )), }, GlobalError::BadRequest { diff --git a/svc/Cargo.lock b/svc/Cargo.lock index b664f81caa..22a8637aa2 100644 --- a/svc/Cargo.lock +++ b/svc/Cargo.lock @@ -56,24 +56,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" -[[package]] -name = "analytics-worker" -version = "0.0.1" -dependencies = [ - "chirp-client", - "chirp-worker", - "clickhouse", - "faker-game", - "faker-user", - "lazy_static", - "prost 0.10.4", - "rivet-health-checks", - "rivet-metrics", - "rivet-runtime", - "serde", - "user-presence-get", -] - [[package]] name = "android-tzdata" version = "0.1.1" @@ -5268,7 +5250,6 @@ dependencies = [ name = "monolith-worker" version = "0.0.1" dependencies = [ - "analytics-worker", "cdn-worker", "cf-custom-hostname-worker", "chirp-client", diff --git a/svc/Cargo.toml b/svc/Cargo.toml index 83a665f276..aa41e7c86d 100644 --- a/svc/Cargo.toml +++ b/svc/Cargo.toml @@ -16,7 +16,6 @@ members = [ "api/portal", "api/route", "api/status", - "pkg/analytics/worker", "pkg/build/ops/create", "pkg/build/ops/get", "pkg/build/ops/list-for-game", diff --git a/svc/pkg/analytics/db/analytics/Service.toml b/svc/pkg/analytics/db/analytics/Service.toml deleted file mode 100644 index 229d2a9694..0000000000 --- a/svc/pkg/analytics/db/analytics/Service.toml +++ /dev/null @@ -1,7 +0,0 @@ -[service] -name = "db-analytics" - -[runtime] -kind = "clickhouse" - -[database] diff --git a/svc/pkg/analytics/db/analytics/migrations/20200101000000_init.down.sql b/svc/pkg/analytics/db/analytics/migrations/20200101000000_init.down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/svc/pkg/analytics/db/analytics/migrations/20200101000000_init.up.sql b/svc/pkg/analytics/db/analytics/migrations/20200101000000_init.up.sql deleted file mode 100644 index 04f7e4b318..0000000000 --- a/svc/pkg/analytics/db/analytics/migrations/20200101000000_init.up.sql +++ /dev/null @@ -1,13 +0,0 @@ -SET allow_experimental_object_type = 1; - -CREATE TABLE events ( - event_id UUID, - ray_id UUID, - ts DateTime64(3), - name LowCardinality(String), - properties JSON DEFAULT properties_raw, - properties_raw String EPHEMERAL -) ENGINE = ReplicatedReplacingMergeTree -PARTITION BY toYYYYMM(ts) -SAMPLE BY cityHash64(event_id) -ORDER BY (toDate(ts), name, cityHash64(event_id)); diff --git a/svc/pkg/analytics/types/msg/event-create.proto b/svc/pkg/analytics/types/msg/event-create.proto index 95e4fb9729..f5e3e2d553 100644 --- a/svc/pkg/analytics/types/msg/event-create.proto +++ b/svc/pkg/analytics/types/msg/event-create.proto @@ -13,6 +13,9 @@ message Message { message Event { reserved 5, 6, 7, 8; + // ID of event. This is used as the primary key in ClickHouse for deduplication. + rivet.common.Uuid event_id = 10; + // Override the timestamp the event was emitted at. optional int64 ts = 9; diff --git a/svc/pkg/analytics/worker/Cargo.toml b/svc/pkg/analytics/worker/Cargo.toml deleted file mode 100644 index 6404adc813..0000000000 --- a/svc/pkg/analytics/worker/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "analytics-worker" -version = "0.0.1" -edition = "2018" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -chirp-worker = { path = "../../../../lib/chirp/worker" } -chirp-client = { path = "../../../../lib/chirp/client" } -clickhouse = { version = "0.11.2", features = ["wa-37420", "uuid"] } -lazy_static = "1.4.0" -prost = "0.10" -rivet-health-checks = { path = "../../../../lib/health-checks" } -rivet-metrics = { path = "../../../../lib/metrics" } -rivet-runtime = { path = "../../../../lib/runtime" } -serde = { version = "1.0", features = ["derive"] } - -user-presence-get = { path = "../../user-presence/ops/get" } - -[dev-dependencies] -chirp-worker = { path = "../../../../lib/chirp/worker" } - -faker-user = { path = "../../faker/ops/user" } -faker-game = { path = "../../faker/ops/game" } diff --git a/svc/pkg/analytics/worker/Service.toml b/svc/pkg/analytics/worker/Service.toml deleted file mode 100644 index 3c77681a65..0000000000 --- a/svc/pkg/analytics/worker/Service.toml +++ /dev/null @@ -1,13 +0,0 @@ -[service] -name = "analytics-worker" - -[runtime] -kind = "rust" - -[consumer] - -[secrets] -"clickhouse/users/chirp/password" = {} - -[databases] -db-analytics = {} diff --git a/svc/pkg/analytics/worker/src/lib.rs b/svc/pkg/analytics/worker/src/lib.rs deleted file mode 100644 index 3719b10aa8..0000000000 --- a/svc/pkg/analytics/worker/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod workers; diff --git a/svc/pkg/analytics/worker/src/workers/event_create.rs b/svc/pkg/analytics/worker/src/workers/event_create.rs deleted file mode 100644 index f61e7af85c..0000000000 --- a/svc/pkg/analytics/worker/src/workers/event_create.rs +++ /dev/null @@ -1,91 +0,0 @@ -use chirp_worker::prelude::*; -use proto::backend::{self, pkg::*}; -use serde_json::json; -use std::collections::{HashMap, HashSet}; - -#[derive(clickhouse::Row, serde::Serialize, Debug)] -struct Event { - ts: i64, - #[serde(with = "clickhouse::serde::uuid")] - event_id: Uuid, - #[serde(with = "clickhouse::serde::uuid")] - ray_id: Uuid, - name: String, - properties_raw: String, -} - -#[worker(name = "analytics-event-create")] -async fn worker(ctx: &OperationContext) -> GlobalResult<()> { - let ray_id = ctx.ray_id(); - - let client = rivet_pools::utils::clickhouse::client()? - .with_user("chirp") - .with_password(util::env::read_secret(&["clickhouse", "users", "chirp", "password"]).await?) - .with_database("db_analytics"); - - let user_ids_proto = ctx - .events - .iter() - .flat_map(|x| x.user_id) - .map(|x| x.as_uuid()) - .collect::>() - .into_iter() - .map(Into::::into) - .collect::>(); - - // Build events - let mut insert = client.insert("events")?; - for req_event in &ctx.events { - let event = build_event(req_event.ts.unwrap_or(ctx.ts()), ray_id, req_event)?; - insert.write(&event).await?; - } - insert.end().await?; - - Ok(()) -} - -fn build_event( - ts: i64, - ray_id: Uuid, - req_event: &analytics::msg::event_create::Event, -) -> GlobalResult { - let mut properties = HashMap::>::new(); - - // Insert provided properties - if let Some(properties_json) = &req_event.properties_json { - let req_properties = serde_json::from_str::< - HashMap>, - >(properties_json)?; - properties.extend(req_properties.into_iter()); - } - - // Insert common legacy properties - if let Some(user_id) = req_event.user_id { - serialize_prop(&mut properties, "user_id", user_id.as_uuid())?; - } - if let Some(ns_id) = req_event.namespace_id { - serialize_prop(&mut properties, "namespace_id", ns_id.as_uuid())?; - } - - Ok(Event { - ts, - // TODO: Pass the event ID when the analytics event is created to - // prevent dupes - event_id: Uuid::new_v4(), - ray_id, - name: req_event.name.clone(), - properties_raw: serde_json::to_string(&properties)?, - }) -} - -fn serialize_prop( - properties: &mut HashMap>, - key: impl ToString, - value: impl serde::Serialize, -) -> GlobalResult<()> { - properties.insert( - key.to_string(), - serde_json::value::RawValue::from_string(serde_json::to_string(&value)?)?, - ); - Ok(()) -} diff --git a/svc/pkg/analytics/worker/src/workers/mod.rs b/svc/pkg/analytics/worker/src/workers/mod.rs deleted file mode 100644 index 5253d6438b..0000000000 --- a/svc/pkg/analytics/worker/src/workers/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod event_create; - -chirp_worker::workers![event_create,]; diff --git a/svc/pkg/analytics/worker/tests/event_create.rs b/svc/pkg/analytics/worker/tests/event_create.rs deleted file mode 100644 index 54bec86356..0000000000 --- a/svc/pkg/analytics/worker/tests/event_create.rs +++ /dev/null @@ -1,106 +0,0 @@ -use chirp_worker::prelude::*; -use proto::backend::{self, pkg::*}; -use serde_json::json; - -#[worker_test] -async fn empty(ctx: TestCtx) { - msg!([ctx] analytics::msg::event_create() { - events: vec![], - }) - .await - .unwrap(); -} - -#[worker_test] -async fn basic(ctx: TestCtx) { - msg!([ctx] analytics::msg::event_create() { - events: vec![ - analytics::msg::event_create::Event { - name: "test.basic".into(), - properties_json: Some(serde_json::to_string(&json!({ - "foo": "bar", - "hello": 123, - "world": { "around": true }, - })).unwrap()), - ..Default::default() - }, - ], - }) - .await - .unwrap(); - - // HACK: Message at the end of a test will get killed since it is spawned - // int he background - tokio::time::sleep(std::time::Duration::from_secs(1)).await; - - // TODO: Check events written to db -} - -#[worker_test] -async fn basic_with_metadata(ctx: TestCtx) { - let user = op!([ctx] faker_user {}).await.unwrap(); - let game = op!([ctx] faker_game {}).await.unwrap(); - - let user_id = user.user_id.unwrap().as_uuid(); - - msg!([ctx] user_presence::msg::game_activity_set(user_id) -> user_presence::msg::update { - user_id: user.user_id, - game_activity: Some(backend::user::presence::GameActivity { - game_id: game.game_id, - message: "This is a test".into(), - public_metadata: Some(serde_json::to_string(&json!({ - "hello": "world", - })).unwrap()), - friend_metadata: Some(serde_json::to_string(&json!({ - "foo": "bar", - })).unwrap()), - }) - }) - .await - .unwrap(); - - msg!([ctx] analytics::msg::event_create() { - events: vec![ - // Event without user - analytics::msg::event_create::Event { - name: "test.no_game_or_user".into(), - user_id: None, - namespace_id: None, - properties_json: Some(serde_json::to_string(&json!({ - "foo": "bar", - "hello": 123, - "world": { "around": true }, - })).unwrap()), - ..Default::default() - }, - analytics::msg::event_create::Event { - name: "test.with_game".into(), - user_id: None, - namespace_id: Some(Uuid::new_v4().into()), - properties_json: Some(serde_json::to_string(&json!({ - "foo": "bar", - "hello": 123, - "world": { "around": true }, - })).unwrap()), - ..Default::default() - }, - - // Event that identifies user - analytics::msg::event_create::Event { - name: "test.identify_user".into(), - user_id: user.user_id, - namespace_id: None, - ..Default::default() - }, - - ], - }) - .await - .unwrap(); - - // HACK: Message at the end of a test will get killed since it is spawned - // int he background - tokio::time::sleep(std::time::Duration::from_secs(1)).await; - - // TODO: Check events written to db -} diff --git a/svc/pkg/captcha/ops/request/src/lib.rs b/svc/pkg/captcha/ops/request/src/lib.rs index 21d94d5604..aacd28741d 100644 --- a/svc/pkg/captcha/ops/request/src/lib.rs +++ b/svc/pkg/captcha/ops/request/src/lib.rs @@ -102,6 +102,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "captcha.needs_verification".into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": user_id, diff --git a/svc/pkg/captcha/ops/verify/src/lib.rs b/svc/pkg/captcha/ops/verify/src/lib.rs index 75dfaecb6b..400d71a0d1 100644 --- a/svc/pkg/captcha/ops/verify/src/lib.rs +++ b/svc/pkg/captcha/ops/verify/src/lib.rs @@ -121,6 +121,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: if success { "captcha.success" } else { "captcha.fail" }.into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": user_id, diff --git a/svc/pkg/cdn/ops/namespace-domain-create/src/lib.rs b/svc/pkg/cdn/ops/namespace-domain-create/src/lib.rs index 17832b1de7..efa1bdc222 100644 --- a/svc/pkg/cdn/ops/namespace-domain-create/src/lib.rs +++ b/svc/pkg/cdn/ops/namespace-domain-create/src/lib.rs @@ -85,6 +85,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "cdn.domain.update".into(), properties_json: Some(serde_json::to_string(&json!({ "developer_team_id": developer_team_id, diff --git a/svc/pkg/cdn/ops/namespace-domain-remove/src/lib.rs b/svc/pkg/cdn/ops/namespace-domain-remove/src/lib.rs index 20a8e74094..afc2e68921 100644 --- a/svc/pkg/cdn/ops/namespace-domain-remove/src/lib.rs +++ b/svc/pkg/cdn/ops/namespace-domain-remove/src/lib.rs @@ -46,6 +46,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "cdn.domain.remove".into(), properties_json: Some(serde_json::to_string(&json!({ "developer_team_id": developer_team_id, diff --git a/svc/pkg/cloud/ops/namespace-create/src/lib.rs b/svc/pkg/cloud/ops/namespace-create/src/lib.rs index b9420285ca..6f3b1664cb 100644 --- a/svc/pkg/cloud/ops/namespace-create/src/lib.rs +++ b/svc/pkg/cloud/ops/namespace-create/src/lib.rs @@ -59,6 +59,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "game.namespace.create".into(), user_id: ctx.creator_user_id, properties_json: Some(serde_json::to_string(&json!({ diff --git a/svc/pkg/cloud/ops/version-publish/src/lib.rs b/svc/pkg/cloud/ops/version-publish/src/lib.rs index 895185cc8f..9683096d43 100644 --- a/svc/pkg/cloud/ops/version-publish/src/lib.rs +++ b/svc/pkg/cloud/ops/version-publish/src/lib.rs @@ -167,6 +167,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "game.version.publish".into(), user_id: ctx.creator_user_id, properties_json: Some(serde_json::to_string(&json!({ diff --git a/svc/pkg/email-verification/ops/complete/src/lib.rs b/svc/pkg/email-verification/ops/complete/src/lib.rs index 291709765d..11bb879468 100644 --- a/svc/pkg/email-verification/ops/complete/src/lib.rs +++ b/svc/pkg/email-verification/ops/complete/src/lib.rs @@ -23,6 +23,7 @@ impl VerificationRow { msg!([client] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "email_verification.complete".into(), properties_json: Some(serde_json::to_string(&json!({ "verification_id": verification_id, @@ -36,6 +37,7 @@ impl VerificationRow { msg!([client] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "email_verification.error".into(), properties_json: Some(serde_json::to_string(&json!({ "verification_id": verification_id, diff --git a/svc/pkg/email-verification/ops/create/src/lib.rs b/svc/pkg/email-verification/ops/create/src/lib.rs index c93be8ef3d..b9f0fafa42 100644 --- a/svc/pkg/email-verification/ops/create/src/lib.rs +++ b/svc/pkg/email-verification/ops/create/src/lib.rs @@ -88,6 +88,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "email_verification.create".into(), properties_json: Some(serde_json::to_string(&json!({ "verification_id": verification_id, diff --git a/svc/pkg/game-user/worker/src/workers/link_complete.rs b/svc/pkg/game-user/worker/src/workers/link_complete.rs index eda3d5f860..8298d8213b 100644 --- a/svc/pkg/game-user/worker/src/workers/link_complete.rs +++ b/svc/pkg/game-user/worker/src/workers/link_complete.rs @@ -148,6 +148,7 @@ async fn worker( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "game_user_link.cancel".into(), user_id: Some(user_id.into()), namespace_id: Some(namespace_id.into()), diff --git a/svc/pkg/game/ops/create/src/lib.rs b/svc/pkg/game/ops/create/src/lib.rs index 1997214287..8dc4a4da56 100644 --- a/svc/pkg/game/ops/create/src/lib.rs +++ b/svc/pkg/game/ops/create/src/lib.rs @@ -77,6 +77,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "game.create".into(), properties_json: Some(serde_json::to_string(&json!({ "developer_team_id": developer_team_id, diff --git a/svc/pkg/game/ops/namespace-version-set/src/lib.rs b/svc/pkg/game/ops/namespace-version-set/src/lib.rs index ffe06b9505..383787d100 100644 --- a/svc/pkg/game/ops/namespace-version-set/src/lib.rs +++ b/svc/pkg/game/ops/namespace-version-set/src/lib.rs @@ -137,6 +137,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "game.namespace.version_set".into(), user_id: ctx.creator_user_id, properties_json: Some(serde_json::to_string(&json!({ diff --git a/svc/pkg/mm/ops/lobby-find-fail/src/lib.rs b/svc/pkg/mm/ops/lobby-find-fail/src/lib.rs index b125bce7c7..9abb15a3a0 100644 --- a/svc/pkg/mm/ops/lobby-find-fail/src/lib.rs +++ b/svc/pkg/mm/ops/lobby-find-fail/src/lib.rs @@ -98,6 +98,7 @@ async fn publish_fail_event( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.query.fail".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": namespace_id, diff --git a/svc/pkg/mm/ops/lobby-find-try-complete/src/lib.rs b/svc/pkg/mm/ops/lobby-find-try-complete/src/lib.rs index b1b6215cac..978feb6144 100644 --- a/svc/pkg/mm/ops/lobby-find-try-complete/src/lib.rs +++ b/svc/pkg/mm/ops/lobby-find-try-complete/src/lib.rs @@ -161,6 +161,7 @@ async fn complete_query( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.query.complete".into(), namespace_id: Some(find_query.namespace_id.into()), properties_json: Some(serde_json::to_string(&json!({ diff --git a/svc/pkg/mm/worker/src/workers/lobby_cleanup.rs b/svc/pkg/mm/worker/src/workers/lobby_cleanup.rs index 4c007f9f14..fcbf79be52 100644 --- a/svc/pkg/mm/worker/src/workers/lobby_cleanup.rs +++ b/svc/pkg/mm/worker/src/workers/lobby_cleanup.rs @@ -188,6 +188,7 @@ async fn worker(ctx: &OperationContext) -> Glob msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.lobby.destroy".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": lobby_row.namespace_id, diff --git a/svc/pkg/mm/worker/src/workers/lobby_create/mod.rs b/svc/pkg/mm/worker/src/workers/lobby_create/mod.rs index 0cbb513f94..b126360955 100644 --- a/svc/pkg/mm/worker/src/workers/lobby_create/mod.rs +++ b/svc/pkg/mm/worker/src/workers/lobby_create/mod.rs @@ -260,6 +260,7 @@ async fn worker(ctx: &OperationContext) -> Globa msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.lobby.create".into(), namespace_id: ctx.namespace_id, properties_json: Some(serde_json::to_string(&json!({ diff --git a/svc/pkg/mm/worker/src/workers/lobby_find/limit.rs b/svc/pkg/mm/worker/src/workers/lobby_find/limit.rs index b1751eb432..f48b22ca62 100644 --- a/svc/pkg/mm/worker/src/workers/lobby_find/limit.rs +++ b/svc/pkg/mm/worker/src/workers/lobby_find/limit.rs @@ -60,6 +60,7 @@ pub async fn check_remote_addresses( ); analytics_events.push(analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.players.count_for_remote_address".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": namespace_id, diff --git a/svc/pkg/mm/worker/src/workers/lobby_find/mod.rs b/svc/pkg/mm/worker/src/workers/lobby_find/mod.rs index 6f5e57c311..da5a4e0b52 100644 --- a/svc/pkg/mm/worker/src/workers/lobby_find/mod.rs +++ b/svc/pkg/mm/worker/src/workers/lobby_find/mod.rs @@ -130,6 +130,7 @@ async fn worker(ctx: &OperationContext) -> GlobalR msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.find.create".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": namespace_id, @@ -247,6 +248,7 @@ async fn worker(ctx: &OperationContext) -> GlobalR // Record analytics events analytics_events.push(analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.query.create".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": namespace_id, @@ -260,6 +262,7 @@ async fn worker(ctx: &OperationContext) -> GlobalR }); for player in &players { analytics_events.push(analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.player.create".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": namespace_id, diff --git a/svc/pkg/mm/worker/src/workers/lobby_ready_set.rs b/svc/pkg/mm/worker/src/workers/lobby_ready_set.rs index c31f629abd..b07eca7f58 100644 --- a/svc/pkg/mm/worker/src/workers/lobby_ready_set.rs +++ b/svc/pkg/mm/worker/src/workers/lobby_ready_set.rs @@ -76,6 +76,7 @@ async fn worker(ctx: &OperationContext) -> Global msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.lobby.ready".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": lobby_row.namespace_id, diff --git a/svc/pkg/mm/worker/src/workers/player_register.rs b/svc/pkg/mm/worker/src/workers/player_register.rs index 7145157324..5afd8ced64 100644 --- a/svc/pkg/mm/worker/src/workers/player_register.rs +++ b/svc/pkg/mm/worker/src/workers/player_register.rs @@ -137,6 +137,7 @@ async fn worker(ctx: &OperationContext) -> Gl msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.player.ready".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": player_row.namespace_id, @@ -175,6 +176,7 @@ async fn fail( msg!([client] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.player.ready_fail".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": player_row.namespace_id, diff --git a/svc/pkg/mm/worker/src/workers/player_remove.rs b/svc/pkg/mm/worker/src/workers/player_remove.rs index b2bcab8e96..fdff24520c 100644 --- a/svc/pkg/mm/worker/src/workers/player_remove.rs +++ b/svc/pkg/mm/worker/src/workers/player_remove.rs @@ -110,6 +110,7 @@ async fn worker(ctx: &OperationContext) -> Glob msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.player.remove".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": player_row.namespace_id, @@ -254,6 +255,7 @@ async fn fail( msg!([client] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "mm.player.remove_fail".into(), properties_json: Some(serde_json::to_string(&json!({ "namespace_id": player_row.namespace_id, diff --git a/svc/pkg/module/worker/src/workers/create.rs b/svc/pkg/module/worker/src/workers/create.rs index 5983bed64e..5b970c706b 100644 --- a/svc/pkg/module/worker/src/workers/create.rs +++ b/svc/pkg/module/worker/src/workers/create.rs @@ -32,6 +32,7 @@ async fn worker(ctx: &OperationContext) -> Result< msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "module.create".into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": ctx.creator_user_id.map(|x| x.as_uuid()), diff --git a/svc/pkg/module/worker/src/workers/instance_create.rs b/svc/pkg/module/worker/src/workers/instance_create.rs index e0dcb59e23..e1f17ec992 100644 --- a/svc/pkg/module/worker/src/workers/instance_create.rs +++ b/svc/pkg/module/worker/src/workers/instance_create.rs @@ -166,6 +166,7 @@ async fn worker( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "module.create".into(), properties_json: Some(serde_json::to_string(&json!({ "module_id": module_id, diff --git a/svc/pkg/module/worker/src/workers/version_create.rs b/svc/pkg/module/worker/src/workers/version_create.rs index 034488aeab..d180b6b88b 100644 --- a/svc/pkg/module/worker/src/workers/version_create.rs +++ b/svc/pkg/module/worker/src/workers/version_create.rs @@ -22,6 +22,7 @@ async fn worker( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "module.create".into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": ctx.creator_user_id.map(|x| x.as_uuid()), diff --git a/svc/pkg/monolith/standalone/worker/Cargo.toml b/svc/pkg/monolith/standalone/worker/Cargo.toml index 980d69a2fe..52c8495744 100644 --- a/svc/pkg/monolith/standalone/worker/Cargo.toml +++ b/svc/pkg/monolith/standalone/worker/Cargo.toml @@ -16,7 +16,6 @@ tokio = { version = "1.29", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "json", "ansi"] } -analytics-worker = { path = "../../../analytics/worker" } cdn-worker = { path = "../../../cdn/worker" } cf-custom-hostname-worker = { path = "../../../cf-custom-hostname/worker" } cloud-worker = { path = "../../../cloud/worker" } diff --git a/svc/pkg/monolith/standalone/worker/src/lib.rs b/svc/pkg/monolith/standalone/worker/src/lib.rs index 2dc324f263..008ec7ee70 100644 --- a/svc/pkg/monolith/standalone/worker/src/lib.rs +++ b/svc/pkg/monolith/standalone/worker/src/lib.rs @@ -22,7 +22,6 @@ pub async fn run_from_env(pools: rivet_pools::Pools) -> GlobalResult<()> { let mut join_set = tokio::task::JoinSet::new(); spawn_workers![ [shared_client, pools, cache, join_set] - analytics_worker, cdn_worker, cf_custom_hostname_worker, cloud_worker, diff --git a/svc/pkg/nsfw/ops/image-score/src/lib.rs b/svc/pkg/nsfw/ops/image-score/src/lib.rs index bfc8b33ba8..10971ba492 100644 --- a/svc/pkg/nsfw/ops/image-score/src/lib.rs +++ b/svc/pkg/nsfw/ops/image-score/src/lib.rs @@ -79,6 +79,7 @@ async fn handle( .iter() .map(|x| { GlobalResult::Ok(analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "nsfw.score".into(), properties_json: Some(serde_json::to_string(&json!({ "url": x.url, diff --git a/svc/pkg/team-invite/worker/src/workers/consume.rs b/svc/pkg/team-invite/worker/src/workers/consume.rs index 6cd416e1cd..3ba6072f3a 100644 --- a/svc/pkg/team-invite/worker/src/workers/consume.rs +++ b/svc/pkg/team-invite/worker/src/workers/consume.rs @@ -58,6 +58,7 @@ async fn fail( msg!([client] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "team.invite.consume_fail".into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": user_id, diff --git a/svc/pkg/team-invite/worker/src/workers/create.rs b/svc/pkg/team-invite/worker/src/workers/create.rs index f84e4cd9f0..37fbb79d01 100644 --- a/svc/pkg/team-invite/worker/src/workers/create.rs +++ b/svc/pkg/team-invite/worker/src/workers/create.rs @@ -36,6 +36,7 @@ async fn worker(ctx: &OperationContext) -> Gl msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "team.invite.create".into(), properties_json: Some(serde_json::to_string(&json!({ "team_id": team_id, diff --git a/svc/pkg/team/ops/avatar-upload-complete/src/lib.rs b/svc/pkg/team/ops/avatar-upload-complete/src/lib.rs index 531df74524..8b2736ab88 100644 --- a/svc/pkg/team/ops/avatar-upload-complete/src/lib.rs +++ b/svc/pkg/team/ops/avatar-upload-complete/src/lib.rs @@ -35,6 +35,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "team.avatar_set".into(), properties_json: Some(serde_json::to_string(&json!({ "team_id": team_id, diff --git a/svc/pkg/team/worker/src/workers/create.rs b/svc/pkg/team/worker/src/workers/create.rs index 654abb1b2d..ac6738445a 100644 --- a/svc/pkg/team/worker/src/workers/create.rs +++ b/svc/pkg/team/worker/src/workers/create.rs @@ -56,6 +56,7 @@ async fn worker(ctx: &OperationContext) -> GlobalRes msg!([ctx] analytics::msg::event_create() { events: vec![ 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!({ @@ -64,6 +65,7 @@ async fn worker(ctx: &OperationContext) -> GlobalRes ..Default::default() }, analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "team.profile_set".into(), properties_json: Some(serde_json::to_string(&json!({ "display_name": ctx.display_name, diff --git a/svc/pkg/team/worker/src/workers/join_request_create.rs b/svc/pkg/team/worker/src/workers/join_request_create.rs index 9d0f3848fc..cf1b60ae69 100644 --- a/svc/pkg/team/worker/src/workers/join_request_create.rs +++ b/svc/pkg/team/worker/src/workers/join_request_create.rs @@ -18,6 +18,7 @@ async fn fail( msg!([client] analytics::msg::event_create() { events: vec![ 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!({ @@ -77,6 +78,7 @@ async fn worker( msg!([ctx] analytics::msg::event_create() { events: vec![ 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!({ diff --git a/svc/pkg/team/worker/src/workers/join_request_resolve.rs b/svc/pkg/team/worker/src/workers/join_request_resolve.rs index 99c1b16f5d..64458b3aef 100644 --- a/svc/pkg/team/worker/src/workers/join_request_resolve.rs +++ b/svc/pkg/team/worker/src/workers/join_request_resolve.rs @@ -37,6 +37,7 @@ async fn worker( msg!([ctx] analytics::msg::event_create() { events: vec![ 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!({ diff --git a/svc/pkg/team/worker/src/workers/member_create.rs b/svc/pkg/team/worker/src/workers/member_create.rs index b7869d523c..fff6a8694c 100644 --- a/svc/pkg/team/worker/src/workers/member_create.rs +++ b/svc/pkg/team/worker/src/workers/member_create.rs @@ -66,6 +66,7 @@ async fn worker(ctx: &OperationContext) -> Gl msg!([ctx] analytics::msg::event_create() { events: vec![ 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!({ @@ -81,6 +82,7 @@ async fn worker(ctx: &OperationContext) -> Gl msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "team.invite.consume".into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": user_id, @@ -123,6 +125,7 @@ async fn fail( msg!([client] analytics::msg::event_create() { events: vec![ 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!({ diff --git a/svc/pkg/team/worker/src/workers/member_kick.rs b/svc/pkg/team/worker/src/workers/member_kick.rs index 5622cc7747..201250dc3f 100644 --- a/svc/pkg/team/worker/src/workers/member_kick.rs +++ b/svc/pkg/team/worker/src/workers/member_kick.rs @@ -29,6 +29,7 @@ async fn worker(ctx: &OperationContext) -> Glob 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!({ diff --git a/svc/pkg/team/worker/src/workers/member_remove.rs b/svc/pkg/team/worker/src/workers/member_remove.rs index 7e8eed7e02..2fe62fa7ed 100644 --- a/svc/pkg/team/worker/src/workers/member_remove.rs +++ b/svc/pkg/team/worker/src/workers/member_remove.rs @@ -44,6 +44,7 @@ async fn worker(ctx: &OperationContext) -> Gl msg!([ctx] analytics::msg::event_create() { events: vec![ 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!({ diff --git a/svc/pkg/team/worker/src/workers/profile_set.rs b/svc/pkg/team/worker/src/workers/profile_set.rs index 9bf4be1953..e0c55b69d2 100644 --- a/svc/pkg/team/worker/src/workers/profile_set.rs +++ b/svc/pkg/team/worker/src/workers/profile_set.rs @@ -128,6 +128,7 @@ async fn worker(ctx: &OperationContext) -> Glob msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "team.profile_set".into(), properties_json: Some(serde_json::to_string(&json!({ "display_name": display_name, diff --git a/svc/pkg/team/worker/src/workers/user_ban.rs b/svc/pkg/team/worker/src/workers/user_ban.rs index 7c3ad78280..e974df0fea 100644 --- a/svc/pkg/team/worker/src/workers/user_ban.rs +++ b/svc/pkg/team/worker/src/workers/user_ban.rs @@ -48,6 +48,7 @@ async fn worker(ctx: &OperationContext) -> GlobalR 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!({ diff --git a/svc/pkg/team/worker/src/workers/user_unban.rs b/svc/pkg/team/worker/src/workers/user_unban.rs index 10543b5def..5785c3c578 100644 --- a/svc/pkg/team/worker/src/workers/user_unban.rs +++ b/svc/pkg/team/worker/src/workers/user_unban.rs @@ -38,6 +38,7 @@ async fn worker(ctx: &OperationContext) -> Globa 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!({ diff --git a/svc/pkg/upload/ops/complete/src/lib.rs b/svc/pkg/upload/ops/complete/src/lib.rs index fae7e5cfa9..aa1cb93665 100644 --- a/svc/pkg/upload/ops/complete/src/lib.rs +++ b/svc/pkg/upload/ops/complete/src/lib.rs @@ -71,6 +71,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "upload.complete".into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": user_id, @@ -179,6 +180,7 @@ async fn validate_profanity_scores( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "upload.nsfw_detected".into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": user_id, diff --git a/svc/pkg/upload/ops/prepare/src/lib.rs b/svc/pkg/upload/ops/prepare/src/lib.rs index ade18e87f0..e4ac4cb09b 100644 --- a/svc/pkg/upload/ops/prepare/src/lib.rs +++ b/svc/pkg/upload/ops/prepare/src/lib.rs @@ -202,6 +202,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "upload.prepare".into(), properties_json: Some(serde_json::to_string(&json!({ "user_id": user_id, diff --git a/svc/pkg/user-follow/ops/toggle/src/lib.rs b/svc/pkg/user-follow/ops/toggle/src/lib.rs index feb892f8c8..6bc1471841 100644 --- a/svc/pkg/user-follow/ops/toggle/src/lib.rs +++ b/svc/pkg/user-follow/ops/toggle/src/lib.rs @@ -89,6 +89,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { 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!({ @@ -123,6 +124,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { 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!({ diff --git a/svc/pkg/user-identity/ops/create/src/lib.rs b/svc/pkg/user-identity/ops/create/src/lib.rs index cacb405d4b..58f3e2e3e4 100644 --- a/svc/pkg/user-identity/ops/create/src/lib.rs +++ b/svc/pkg/user-identity/ops/create/src/lib.rs @@ -30,6 +30,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ 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, @@ -58,6 +59,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ 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, diff --git a/svc/pkg/user/ops/avatar-upload-complete/src/lib.rs b/svc/pkg/user/ops/avatar-upload-complete/src/lib.rs index 97bd4472a1..b6d7277a3c 100644 --- a/svc/pkg/user/ops/avatar-upload-complete/src/lib.rs +++ b/svc/pkg/user/ops/avatar-upload-complete/src/lib.rs @@ -36,6 +36,7 @@ async fn handle( msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "user.avatar_set".into(), user_id: Some(user_id.into()), ..Default::default() diff --git a/svc/pkg/user/worker/src/workers/create.rs b/svc/pkg/user/worker/src/workers/create.rs index 2dd2489bf4..fef7e29dd7 100644 --- a/svc/pkg/user/worker/src/workers/create.rs +++ b/svc/pkg/user/worker/src/workers/create.rs @@ -84,6 +84,7 @@ async fn worker(ctx: &OperationContext) -> GlobalRes 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, @@ -92,6 +93,7 @@ async fn worker(ctx: &OperationContext) -> GlobalRes ..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, diff --git a/svc/pkg/user/worker/src/workers/delete.rs b/svc/pkg/user/worker/src/workers/delete.rs index 7feeab6776..0b2b025008 100644 --- a/svc/pkg/user/worker/src/workers/delete.rs +++ b/svc/pkg/user/worker/src/workers/delete.rs @@ -134,6 +134,7 @@ async fn worker(ctx: &OperationContext) -> GlobalRes msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "user.delete".into(), user_id: None, namespace_id: None, diff --git a/svc/pkg/user/worker/src/workers/profile_set.rs b/svc/pkg/user/worker/src/workers/profile_set.rs index 00238275f9..2c598f64f9 100644 --- a/svc/pkg/user/worker/src/workers/profile_set.rs +++ b/svc/pkg/user/worker/src/workers/profile_set.rs @@ -90,6 +90,7 @@ async fn worker(ctx: &OperationContext) -> Glob msg!([ctx] analytics::msg::event_create() { events: vec![ analytics::msg::event_create::Event { + event_id: Some(Uuid::new_v4().into()), name: "user.profile_set".into(), user_id: Some(*user_id), ..Default::default()