Skip to content

Commit

Permalink
Merge branch 'main' into feat/scrolling-profile-view
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-sawlani-yral committed May 20, 2024
2 parents da95707 + a8f477b commit b3293d5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/page/err.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::{state::canisters::auth_canisters_store, utils::event_streaming::events::ErrorEvent};
use gloo::history::{BrowserHistory, History};
use leptos::*;
use leptos_router::*;
Expand All @@ -17,6 +18,9 @@ pub fn ServerErrorPage() -> impl IntoView {
.unwrap_or_else(|_| "Server Error".to_string())
});

let canister_store = auth_canisters_store();
ErrorEvent.send_event(error, canister_store);

view! { <ErrorView error/> }
}

Expand Down
3 changes: 2 additions & 1 deletion src/page/upload/video_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub fn VideoUploader(params: UploadParams) -> impl IntoView {
canisters,
hashtags,
description,
uid,
uid.clone(),
params.enable_hot_or_not,
params.is_nsfw,
)
Expand All @@ -297,6 +297,7 @@ pub fn VideoUploader(params: UploadParams) -> impl IntoView {
publishing.set(false);

VideoUploadSuccessful.send_event(
uid,
hashtags_len,
is_nsfw,
enable_hot_or_not,
Expand Down
33 changes: 32 additions & 1 deletion src/utils/event_streaming/events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ic_agent::Identity;
use leptos::html::Input;
use leptos::{create_effect, ReadSignal, RwSignal, SignalGetUntracked};
use leptos::{create_effect, ReadSignal, RwSignal, Signal, SignalGetUntracked};
use leptos::{create_signal, ev, expect_context, html::Video, Memo, NodeRef, SignalGet, SignalSet};
use leptos_use::use_event_listener;
use serde_json::json;
Expand Down Expand Up @@ -33,6 +33,7 @@ pub enum AnalyticsEvent {
LoginCta(LoginCta),
LogoutClicked(LogoutClicked),
LogoutConfirmation(LogoutConfirmation),
ErrorEvent(ErrorEvent),
}

#[derive(Default)]
Expand Down Expand Up @@ -404,6 +405,7 @@ pub struct VideoUploadSuccessful;
impl VideoUploadSuccessful {
pub fn send_event(
&self,
video_id: String,
hashtags_len: usize,
is_nsfw: bool,
enable_hot_or_not: bool,
Expand All @@ -425,6 +427,7 @@ impl VideoUploadSuccessful {
"is_NSFW": is_nsfw,
"is_hotorNot": enable_hot_or_not,
"is_filter_used": false,
"video_id": video_id,
}),
);
}
Expand Down Expand Up @@ -654,3 +657,31 @@ impl LogoutConfirmation {
}
}
}

#[derive(Default)]
pub struct ErrorEvent;

impl ErrorEvent {
pub fn send_event(&self, error: Signal<String>, cans_store: RwSignal<Option<Canisters<true>>>) {
#[cfg(all(feature = "hydrate", feature = "ga4"))]
{
let event_history: EventHistory = expect_context();
let user = user_details_can_store_or_ret!(cans_store);
let details = user.details;

let user_id = details.principal;
let canister_id = user.canister_id;

// error_event - analytics
send_event(
"error_event",
&json!({
"user_id": user_id,
"canister_id": canister_id,
"description": error.get_untracked(),
"previous_event": event_history.event_name.get_untracked(),
}),
);
}
}
}

0 comments on commit b3293d5

Please sign in to comment.