fn update_total_stat(&mut self, total_stat: HourlyPageViewStat, count_str: String) {
self.total_stat = HourlyPageViewStat::default();
if !self.encrypted.clone() {
return;
}
let mut count = self.decrypt(total_stat.pv_count).parse::<u32>().unwrap();
if count_str != "" {
count += self.decrypt(count_str).parse::<u32>().unwrap();
}
let avg_duration = self.decrypt(total_stat.avg_duration).parse::<u32>().unwrap() / 2;
self.total_stat = HourlyPageViewStat {
sid: total_stat.sid,
cid_count: total_stat.cid_count,
pv_count: self.encrypt(count.to_string()),
avg_duration: self.encrypt(avg_duration.to_string()),
timestamp: total_stat.timestamp
}
}
Time to drop the centralized analytics tools! Instead of sending your user's privacy to the Internet cartels, W3A SDK enforces users' 100% control over the privacy. With the SDK, any web service can become a part of Web3.0 in just a few minutes.