-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
base: main
Are you sure you want to change the base?
Conversation
Counterpart of chatmail/core#6851
a4d64cb
to
5619601
Compare
Counterpart of chatmail/core#6851
285d80a
to
416131b
Compare
932b191
to
8895fd8
Compare
511aaa9
to
966124a
Compare
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.
966124a
to
b1c57ee
Compare
Counterpart of chatmail/core#6851
6b9f05f
to
4314864
Compare
@@ -886,6 +881,21 @@ impl CommandApi { | |||
Ok(chat_id.to_u32()) | |||
} | |||
|
|||
/// Like `secure_join()`, but allows to pass a source and a UI-path. |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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. \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?; |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async fn get_statistics_bot(context: &Context) -> Result<ChatId, anyhow::Error> { | |
async fn get_statistics_chat_id(context: &Context) -> Result<ChatId, anyhow::Error> { |
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:
TODO[blog post]
in the code)