Skip to main content

rpfm_telemetry/
feedback.rs

1//---------------------------------------------------------------------------//
2// Copyright (c) 2017-2026 Ismael Gutiérrez González. All rights reserved.
3//
4// This file is part of the Rusted PackFile Manager (RPFM) project,
5// which can be found here: https://github.com/Frodo45127/rpfm.
6//
7// This file is licensed under the MIT license, which can be found here:
8// https://github.com/Frodo45127/rpfm/blob/master/LICENSE.
9//---------------------------------------------------------------------------//
10
11//! User feedback capture, posted to PostHog as a dedicated event.
12//!
13//! Feedback is sent as a PostHog `user_feedback` event with the user's text
14//! carried in the `feedback` property, reusing the PostHog plumbing in
15//! [`crate::actions`] (API key, host, `distinct_id` and shared event
16//! properties). Sending is not gated on the usage-telemetry toggle: the user
17//! just clicked Send, which is consent in the moment regardless of the
18//! telemetry/crash-report settings.
19
20use std::collections::HashMap;
21
22use crate::actions::capture_event;
23use crate::info;
24
25/// PostHog event name used for user-feedback submissions.
26const FEEDBACK_EVENT_NAME: &str = "user_feedback";
27
28/// Captures a single user-feedback message and ships it to PostHog.
29///
30/// # Arguments
31///
32/// * `message` - The free-form text the user typed in the feedback dialog.
33pub fn send_user_feedback(message: &str) {
34    info!("Sending user feedback ({} chars)...", message.len());
35
36    let mut properties = HashMap::new();
37    properties.insert("feedback".to_string(), serde_json::Value::from(message.to_string()));
38
39    capture_event(FEEDBACK_EVENT_NAME, properties);
40}