When testing the fix for T196131 (v5.8.2 build 1420)opted in users start the app for the first time after install/upgrade, the app should send a 'session_start' event to the MobileWikiAppiOSSessions table, and take a snapshot of the user configuration and send it to the MobileWikiAppiOSUserHistory table at the same time. However, we found that there are 122 distinct users in the MobileWikiAppiOSSessions tablein 5.8.2.1421, but only there are 324793 users in thenique app IDs in MobileWikiAppiOSUserHistorySessions table., Since the app should send a snapshot to MobileWikiAppiOSUserHistory table when users start the app for the first time after install/update or opt-in in settings,but only 194487 unique app IDs in MobileWikiAppiOSUserHistory table. this two counts should have beenAbout 40% of apps didn't send the same.ir snapshots!
IAfter some investigation is needed to figure out if there's any edge cases we didn't, there are 2 issues may be related to think of.s bug:
```lang=sql
-- users not sending snapshots
select distinct event.app_install_id
from event.mobilewikiappiossessions
where year=2018 and month=6
and useragent.wmf_app_version='5.8.2.1420'
and event.app_install_id not in (**1, Events are not being queued over multiple sessions. Currently, it seems the events are only queued for the last session, but not older sessions.**
Steps to reproduce:
select distinct event.app_install_id- Clean install 5.8.2.1421
from event.mobilewikiappiosuserhistory- Set up Charles proxy to allow throttling. In throttle settings, change the bandwidth to 0kbps
where year=2018 and month=6- Start the app for the first time, opt in to send usage report. Of course, we can't see any feed other than the education cards
and useragent.wmf_app_version='5.8.2.1420'- Take the app to the background to end this session. Then, turn on the app to start a 2nd session, and turn off again.
)- Stop throttling
```- Take the app to the foreground again to start the 3rd session. From Charles proxy, we only see the queued 'session_end' events from last session, but no snapshots and other events occured during the first session.
**2, Users from [target countries](https://github.com/wikimedia/wikipedia-ios/blob/4f02daad6766d7c531dc5817241a37e4d32d9bdf/Wikipedia/Code/UserHistoryFunnel.swift#L4-L9) are not being identified correctly. **
After breaking down the tables by countries, we found that out of the users who sent eventlogging to other tables but not sent snapshots, 17.6% are Germany, 9% are Italy, 8% are France, 6.4% are Japan, 4% are Spain, 4% are Russia, 3.7% are Netherlands, 3.6% are Switzerland, 3.4% are US, 2.7% are Sweden. Because the distribution of the problematic users is not proportional to our user population (we have ~30% user from US, 8.5% from Germany, 7% from UK), this doesn't seem random and may have something to do with our target countries identification.