Skip to content

Commit ca03e08

Browse files
author
Steven Orvell
committed
Factor telemetry to separate module
Also use exclusively in `properties-mixin`
1 parent 8d9219f commit ca03e08

File tree

4 files changed

+65
-48
lines changed

4 files changed

+65
-48
lines changed

lib/mixins/element-mixin.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@
466466
* @suppress {invalidCasts}
467467
*/
468468
_initializeProperties() {
469-
Polymer.telemetry.instanceCount++;
470469
this.constructor.finalize();
471470
// note: finalize template when we have access to `localName` to
472471
// avoid dependence on `is` for polyfilling styling.

lib/mixins/properties-mixin.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
-->
1010

1111
<link rel="import" href="../utils/boot.html">
12+
<link rel="import" href="../utils/telemetry.html">
1213
<link rel="import" href="../utils/mixin.html">
1314
<link rel="import" href="../mixins/properties-changed.html">
1415

@@ -192,6 +193,7 @@
192193
* @return {void}
193194
*/
194195
_initializeProperties() {
196+
Polymer.telemetry.instanceCount++;
195197
this.constructor.finalize();
196198
super._initializeProperties();
197199
}

lib/utils/boot.html

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -61,52 +61,5 @@
6161
};
6262
/* eslint-enable */
6363

64-
/**
65-
* Provides basic tracking of element definitions (registrations) and
66-
* instance counts.
67-
*
68-
* @namespace
69-
* @summary Provides basic tracking of element definitions (registrations) and
70-
* instance counts.
71-
*/
72-
Polymer.telemetry = {
73-
/**
74-
* Total number of Polymer element instances created.
75-
* @type {number}
76-
*/
77-
instanceCount: 0,
78-
/**
79-
* Array of Polymer element classes that have been finalized.
80-
* @type {Array<Polymer.Element>}
81-
*/
82-
registrations: [],
83-
/**
84-
* @param {!PolymerElementConstructor} prototype Element prototype to log
85-
* @this {this}
86-
* @private
87-
*/
88-
_regLog: function(prototype) {
89-
console.log('[' + prototype.is + ']: registered');
90-
},
91-
/**
92-
* Registers a class prototype for telemetry purposes.
93-
* @param {HTMLElement} prototype Element prototype to register
94-
* @this {this}
95-
* @protected
96-
*/
97-
register: function(prototype) {
98-
this.registrations.push(prototype);
99-
Polymer.log && this._regLog(prototype);
100-
},
101-
/**
102-
* Logs all elements registered with an `is` to the console.
103-
* @public
104-
* @this {this}
105-
*/
106-
dumpRegistrations: function() {
107-
this.registrations.forEach(this._regLog);
108-
}
109-
};
110-
11164
})();
11265
</script>

lib/utils/telemetry.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!--
2+
@license
3+
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
4+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7+
Code distributed by Google as part of the polymer project is also
8+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9+
-->
10+
<link rel="import" href="boot.html">
11+
<script>
12+
(function() {
13+
'use strict';
14+
15+
/**
16+
* Provides basic tracking of element definitions (registrations) and
17+
* instance counts.
18+
*
19+
* @namespace
20+
* @summary Provides basic tracking of element definitions (registrations) and
21+
* instance counts.
22+
*/
23+
Polymer.telemetry = {
24+
/**
25+
* Total number of Polymer element instances created.
26+
* @type {number}
27+
*/
28+
instanceCount: 0,
29+
/**
30+
* Array of Polymer element classes that have been finalized.
31+
* @type {Array<Polymer.Element>}
32+
*/
33+
registrations: [],
34+
/**
35+
* @param {!PolymerElementConstructor} prototype Element prototype to log
36+
* @this {this}
37+
* @private
38+
*/
39+
_regLog: function(prototype) {
40+
console.log('[' + prototype.is + ']: registered');
41+
},
42+
/**
43+
* Registers a class prototype for telemetry purposes.
44+
* @param {HTMLElement} prototype Element prototype to register
45+
* @this {this}
46+
* @protected
47+
*/
48+
register: function(prototype) {
49+
this.registrations.push(prototype);
50+
Polymer.log && this._regLog(prototype);
51+
},
52+
/**
53+
* Logs all elements registered with an `is` to the console.
54+
* @public
55+
* @this {this}
56+
*/
57+
dumpRegistrations: function() {
58+
this.registrations.forEach(this._regLog);
59+
}
60+
};
61+
62+
})();
63+
</script>

0 commit comments

Comments
 (0)