Skip to content

Conversation

@prakash-bhatt-yral
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings August 26, 2025 06:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses bug #1049 by refactoring storage implementation and adding an initialization event to track when the application starts. The changes replace local storage with cookie-based storage for device ID management and ensure events are properly triggered at application startup.

  • Replaced LocalStorage implementation with Cookie-based Storage for persistent device ID management
  • Added an init_event function to track application initialization with user principal data
  • Enhanced logging for debugging Mixpanel event flow

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ssr/src/utils/src/storage.rs New cookie-based storage implementation replacing local storage
ssr/src/utils/src/mixpanel/mixpanel_events.rs Added init_event function and updated device ID references
ssr/src/utils/src/local_storage.rs Removed local storage implementation
ssr/src/utils/src/lib.rs Updated module exports to use storage instead of local_storage
ssr/src/page/src/root.rs Added init_event call on page load with user principal
ssr/src/page/src/post_view/mod.rs Changed Effect to Effect::new_isomorphic for better SSR compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +17 to +18
if let Some(uuid) = uuid_value {
uuid
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function logic is inconsistent with the removed LocalStorage implementation. The original code checked uuid_value.is_empty() for an empty string, but this code checks for None. This could cause issues if cookies return empty strings instead of None, leading to unnecessary UUID regeneration.

Suggested change
if let Some(uuid) = uuid_value {
uuid
if let Some(ref uuid) = uuid_value {
if !uuid.is_empty() {
uuid.clone()
} else {
let new_device_id = uuid::Uuid::new_v4().to_string();
set_uuid.set(Some(new_device_id.clone()));
new_device_id
}

Copilot uses AI. Check for mistakes.
}

pub async fn init_event(user_principal: Option<String>) {
leptos::logging::log!("Init event {:?})", user_principal);
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closing quote in the log message format string. It should be "Init event {:?})""Init event {:?}".

Suggested change
leptos::logging::log!("Init event {:?})", user_principal);
leptos::logging::log!("Init event {:?}", user_principal);

Copilot uses AI. Check for mistakes.

#[server]
async fn track_event_server_fn(props: Value) -> Result<(), ServerFnError> {
leptos::logging::log!("Init event served");
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This debug log message is misleading as it appears in the general track_event_server_fn function, not specifically for init events. This will log for all events tracked through this function, which could be confusing when debugging.

Suggested change
leptos::logging::log!("Init event served");
leptos::logging::log!("Event tracked via track_event_server_fn");

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: No events triggered before gameplay despite video start

1 participant