mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-19 01:14:44 -05:00
Factor telemetry to separate module
Also use exclusively in `properties-mixin`
This commit is contained in:
@@ -466,7 +466,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* @suppress {invalidCasts}
|
||||
*/
|
||||
_initializeProperties() {
|
||||
Polymer.telemetry.instanceCount++;
|
||||
this.constructor.finalize();
|
||||
// note: finalize template when we have access to `localName` to
|
||||
// avoid dependence on `is` for polyfilling styling.
|
||||
|
||||
@@ -9,6 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
-->
|
||||
|
||||
<link rel="import" href="../utils/boot.html">
|
||||
<link rel="import" href="../utils/telemetry.html">
|
||||
<link rel="import" href="../utils/mixin.html">
|
||||
<link rel="import" href="../mixins/properties-changed.html">
|
||||
|
||||
@@ -192,6 +193,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* @return {void}
|
||||
*/
|
||||
_initializeProperties() {
|
||||
Polymer.telemetry.instanceCount++;
|
||||
this.constructor.finalize();
|
||||
super._initializeProperties();
|
||||
}
|
||||
|
||||
@@ -61,52 +61,5 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
||||
/**
|
||||
* Provides basic tracking of element definitions (registrations) and
|
||||
* instance counts.
|
||||
*
|
||||
* @namespace
|
||||
* @summary Provides basic tracking of element definitions (registrations) and
|
||||
* instance counts.
|
||||
*/
|
||||
Polymer.telemetry = {
|
||||
/**
|
||||
* Total number of Polymer element instances created.
|
||||
* @type {number}
|
||||
*/
|
||||
instanceCount: 0,
|
||||
/**
|
||||
* Array of Polymer element classes that have been finalized.
|
||||
* @type {Array<Polymer.Element>}
|
||||
*/
|
||||
registrations: [],
|
||||
/**
|
||||
* @param {!PolymerElementConstructor} prototype Element prototype to log
|
||||
* @this {this}
|
||||
* @private
|
||||
*/
|
||||
_regLog: function(prototype) {
|
||||
console.log('[' + prototype.is + ']: registered');
|
||||
},
|
||||
/**
|
||||
* Registers a class prototype for telemetry purposes.
|
||||
* @param {HTMLElement} prototype Element prototype to register
|
||||
* @this {this}
|
||||
* @protected
|
||||
*/
|
||||
register: function(prototype) {
|
||||
this.registrations.push(prototype);
|
||||
Polymer.log && this._regLog(prototype);
|
||||
},
|
||||
/**
|
||||
* Logs all elements registered with an `is` to the console.
|
||||
* @public
|
||||
* @this {this}
|
||||
*/
|
||||
dumpRegistrations: function() {
|
||||
this.registrations.forEach(this._regLog);
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<link rel="import" href="boot.html">
|
||||
<script>
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Provides basic tracking of element definitions (registrations) and
|
||||
* instance counts.
|
||||
*
|
||||
* @namespace
|
||||
* @summary Provides basic tracking of element definitions (registrations) and
|
||||
* instance counts.
|
||||
*/
|
||||
Polymer.telemetry = {
|
||||
/**
|
||||
* Total number of Polymer element instances created.
|
||||
* @type {number}
|
||||
*/
|
||||
instanceCount: 0,
|
||||
/**
|
||||
* Array of Polymer element classes that have been finalized.
|
||||
* @type {Array<Polymer.Element>}
|
||||
*/
|
||||
registrations: [],
|
||||
/**
|
||||
* @param {!PolymerElementConstructor} prototype Element prototype to log
|
||||
* @this {this}
|
||||
* @private
|
||||
*/
|
||||
_regLog: function(prototype) {
|
||||
console.log('[' + prototype.is + ']: registered');
|
||||
},
|
||||
/**
|
||||
* Registers a class prototype for telemetry purposes.
|
||||
* @param {HTMLElement} prototype Element prototype to register
|
||||
* @this {this}
|
||||
* @protected
|
||||
*/
|
||||
register: function(prototype) {
|
||||
this.registrations.push(prototype);
|
||||
Polymer.log && this._regLog(prototype);
|
||||
},
|
||||
/**
|
||||
* Logs all elements registered with an `is` to the console.
|
||||
* @public
|
||||
* @this {this}
|
||||
*/
|
||||
dumpRegistrations: function() {
|
||||
this.registrations.forEach(this._regLog);
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user