From ca03e08df8d4817a08d4082ed771d7d956b772ae Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 1 Nov 2018 12:45:08 -0700 Subject: [PATCH] Factor telemetry to separate module Also use exclusively in `properties-mixin` --- lib/mixins/element-mixin.html | 1 - lib/mixins/properties-mixin.html | 2 + lib/utils/boot.html | 47 ------------------------ lib/utils/telemetry.html | 63 ++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 48 deletions(-) create mode 100644 lib/utils/telemetry.html diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html index dce111c712..c64178e3fd 100644 --- a/lib/mixins/element-mixin.html +++ b/lib/mixins/element-mixin.html @@ -466,7 +466,6 @@ * @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. diff --git a/lib/mixins/properties-mixin.html b/lib/mixins/properties-mixin.html index 728dea2400..0e6da40389 100644 --- a/lib/mixins/properties-mixin.html +++ b/lib/mixins/properties-mixin.html @@ -9,6 +9,7 @@ --> + @@ -192,6 +193,7 @@ * @return {void} */ _initializeProperties() { + Polymer.telemetry.instanceCount++; this.constructor.finalize(); super._initializeProperties(); } diff --git a/lib/utils/boot.html b/lib/utils/boot.html index 4ea0412c7d..3cd64cdf83 100644 --- a/lib/utils/boot.html +++ b/lib/utils/boot.html @@ -61,52 +61,5 @@ }; /* 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} - */ - 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); - } - }; - })(); diff --git a/lib/utils/telemetry.html b/lib/utils/telemetry.html new file mode 100644 index 0000000000..9e4d45bfd5 --- /dev/null +++ b/lib/utils/telemetry.html @@ -0,0 +1,63 @@ + + +