diff --git a/Cargo.lock b/Cargo.lock index bb5bad5547..c934309a27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1667,7 +1667,7 @@ dependencies = [ [[package]] name = "dfx-core" version = "0.0.1" -source = "git+https://github.com/hpeebles/dfinity-sdk?rev=d39dde0611fda8f30a6796b40b1dbb13a0541597#d39dde0611fda8f30a6796b40b1dbb13a0541597" +source = "git+https://github.com/dfinity/sdk?rev=c7fa9267950836fb2e8af2f03a6531ead9289f81#c7fa9267950836fb2e8af2f03a6531ead9289f81" dependencies = [ "aes-gcm", "argon2", @@ -2103,7 +2103,7 @@ dependencies = [ [[package]] name = "event_sink_canister" version = "0.1.0" -source = "git+https://github.com/open-chat-labs/event-sink?rev=e8e4a547f767ef568ddf978c6cc421a1ef05485e#e8e4a547f767ef568ddf978c6cc421a1ef05485e" +source = "git+https://github.com/open-chat-labs/event-sink?rev=598a846ae880e6bb691809bae1c0839180381883#598a846ae880e6bb691809bae1c0839180381883" dependencies = [ "candid", "serde", @@ -2113,7 +2113,7 @@ dependencies = [ [[package]] name = "event_sink_client" version = "0.1.0" -source = "git+https://github.com/open-chat-labs/event-sink?rev=e8e4a547f767ef568ddf978c6cc421a1ef05485e#e8e4a547f767ef568ddf978c6cc421a1ef05485e" +source = "git+https://github.com/open-chat-labs/event-sink?rev=598a846ae880e6bb691809bae1c0839180381883#598a846ae880e6bb691809bae1c0839180381883" dependencies = [ "event_sink_canister", "ic_principal", @@ -2123,7 +2123,7 @@ dependencies = [ [[package]] name = "event_sink_client_cdk_runtime" version = "0.1.0" -source = "git+https://github.com/open-chat-labs/event-sink?rev=e8e4a547f767ef568ddf978c6cc421a1ef05485e#e8e4a547f767ef568ddf978c6cc421a1ef05485e" +source = "git+https://github.com/open-chat-labs/event-sink?rev=598a846ae880e6bb691809bae1c0839180381883#598a846ae880e6bb691809bae1c0839180381883" dependencies = [ "event_sink_canister", "event_sink_client", @@ -2138,7 +2138,7 @@ dependencies = [ [[package]] name = "event_sink_utils" version = "0.1.0" -source = "git+https://github.com/open-chat-labs/event-sink?rev=e8e4a547f767ef568ddf978c6cc421a1ef05485e#e8e4a547f767ef568ddf978c6cc421a1ef05485e" +source = "git+https://github.com/open-chat-labs/event-sink?rev=598a846ae880e6bb691809bae1c0839180381883#598a846ae880e6bb691809bae1c0839180381883" dependencies = [ "serde", ] @@ -2949,9 +2949,9 @@ dependencies = [ [[package]] name = "ic-agent" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410a8c1bdd647dfc43978497e8f794378a18eeb3ec7c768b92c3885c999e1d1b" +checksum = "f32c4711ca94eee9b7966116698b69ca99e7e24cba68c1f3dd86f2ed70218a7e" dependencies = [ "backoff", "cached", @@ -2966,6 +2966,7 @@ dependencies = [ "ic-verify-bls-signature", "k256 0.13.1", "leb128", + "p256", "pem 2.0.1", "pkcs8 0.10.2", "rand", @@ -3040,9 +3041,9 @@ dependencies = [ [[package]] name = "ic-identity-hsm" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478f1fb56cdda5959ac4a685dbe74c56f25226212defb34ab5cf136f4b919344" +checksum = "e9d363914507e81896a6edd1768aa2524bd923b94ed4c27a9793a90b0880f741" dependencies = [ "hex", "ic-agent", @@ -3078,9 +3079,9 @@ dependencies = [ [[package]] name = "ic-transport-types" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb030f03ef8332fbf8eda6bb25e80d8354d2bef88b27e671b3c167d9ee8e7a7" +checksum = "d595b9f72e5952bcb22e5cda37ae1c8d6579a24aaa224b63b8d245f386bdcbb2" dependencies = [ "candid", "hex", @@ -3095,9 +3096,9 @@ dependencies = [ [[package]] name = "ic-utils" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2921308283f89a431872ba63f5ece9ffe6eadf7bc4cc5d12239eae146c7db8f0" +checksum = "a8e26bd17f2f188a608deae41b8c269a85e1e98118c9a7aa0803ad252552c0b2" dependencies = [ "async-trait", "candid", @@ -5189,9 +5190,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" dependencies = [ "base64 0.21.5", "bytes", @@ -5203,13 +5204,11 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", - "hyper-tls", "ipnet", "js-sys", "log", "mime", "mime_guess", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -5218,9 +5217,9 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", - "tokio-native-tls", "tokio-rustls", "tokio-util", "tower-service", @@ -6354,6 +6353,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "synstructure" version = "0.12.6" @@ -7260,9 +7265,9 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-streams" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" dependencies = [ "futures-util", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 225becc5d1..5248f3c2df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,24 +158,24 @@ candid = "0.10.3" canister_sig_util = { git = "https://github.com/dfinity/internet-identity", rev = "f46da3bfefff638a844117606a4dea70b2dd4405" } ciborium = "0.2.1" clap = "4.4.8" -dfx-core = { git = "https://github.com/hpeebles/dfinity-sdk", rev = "d39dde0611fda8f30a6796b40b1dbb13a0541597" } +dfx-core = { git = "https://github.com/dfinity/sdk", rev = "c7fa9267950836fb2e8af2f03a6531ead9289f81" } dirs = "5.0.1" dotenv = "0.15.0" -event_sink_canister = { git = "https://github.com/open-chat-labs/event-sink", rev = "e8e4a547f767ef568ddf978c6cc421a1ef05485e" } -event_sink_client = { git = "https://github.com/open-chat-labs/event-sink", rev = "e8e4a547f767ef568ddf978c6cc421a1ef05485e" } -event_sink_client_cdk_runtime = { git = "https://github.com/open-chat-labs/event-sink", rev = "e8e4a547f767ef568ddf978c6cc421a1ef05485e" } -event_sink_utils = { git = "https://github.com/open-chat-labs/event-sink", rev = "e8e4a547f767ef568ddf978c6cc421a1ef05485e" } +event_sink_canister = { git = "https://github.com/open-chat-labs/event-sink", rev = "598a846ae880e6bb691809bae1c0839180381883" } +event_sink_client = { git = "https://github.com/open-chat-labs/event-sink", rev = "598a846ae880e6bb691809bae1c0839180381883" } +event_sink_client_cdk_runtime = { git = "https://github.com/open-chat-labs/event-sink", rev = "598a846ae880e6bb691809bae1c0839180381883" } +event_sink_utils = { git = "https://github.com/open-chat-labs/event-sink", rev = "598a846ae880e6bb691809bae1c0839180381883" } futures = "0.3.29" getrandom = { version = "0.2.11", features = ["custom"] } hex = "0.4.3" -ic-agent = "0.32.0" +ic-agent = "0.33.0" ic-cdk = "=0.12.0" ic-cdk-macros = "0.8.4" ic-cdk-timers = "0.6.0" ic-ledger-types = "0.9.0" ic-stable-structures = "0.6.2" -ic-transport-types = "0.32.0" -ic-utils = "0.32.0" +ic-transport-types = "0.33.0" +ic-utils = "0.33.0" icrc-ledger-types = "0.1.5" ic0 = "0.21.1" itertools = "0.11.0" diff --git a/backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs b/backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs index 4c44c40509..b1a31f1ec3 100644 --- a/backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs +++ b/backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs @@ -1,6 +1,6 @@ use crate::lifecycle::{init_env, init_state}; use crate::memory::get_upgrades_memory; -use crate::{mutate_state, Data}; +use crate::{mutate_state, Data, UserRegisteredEventPayload}; use canister_logger::LogEntry; use canister_tracing_macros::trace; use ic_cdk_macros::post_upgrade; @@ -36,5 +36,24 @@ fn post_upgrade(args: Args) { crate::jobs::sync_legacy_user_principals::start_job_if_required(state); } + + let source = Some(state.env.canister_id().to_text()); + + // Push an event for each user who registered before the previous upgrade + for user in state.data.users.iter().filter(|u| u.date_created < 1707486762394) { + let payload = serde_json::to_vec(&UserRegisteredEventPayload { + referred: user.referred_by.is_some(), + is_bot: user.is_bot, + }) + .unwrap(); + + state.data.event_sink_client.push_event(event_sink_client::Event { + name: "user_registered".to_string(), + timestamp: user.date_created, + user: Some(user.user_id.to_string()), + source: source.clone(), + payload, + }); + } }); }