OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2014 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/guid.html"> | 8 <link rel="import" href="/tracing/base/guid.html"> |
9 <link rel="import" href="/tracing/base/utils.html"> | 9 <link rel="import" href="/tracing/base/utils.html"> |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 class Timing { | 74 class Timing { |
75 static mark(groupName, functionName) { | 75 static mark(groupName, functionName) { |
76 return new Mark(groupName, functionName); | 76 return new Mark(groupName, functionName); |
77 } | 77 } |
78 | 78 |
79 static instant(groupName, functionName, opt_value) { | 79 static instant(groupName, functionName, opt_value) { |
80 const valueString = opt_value === undefined ? '' : ' ' + opt_value; | 80 const valueString = opt_value === undefined ? '' : ' ' + opt_value; |
81 // eslint-disable-next-line no-console | |
82 console.timeStamp(`${groupName} ${functionName}${valueString}`); | |
83 | 81 |
84 if (!(window.ga instanceof Function)) return; | 82 /* eslint-disable no-console */ |
| 83 if (console && console.timeStamp) { |
| 84 console.timeStamp(`${groupName} ${functionName}${valueString}`); |
| 85 } |
| 86 /* eslint-enable no-console */ |
| 87 |
85 // Google Analytics | 88 // Google Analytics |
86 ga('send', { | 89 if (window && window.ga instanceof Function) { |
87 hitType: 'event', | 90 ga('send', { |
88 eventCategory: groupName, | 91 hitType: 'event', |
89 eventAction: functionName, | 92 eventCategory: groupName, |
90 eventValue: opt_value, | 93 eventAction: functionName, |
91 }); | 94 eventValue: opt_value, |
| 95 }); |
| 96 } |
92 } | 97 } |
93 } | 98 } |
94 | 99 |
95 return { | 100 return { |
96 Timing, | 101 Timing, |
97 }; | 102 }; |
98 }); | 103 }); |
99 </script> | 104 </script> |
OLD | NEW |