@eo-logger/client
Advanced tools
+0
-1
@@ -5,3 +5,2 @@ import { Context as BaseContext, ECS, Logger as BaseLogger, LoggerParams } from '@eo-logger/core'; | ||
| constructor(params: LoggerParams); | ||
| collectMetrics(): void; | ||
| } | ||
@@ -8,0 +7,0 @@ export declare class Context extends BaseContext { |
+14
-11
@@ -6,2 +6,3 @@ "use strict"; | ||
| var core_1 = require("@eo-logger/core"); | ||
| var web_vitals_1 = require("web-vitals"); | ||
| var utils_1 = require("./utils"); | ||
@@ -18,15 +19,15 @@ tslib_1.__exportStar(require("./utils"), exports); | ||
| }); | ||
| var saveMetric = function (metric) { | ||
| var _a; | ||
| _this.context.setMetrics((_a = {}, | ||
| _a[metric.name] = metric.value, | ||
| _a)); | ||
| }; | ||
| web_vitals_1.getCLS(saveMetric); | ||
| web_vitals_1.getFCP(saveMetric); | ||
| web_vitals_1.getFID(saveMetric); | ||
| web_vitals_1.getLCP(saveMetric); | ||
| web_vitals_1.getTTFB(saveMetric); | ||
| return _this; | ||
| } | ||
| Logger.prototype.collectMetrics = function () { | ||
| var performanceMetrics = utils_1.getPerformanceMetrics(); | ||
| if (performanceMetrics) { | ||
| this.context.setMetrics(performanceMetrics); | ||
| } | ||
| this.debug('metrics', { | ||
| networkInformation: utils_1.getNetworkInformation(), | ||
| screen: utils_1.getScreenInformation(), | ||
| }); | ||
| this.context.clearMetrics(); | ||
| }; | ||
| return Logger; | ||
@@ -48,2 +49,4 @@ }(core_1.Logger)); | ||
| }; | ||
| ecsMessage.networkInformation = utils_1.getNetworkInformation(); | ||
| ecsMessage.screen = utils_1.getScreenInformation(); | ||
| return ecsMessage; | ||
@@ -50,0 +53,0 @@ }; |
+0
-1
| import { ECS } from '@eo-logger/core'; | ||
| export declare function getScreenInformation(): Record<string, string> | undefined; | ||
| export declare function getPerformanceMetrics(): Record<string, number> | undefined; | ||
| export declare function getNetworkInformation(): ECS.NetworkInformation | undefined; |
+1
-20
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getNetworkInformation = exports.getPerformanceMetrics = exports.getScreenInformation = void 0; | ||
| exports.getNetworkInformation = exports.getScreenInformation = void 0; | ||
| function getScreenInformation() { | ||
@@ -16,21 +16,2 @@ try { | ||
| exports.getScreenInformation = getScreenInformation; | ||
| function getPerformanceMetrics() { | ||
| try { | ||
| var _a = window.performance.timing, domComplete = _a.domComplete, domLoading = _a.domLoading, domInteractive = _a.domInteractive, navigationStart = _a.navigationStart; | ||
| var metrics = {}; | ||
| if (domComplete > 0) { | ||
| metrics.domComplete = domComplete - domLoading; | ||
| metrics.domCompleteFull = domComplete - navigationStart; | ||
| } | ||
| if (domInteractive > 0) { | ||
| metrics.domInteractive = domInteractive - domLoading; | ||
| metrics.domInteractiveFull = domInteractive - navigationStart; | ||
| } | ||
| return metrics; | ||
| } | ||
| catch (error) { | ||
| console.error(error); | ||
| } | ||
| } | ||
| exports.getPerformanceMetrics = getPerformanceMetrics; | ||
| function getNetworkInformation() { | ||
@@ -37,0 +18,0 @@ try { |
+5
-5
| { | ||
| "name": "@eo-logger/client", | ||
| "version": "1.0.1", | ||
| "version": "1.1.0", | ||
| "description": "Client part of eo-logger", | ||
@@ -25,5 +25,5 @@ "author": "Maksim Sharipov <m.v.sharipov@gmail.com>", | ||
| "scripts": { | ||
| "build": "rm -rf lib && tsc", | ||
| "build": "tsc", | ||
| "postbuild": "size-limit", | ||
| "prepublish": "npm run build" | ||
| "prepublish": "rm -rf lib && npm run build" | ||
| }, | ||
@@ -34,3 +34,3 @@ "bugs": { | ||
| "dependencies": { | ||
| "@eo-logger/core": "^1.0.1", | ||
| "@eo-logger/core": "^1.1.0", | ||
| "web-vitals": "^0.2.2" | ||
@@ -50,3 +50,3 @@ }, | ||
| ], | ||
| "gitHead": "c5a9e80337ff9c4d702bf6e636168bbfa27f0839" | ||
| "gitHead": "4cf14877c27f2f5584c0a1269bd33a37b93314f9" | ||
| } |
4586
-13.89%95
-15.93%Updated