Skip to content

Opt-in weekly sending of statistics #6851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

Hocuri
Copy link
Collaborator

@Hocuri Hocuri commented May 12, 2025

This way, the statistics / self-reporting bot will be made into an opt-in regular sending of statistics, where you enable the setting once and then they will be sent automatically. The statistics will be sent to a bot, so that the user can see exactly which data is being sent, and how often. The chat will be archived and muted by default, so that it doesn't disturb the user.

Plan for statistics-sending:

  • Get this PR reviewed and merged (but don't make it available in the UI yet; if Android wants to make a release in the meantime, I will create a PR that removes the option there)
  • Write something for people who are interested in what exactly we count, and link to it (see TODO[blog post] in the code)
  • Prepare a short survey for participants
  • Fine-tune the texts at [WIP] Make sending of statistics into a setting deltachat/deltachat-android#3794, and get it reviewed and merged
  • After the next release, ask people to enable the statistics-sending

Hocuri added a commit to deltachat/deltachat-android that referenced this pull request May 12, 2025
@Hocuri Hocuri force-pushed the hoc/send-statistics-setting branch from a4d64cb to 5619601 Compare June 20, 2025 09:17
@Hocuri Hocuri changed the base branch from main to link2xt/pgp-contacts June 20, 2025 15:55
Hocuri added a commit to deltachat/deltachat-android that referenced this pull request Jun 25, 2025
Base automatically changed from link2xt/pgp-contacts to main June 26, 2025 14:06
@link2xt link2xt force-pushed the main branch 2 times, most recently from 285d80a to 416131b Compare June 26, 2025 14:07
@Hocuri Hocuri force-pushed the hoc/send-statistics-setting branch 2 times, most recently from 932b191 to 8895fd8 Compare July 8, 2025 15:06
@Hocuri Hocuri force-pushed the hoc/send-statistics-setting branch from 511aaa9 to 966124a Compare July 15, 2025 15:24
@Hocuri Hocuri changed the title [WIP] Make sending of statistics into a setting [WIP] Opt-in weekly sending of statistics Jul 31, 2025
This way, the statistics / self-reporting bot will be made into an opt-in regular sending of statistics, where you enable the setting once and then they will be sent automatically. The statistics will be sent to a bot, so that the user can see exactly which data is being sent, and how often. The chat will be archived and muted by default, so that it doesn't disturb the user.
@Hocuri Hocuri force-pushed the hoc/send-statistics-setting branch from 966124a to b1c57ee Compare August 14, 2025 16:15
Hocuri added a commit to deltachat/deltachat-android that referenced this pull request Aug 15, 2025
@Hocuri Hocuri force-pushed the hoc/send-statistics-setting branch from 6b9f05f to 4314864 Compare August 15, 2025 11:56
@Hocuri Hocuri changed the title [WIP] Opt-in weekly sending of statistics Opt-in weekly sending of statistics Aug 15, 2025
@Hocuri Hocuri requested a review from link2xt August 15, 2025 12:46
@Hocuri Hocuri requested a review from iequidoo August 15, 2025 12:46
@@ -886,6 +881,21 @@ impl CommandApi {
Ok(chat_id.to_u32())
}

/// Like `secure_join()`, but allows to pass a source and a UI-path.
Copy link
Collaborator

Choose a reason for hiding this comment

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

source and uipath should be documented, their purpose and why they are u32 isn't clear when one sees this API for the first time.

/// This key is sent to the self_reporting bot so that the bot can recognize the user
/// Send statistics to Delta Chat's developers.
/// Can be exposed to the user as a setting.
SendStatistics,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe prefix everything with Stats then? E.g. StatsSending, StatsLastSent, StatsId, StatsLastMsgId, StatsLastContactId. I think it's better w/o "Excluded" and "Old" because even the comment says "included". Alternatively, replace both words with "Included" or "Counted", these sound better to me.

StatsLastExcludedMsgId,

/// The last contact id that already existed when statistics-sending was enabled.
/// All newer contacts get the `"new": true` attribute.
Copy link
Collaborator

Choose a reason for hiding this comment

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

statistics::ContactStat::new should be referenced from here, otherwise it's not clear which attribute is meant. But removing this doc line is also fine i think.

|| is_mdn
|| chat_id_blocked == Blocked::Yes
|| group_changes.silent
|| mime_parser.from.addr == STATISTICS_BOT_EMAIL
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the chat is archived and muted by default, maybe there's no need in this check?

#[derive(Serialize)]
struct Statistics {
core_version: String,
key_created: Vec<i64>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe rename this to key_create_timestamps? Everything unobvious need documentation here, the struct is private, but the format is actually public

if should_send_statistics(context).await? {
let last_sending_time = context.get_config_i64(Config::LastStatisticsSent).await?;
let next_sending_time = last_sending_time.saturating_add(SENDING_INTERVAL_SECONDS);
if next_sending_time <= time() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If time() < last_sending_time, need to update Config::LastStatisticsSent to protect from rewound clock

msg.set_text(
"The attachment contains anonymous usage statistics, \
because you enabled this in the settings. \
This helps us improve the security of Delta Chat. \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This helps us improve the security of Delta Chat. \
This helps us improve Delta Chat. \

.log_err(context)
.ok();

set_last_excluded_msg_id(context).await?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add last_msg_id to struct Statistics and exclude it from serialization. This way we won't miss messages stored into the db concurrently

Ok(serde_json::to_string_pretty(&statistics)?)
}

async fn get_statistics_bot(context: &Context) -> Result<ChatId, anyhow::Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
async fn get_statistics_bot(context: &Context) -> Result<ChatId, anyhow::Error> {
async fn get_statistics_chat_id(context: &Context) -> Result<ChatId, anyhow::Error> {

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.

2 participants