Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: packages/usage/example/example.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packages/usage/changelog.md ('k') | packages/usage/example/ga.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /// A simple web app to hand-test the usage library.
6 * A simple web app to hand-test the usage library.
7 */
8 library usage_example; 6 library usage_example;
9 7
10 import 'dart:html'; 8 import 'dart:html';
11 9
12 import 'package:usage/usage_html.dart'; 10 import 'package:usage/usage_html.dart';
13 11
14 Analytics _analytics; 12 Analytics _analytics;
15 String _lastUa; 13 String _lastUa;
16 int _count = 0; 14 int _count = 0;
17 15
18 void main() { 16 void main() {
19 querySelector('#foo').onClick.listen((_) => _handleFoo(getAnalytics())); 17 querySelector('#foo').onClick.listen((_) => _handleFoo());
20 querySelector('#bar').onClick.listen((_) => _handleBar(getAnalytics())); 18 querySelector('#bar').onClick.listen((_) => _handleBar());
21 querySelector('#page').onClick.listen((_) => _changePage(getAnalytics())); 19 querySelector('#page').onClick.listen((_) => _changePage());
22 } 20 }
23 21
24 String _ua() => (querySelector('#ua') as InputElement).value.trim(); 22 String _ua() => (querySelector('#ua') as InputElement).value.trim();
25 23
26 Analytics getAnalytics() { 24 Analytics getAnalytics() {
27 if (_analytics == null || _lastUa != _ua()) { 25 if (_analytics == null || _lastUa != _ua()) {
28 _lastUa = _ua(); 26 _lastUa = _ua();
29 _analytics = new AnalyticsHtml(_lastUa, 'Test app', '1.0'); 27 _analytics = new AnalyticsHtml(_lastUa, 'Test app', '1.0');
30 _analytics.sendScreenView(window.location.pathname); 28 _analytics.sendScreenView(window.location.pathname);
31 } 29 }
32 30
33 return _analytics; 31 return _analytics;
34 } 32 }
35 33
36 void _handleFoo(Analytics analytics) { 34 void _handleFoo() {
35 Analytics analytics = getAnalytics();
37 analytics.sendEvent('main', 'foo'); 36 analytics.sendEvent('main', 'foo');
38 } 37 }
39 38
40 void _handleBar(Analytics analytics) { 39 void _handleBar() {
40 Analytics analytics = getAnalytics();
41 analytics.sendEvent('main', 'bar'); 41 analytics.sendEvent('main', 'bar');
42 } 42 }
43 43
44 void _changePage(Analytics analytics) { 44 void _changePage() {
45 Analytics analytics = getAnalytics();
45 window.history.pushState(null, 'new page', '${++_count}.html'); 46 window.history.pushState(null, 'new page', '${++_count}.html');
46 analytics.sendScreenView(window.location.pathname); 47 analytics.sendScreenView(window.location.pathname);
47 } 48 }
OLDNEW
« no previous file with comments | « packages/usage/changelog.md ('k') | packages/usage/example/ga.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698