UI: Fix GA

My previous change (aosp/1538264) broke analytics.
This is because the semantic of the special "arguments"
are different between a lambda and a function.
In the process of doing so, I discovered other bugs:

Problem: GA was initialized only after the user
  clicked on some sidebar URL. The problem was that
  the initial redraw() call didn't call setRouteOnHash()
  because state.route is still null there. This means that
  we were missing analytics for most people who opened a trace
  via internal dashboards and did stay within the timeline
  viewer (likely most of them).
Fix: trigger an updatePath() at initialization time.

Problem: the isInternalUser dimension was flaky, as
  it could be set after GA is initialized, depending
  on script execution order.
Fix: init GA after the script that sets isInternalUser
  either succeeds or fails.

Problem: the isInternalUser detection was flaky. This
  seems related with the state of SSO cookies. If the UI
  is opened when starting a fresh browser, the requests
  fails. But then succeeds after opening corp gmail.
Fix: make isInternalUser sticky in via localStorage.

Problem: GA errors were detectable only on the
  production/staging URLs. This is because the UI
  was explicitly listing only them, leaving
  localhost out. This makes harder to spot problems
  early.
Fix: add localhost to the set of allowed origins.

Bug: 143973344
Test: manual via https://tagassistant.google.com/
Change-Id: Id074d9ab13e4cb454cacd24adb5b55e2b7668337
7 files changed
tree: e007f0e99d2b8d429633ac9e760117ce77e8bb96
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. src/
  13. test/
  14. tools/
  15. ui/
  16. .clang-format
  17. .clang-tidy
  18. .gitattributes
  19. .gitignore
  20. .gn
  21. .style.yapf
  22. Android.bp
  23. Android.bp.extras
  24. BUILD
  25. BUILD.extras
  26. BUILD.gn
  27. CHANGELOG
  28. codereview.settings
  29. DIR_METADATA
  30. heapprofd.rc
  31. LICENSE
  32. METADATA
  33. MODULE_LICENSE_APACHE2
  34. OWNERS
  35. perfetto.rc
  36. PRESUBMIT.py
  37. README.chromium
  38. README.md
  39. TEST_MAPPING
  40. traced_perf.rc
  41. WORKSPACE
README.md

Perfetto - System profiling, app tracing and trace analysis

Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.

See https://perfetto.dev/docs or the /docs/ directory for documentation.