Cleanup on the "email_chosen" state and reduce duplication of code.

* Code that decided how to handle transition states and clear certs was sprinkled throughout the code, making it difficult to maintain.
* Move cert invalidation that happened in state.js into user.js.
* Rename user.js->checkEmailIssuer to checkForInvalidCerts
* Simplify checkForInvalidCerts
* Add more unit tests.
Submit KPI data when the dialog closes either in the interaction_iframe OR in the internal_api.

Only generate GUIDs for a KPI blob whenever needed:

* When the dialog is orphaned AND
* A staging event occurs without a confirmation event.
'native' is reserved on Android 2.2, so access it array-style. Fixes 3522.
Instead of sending a GUID to associate two KPI blobs, set "staging_continuation" in the event stream.
Fix a couple instances of reserved word 'native' in tests.
Merge pull request #3534 from 6a68/issue_3522_fml_android22

'native' is reserved on Android 2.2, so access it array-style.
Merge pull request #3495 from shane-tomlinson/issue_3306_kpi_this_session

Submit KPI data when the dialog closes either in the interaction_iframe OR in the internal_api.
Make sure all expected KPIs are sent.

~ 4% of the KPI blobs were missing:
* number_emails
* number_sites_signed_in
* number_sites_remembered
* orphaned

The problem is that occasionally, the window would unload before the onbeforeunload handler could set the last KPIs.

Since KPIs are now sent in the communication iframe instead of in the dialog, the last remaining KPIs are set there before sending the blobs.

orphaned now means, 100% of the time, no assertion was generated in the dialog.

fixes #2280
Merge pull request #3517 from shane-tomlinson/refactor_simplify_email_chosen

Cleanup on the "email_chosen" state and reduce duplication of code.
Merge pull request #3516 from mozilla/issue_2280_missing_kpi_fields

Issue 2280 missing kpi fields

This had an r+ already, merging!
my previous "fix" was wrong in some cases; this is perfect now!
Merge pull request #3542 from jrgm/fix-inspect-localstorage

fix scripts/inspect_localstorage to handle both old-style, issuer groups and mixed.
Fix the "Unmatched start" error.

fixes #3543
Merge pull request #3544 from mozilla/issue_3543-unmatched-start

Fix the "Unmatched start" error.
Stop using [].indexOf - ie8 doesn't have it.

Use _.indexOf instead

fixes #3548
Fix the "transition_to_primary" upgrade.

fixes #3551
Add Selenium and Frontend tests for #3551
Merge pull request #3549 from mozilla/issue_3548_ie8_error

Stop using [].indexOf - ie8 doesn't have it.
Simplify and clarify the Selenium and front end tests.

* To Selenium, simplify the tests.
* To Selenium, add better commenting.
* To Frontend tests, clarify the transition_to_secondary test names to be self explanatory.
Update package.json metadata, fixes #3555