From d9a6996ed56eceaab61d234dfb1c89cca3a17523 Mon Sep 17 00:00:00 2001 From: Joan Leon Date: Mon, 14 Oct 2024 12:46:45 +0200 Subject: [PATCH] refactor(packages/sui-logger): rename Reporter and migraet to SWC --- package-lock.json | 189 +++++++----------- packages/sui-logger/README.md | 50 ++--- packages/sui-logger/package.json | 5 +- packages/sui-logger/src/index.js | 4 +- packages/sui-logger/test/browser/indexSpec.js | 26 +-- packages/sui-logger/test/server/indexSpec.js | 26 +-- 6 files changed, 132 insertions(+), 168 deletions(-) diff --git a/package-lock.json b/package-lock.json index 483083d91..c5bed7e2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,9 +85,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.7.tgz", - "integrity": "sha512-9ickoLz+hcXCeh7jrcin+/SLWm+GkxE2kTvoYyp38p4WkdFXfQJxDFGWp/YHjiKLPx06z2A7W8XKuqbReXDzsw==", + "version": "7.25.8", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.8.tgz", + "integrity": "sha512-ZsysZyXY4Tlx+Q53XdnOFmqwfB9QDTHYxaZYajWRoBLuLEAwI2UIbtxOjWh/cFaa9IKUlcB+DDuoskLuKu56JA==", "engines": { "node": ">=6.9.0" } @@ -452,11 +452,11 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.7.tgz", - "integrity": "sha512-aZn7ETtQsjjGG5HruveUK06cU3Hljuhd9Iojm4M8WWv3wLE6OkE5PWbDUkItmMgegmccaITudyuW5RPYrYlgWw==", + "version": "7.25.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.8.tgz", + "integrity": "sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==", "dependencies": { - "@babel/types": "^7.25.7" + "@babel/types": "^7.25.8" }, "bin": { "parser": "bin/babel-parser.js" @@ -1346,13 +1346,12 @@ } }, "node_modules/@babel/plugin-transform-optional-chaining": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.25.7.tgz", - "integrity": "sha512-h39agClImgPWg4H8mYVAbD1qP9vClFbEjqoJmt87Zen8pjqK8FTPUwrOXAvqu5soytwxrLMd2fx2KSCp2CHcNg==", + "version": "7.25.8", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.25.8.tgz", + "integrity": "sha512-q05Bk7gXOxpTHoQ8RSzGSh/LHVB9JEIkKnk3myAWwZHnYiTGYtbdrYkIsS8Xyh4ltKf7GNUSgzs/6P2bJtBAQg==", "dependencies": { "@babel/helper-plugin-utils": "^7.25.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.25.7", - "@babel/plugin-syntax-optional-chaining": "^7.8.3" + "@babel/helper-skip-transparent-expression-wrappers": "^7.25.7" }, "engines": { "node": ">=6.9.0" @@ -1849,9 +1848,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.7.tgz", - "integrity": "sha512-vwIVdXG+j+FOpkwqHRcBgHLYNL7XMkufrlaFvL9o6Ai9sJn9+PdyIL5qa0XzTZw084c+u9LOls53eoZWP/W5WQ==", + "version": "7.25.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz", + "integrity": "sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==", "dependencies": { "@babel/helper-string-parser": "^7.25.7", "@babel/helper-validator-identifier": "^7.25.7", @@ -3072,9 +3071,9 @@ } }, "node_modules/@jest/reporters/node_modules/@babel/core": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.7.tgz", - "integrity": "sha512-yJ474Zv3cwiSOO9nXJuqzvwEeM+chDuQ8GJirw+pZ91sCGCyOZ3dJkVE09fTV0VEVzXyLWhh3G/AolYTPX7Mow==", + "version": "7.25.8", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.8.tgz", + "integrity": "sha512-Oixnb+DzmRT30qu9d3tJSQkxuygWm32DFykT4bRoORPa9hZ/L4KhVB/XiRm6KG+roIEM7DBQlmg27kw2HZkdZg==", "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.25.7", @@ -3082,10 +3081,10 @@ "@babel/helper-compilation-targets": "^7.25.7", "@babel/helper-module-transforms": "^7.25.7", "@babel/helpers": "^7.25.7", - "@babel/parser": "^7.25.7", + "@babel/parser": "^7.25.8", "@babel/template": "^7.25.7", "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7", + "@babel/types": "^7.25.8", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -5173,11 +5172,11 @@ } }, "node_modules/@types/jsdom/node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.0.tgz", + "integrity": "sha512-ZkDsAOcxsUMZ4Lz5fVciOehNcJ+Gb8gTzcA4yl3wnc273BAybYWrQ+Ks/OjCjSEpjvQkDSeZbybK9qj2VHHdGA==", "dependencies": { - "entities": "^4.4.0" + "entities": "^4.5.0" }, "funding": { "url": "https://github.com/inikulin/parse5?sponsor=1" @@ -5288,18 +5287,38 @@ } }, "node_modules/@types/request/node_modules/form-data": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.2.tgz", + "integrity": "sha512-GgwY0PS7DbXqajuGf4OYlsrIu3zgxD6Vvql43IBhm6MahqA5SK/7mwhtNj2AdH2z35YR34ujJ7BN+3fFC3jP5Q==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" + "mime-types": "^2.1.12", + "safe-buffer": "^5.2.1" }, "engines": { "node": ">= 0.12" } }, + "node_modules/@types/request/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/@types/retry": { "version": "0.12.2", "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.2.tgz", @@ -7383,9 +7402,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001667", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001667.tgz", - "integrity": "sha512-7LTwJjcRkzKFmtqGsibMeuXmvFDfZq/nzIjnmgCGzKKRVzjD72selLDK1oPF/Oxzmt4fNcPvTDvGqSDG4tCALw==", + "version": "1.0.30001668", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001668.tgz", + "integrity": "sha512-nWLrdxqCdblixUO+27JtGJJE/txpJlyUy5YN1u53wLZkP0emYCo5zgS6QYft7VUYR42LGgi/S5hdLZTrnyIddw==", "funding": [ { "type": "opencollective", @@ -9697,9 +9716,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.5.33", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.33.tgz", - "integrity": "sha512-+cYTcFB1QqD4j4LegwLfpCNxifb6dDFUAwk6RsLusCwIaZI6or2f+q8rs5tTB2YC53HhOlIbEaqHMAAC8IOIwA==" + "version": "1.5.36", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.36.tgz", + "integrity": "sha512-HYTX8tKge/VNp6FGO+f/uVDmUkq+cEfcxYhKf15Akc4M5yxt5YmorwlAitKWjWhWQnKcDRBAQKXkhqqXMqcrjw==" }, "node_modules/element-polyfill": { "version": "1.1.0", @@ -9756,16 +9775,16 @@ } }, "node_modules/engine.io": { - "version": "6.6.1", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.1.tgz", - "integrity": "sha512-NEpDCw9hrvBW+hVEOK4T7v0jFJ++KgtPl4jKFwsZVfG1XhS0dCrSb3VMb9gPAd7VAdW52VT1EnaNiU2vM8C0og==", + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.2.tgz", + "integrity": "sha512-gmNvsYi9C8iErnZdVcJnvCpSKbWTt1E8+JZo8b+daLninywUWi5NQ5STSHZ9rFjFO7imNcvb8Pc5pe/wMR5xEw==", "dependencies": { "@types/cookie": "^0.4.1", "@types/cors": "^2.8.12", "@types/node": ">=10.0.0", "accepts": "~1.3.4", "base64id": "2.0.0", - "cookie": "~0.4.1", + "cookie": "~0.7.2", "cors": "~2.8.5", "debug": "~4.3.1", "engine.io-parser": "~5.2.1", @@ -9784,9 +9803,9 @@ } }, "node_modules/engine.io/node_modules/cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", "engines": { "node": ">= 0.6" } @@ -12052,9 +12071,9 @@ } }, "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -16976,11 +16995,11 @@ } }, "node_modules/jsdom/node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.0.tgz", + "integrity": "sha512-ZkDsAOcxsUMZ4Lz5fVciOehNcJ+Gb8gTzcA4yl3wnc273BAybYWrQ+Ks/OjCjSEpjvQkDSeZbybK9qj2VHHdGA==", "dependencies": { - "entities": "^4.4.0" + "entities": "^4.5.0" }, "funding": { "url": "https://github.com/inikulin/parse5?sponsor=1" @@ -18893,9 +18912,9 @@ } }, "node_modules/nan": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz", - "integrity": "sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz", + "integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==", "optional": true }, "node_modules/nanoid": { @@ -25096,9 +25115,9 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/webpack-dev-server/node_modules/memfs": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/memfs/-/memfs-4.13.0.tgz", - "integrity": "sha512-dIs5KGy24fbdDhIAg0RxXpFqQp3RwL6wgSMRF9OSuphL/Uc9a4u2/SDJKPLj/zUgtOGKuHrRMrj563+IErj4Cg==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-4.14.0.tgz", + "integrity": "sha512-JUeY0F/fQZgIod31Ja1eJgiSxLn7BfQlCnqhwXFBzFHEw63OdLK7VJUJ7bnzNsWgCyoUP5tEp1VRY8rDaYzqOA==", "dependencies": { "@jsonjoy.com/json-pack": "^1.0.3", "@jsonjoy.com/util": "^1.3.0", @@ -26588,7 +26607,7 @@ }, "packages/sui-logger": { "name": "@s-ui/logger", - "version": "1.0.0-beta0", + "version": "1.1.0", "license": "MIT", "dependencies": { "@s-ui/react-router": "1", @@ -26597,12 +26616,11 @@ "hot-shots": "7.7.1" }, "devDependencies": { - "@babel/cli": "7.15.7", "@s-ui/bundler": "9", + "@s-ui/js-compiler": "1", "@s-ui/lint": "4", "@s-ui/mono": "2", "@s-ui/test": "8", - "babel-preset-sui": "3", "chai": "4.3.4", "react": "17", "sinon": "11.1.2" @@ -26611,35 +26629,6 @@ "react": "16 || 17" } }, - "packages/sui-logger/node_modules/@babel/cli": { - "version": "7.15.7", - "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.15.7.tgz", - "integrity": "sha512-YW5wOprO2LzMjoWZ5ZG6jfbY9JnkDxuHDwvnrThnuYtByorova/I0HNXJedrUfwuXFQfYOjcqDA4PU3qlZGZjg==", - "dev": true, - "dependencies": { - "commander": "^4.0.1", - "convert-source-map": "^1.1.0", - "fs-readdir-recursive": "^1.1.0", - "glob": "^7.0.0", - "make-dir": "^2.1.0", - "slash": "^2.0.0", - "source-map": "^0.5.0" - }, - "bin": { - "babel": "bin/babel.js", - "babel-external-helpers": "bin/babel-external-helpers.js" - }, - "engines": { - "node": ">=6.9.0" - }, - "optionalDependencies": { - "@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents.3", - "chokidar": "^3.4.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, "packages/sui-logger/node_modules/@sinonjs/commons": { "version": "1.8.6", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", @@ -26686,21 +26675,6 @@ "node": ">=4" } }, - "packages/sui-logger/node_modules/commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "packages/sui-logger/node_modules/convert-source-map": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", - "dev": true - }, "packages/sui-logger/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -26772,15 +26746,6 @@ "url": "https://opencollective.com/sinon" } }, - "packages/sui-logger/node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "packages/sui-logger/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -26897,7 +26862,7 @@ }, "packages/sui-pde": { "name": "@s-ui/pde", - "version": "2.26.0", + "version": "2.28.0", "license": "MIT", "dependencies": { "@optimizely/optimizely-sdk": "5.3.4", @@ -27153,7 +27118,7 @@ }, "packages/sui-segment-wrapper": { "name": "@s-ui/segment-wrapper", - "version": "4.4.0", + "version": "4.5.0", "license": "ISC", "dependencies": { "@s-ui/js": "2", diff --git a/packages/sui-logger/README.md b/packages/sui-logger/README.md index 6d6ea2913..73f85fd32 100644 --- a/packages/sui-logger/README.md +++ b/packages/sui-logger/README.md @@ -8,19 +8,19 @@ - [Table of contents](#table-of-contents) - [Installation](#installation) - [Application logging](#application-logging) - - [Client side logging with mushroom](#client-side-logging-with-mushroom) + - [Client side logging with reporter](#client-side-logging-with-reporter) - [Server side logging](#server-side-logging) - [With Stdout](#with-stdout) - - [With Mushroom](#with-mushroom) - - [How to consume Mushroom logs](#how-to-consume-mushroom-logs) + - [With Reporter](#with-reporter) + - [How to consume Reporter logs](#how-to-consume-reporter-logs) - [Server logging](#server-logging) - [Express middleware for sui-ssr logging hook](#express-middleware-for-sui-ssr-logging-hook) - [StdoutLogger](#stdoutlogger) - [DataDogLogger](#datadoglogger) - - [Express middleware for sui-ssr logging hook using Mushroom](#express-middleware-for-sui-ssr-logging-hook-using-mushroom) + - [Express middleware for sui-ssr logging hook using Reporter](#express-middleware-for-sui-ssr-logging-hook-using-reporter) - [Tracking page fetching](#tracking-page-fetching) - [Consume Stdout logs](#consume-stdout-logs) - - [Consume Mushroom logs](#consume-mushroom-logs) + - [Consume Reporter logs](#consume-reporter-logs) ## Installation @@ -28,21 +28,21 @@ ## Application logging -### Client side logging with mushroom +### Client side logging with reporter To start logging client-side logs in our application, we should initialize our tracker. ```js // app.js -import {Mushroom} from '@adv-ui/mushroom' // Service Logger +import {Reporter} from '@adv-ui/reporter' // Service Logger import {initTracker} from '@s-ui/logger' -initTracker({Mushroom, appName: 'milanuncios', environment: 'production', devMode: false}) +initTracker({Reporter, appName: 'milanuncios', environment: 'production', devMode: false}) ``` Options: -- **`Mushroom` {Function}** - Application Logger +- **`Reporter` {Function}** - Application Logger - **`appName` {String}** - Application name - **`devMode` {String}** - Allows sending events to the development endpoint, Production endpoint is used by default. - **`environment` {String}** - Optionally set the environment property to be used as part of the context (e.g. `preproduction` or `production`). If not set `NODE_ENV` will be used as default value @@ -64,7 +64,7 @@ Options: - **`userId` {String}** - User id to add to all logs - **`trackerName` {String}** [optional] - Tracker name that will be used by the microservice - > 💡 Please note that, if you decide to use a custom trackerName, you'd need to create a custom provider inside the ms-adit--mushroom microservice. + > 💡 Please note that, if you decide to use a custom trackerName, you'd need to create a custom provider inside the ms-adit--reporter microservice. ### Server side logging @@ -100,21 +100,21 @@ export const getLogger = ({req}) => { Enabled by default, there is a ENV var to disable it `DISABLE_SERVER_LOGGER_PATCH=true`. This help us to disable without compile app again. -#### With Mushroom +#### With Reporter To start logging server-side logs in our application, we should initialize our tracker in one server file ```js // app.js -import {Mushroom} from '@adv-ui/mushroom' // Service Logger +import {Reporter} from '@adv-ui/reporter' // Service Logger import {initTracker} from '@s-ui/logger' -initTracker({Mushroom, appName: 'milanuncios', devMode: false}) +initTracker({Reporter, appName: 'milanuncios', devMode: false}) ``` Options: -- **`Mushroom` {Function}** - Service Logger +- **`Reporter` {Function}** - Service Logger - **`appName` {String}** - Application name - **`devMode` {String}** - Allows sending events to the development endpoint, Production endpoint is used by default. - **`...rest`** - See your Service Logger client configuration @@ -137,9 +137,9 @@ Options: - **`userId` {String}** - User id to add to all logs -#### How to consume Mushroom logs +#### How to consume Reporter logs -When we create a mushroom logger function, we get a logger with three methods: `error`, `log` and `metric`. +When we create a reporter logger function, we get a logger with three methods: `error`, `log` and `metric`. **Error method** @@ -151,9 +151,9 @@ logger.error(new Error('Something went wrong')) We could consume in **ELK**: -- `mushroom.errorMessage`: {string} -- `mushroom.errorName`: {string} -- `mushroom.errorStack`: {string} +- `reporter.errorMessage`: {string} +- `reporter.errorName`: {string} +- `reporter.errorStack`: {string} **Patch native console.error** @@ -165,9 +165,9 @@ console.error(new Error('Something went wrong')) We could consume in **ELK**: -- `mushroom.errorMessage`: {string} -- `mushroom.errorName`: {string} -- `mushroom.errorStack`: {string} +- `reporter.errorMessage`: {string} +- `reporter.errorName`: {string} +- `reporter.errorStack`: {string} **Log method** @@ -215,7 +215,7 @@ It accepts a `Metric` object containing a `name` and `tags` [Metric type definition](./src/logger.js#73) -> 💡 Please note that in order for metrics to work, you'd need to create a custom provider inside the ms-adit--mushroom microservice. +> 💡 Please note that in order for metrics to work, you'd need to create a custom provider inside the ms-adit--reporter microservice. ```js logger.metric({ @@ -236,7 +236,7 @@ It accepts a `Timing` object containing a `name`, `amount` and `tags` [Metric type definition](./src/logger.js#94) -> 💡 Please note that similarly to previous method in order to make it work, you'd need to create a custom provider inside the ms-adit--mushroom microservice. +> 💡 Please note that similarly to previous method in order to make it work, you'd need to create a custom provider inside the ms-adit--reporter microservice. ```js logger.timing({ @@ -400,7 +400,7 @@ Options: - **`globalTags` {Object}** - This properties will be used in `globalTags` param on `hot-shots` client creation. It should have at least this attribute `{node_ssr: 'app_name'}` - **`routes` {import('react').ComponentType}** - React routes -#### Express middleware for sui-ssr logging hook using Mushroom +#### Express middleware for sui-ssr logging hook using Reporter `@s-ui/ssr` accepts hooks (express middlewares), one of them is for logging and we could add here our logging hook. diff --git a/packages/sui-logger/package.json b/packages/sui-logger/package.json index 475d5a888..8ad0743c8 100644 --- a/packages/sui-logger/package.json +++ b/packages/sui-logger/package.json @@ -4,7 +4,7 @@ "description": "Web app logger for both client and server side", "main": "lib/index.js", "scripts": { - "lib": "babel --presets sui ./src --out-dir ./lib", + "lib": "sui-js-compiler", "lint": "sui-lint js", "prepublishOnly": "rm -rf ./lib && npm run lib", "test": "npm run test:server && npm run test:browser", @@ -22,12 +22,11 @@ "hot-shots": "7.7.1" }, "devDependencies": { - "@babel/cli": "7.15.7", "@s-ui/bundler": "9", + "@s-ui/js-compiler": "1", "@s-ui/lint": "4", "@s-ui/mono": "2", "@s-ui/test": "8", - "babel-preset-sui": "3", "chai": "4.3.4", "react": "17", "sinon": "11.1.2" diff --git a/packages/sui-logger/src/index.js b/packages/sui-logger/src/index.js index 431393588..e0410ab8b 100644 --- a/packages/sui-logger/src/index.js +++ b/packages/sui-logger/src/index.js @@ -5,10 +5,10 @@ export {createClientLogger} from './client.js' export {createServerLogger, logErrorsMiddleware} from './server.js' export {traceInitialProps} from './traceInitialProps.js' -export const initTracker = ({Mushroom, appName, environment, version, tenant, ...config}) => { +export const initTracker = ({Reporter, appName, environment, version, tenant, ...config}) => { const context = {environment: environment || NODE_ENV, isServer, version, tenant} - Mushroom.start(appName, { + Reporter.start(appName, { ...config, context }) diff --git a/packages/sui-logger/test/browser/indexSpec.js b/packages/sui-logger/test/browser/indexSpec.js index df5895427..5398d9460 100644 --- a/packages/sui-logger/test/browser/indexSpec.js +++ b/packages/sui-logger/test/browser/indexSpec.js @@ -3,51 +3,51 @@ import sinon from 'sinon' import {initTracker} from '../../src/index.js' -const Mushroom = { +const Reporter = { start: () => {} } describe('initTracker', () => { - let mushroomStub + let reporterStub beforeEach(() => { - mushroomStub = sinon.stub(Mushroom, 'start') + reporterStub = sinon.stub(Reporter, 'start') }) afterEach(() => { - mushroomStub.restore() + reporterStub.restore() }) it('initialize tracker with the expected config', () => { - initTracker({Mushroom, appName: 'test', version: '1.0.0', config: {foo: 'bar'}}) + initTracker({Reporter, appName: 'test', version: '1.0.0', config: {foo: 'bar'}}) - expect(mushroomStub.calledOnce).to.equal(true) - mushroomStub.calledWith('test', { + expect(reporterStub.calledOnce).to.equal(true) + reporterStub.calledWith('test', { config: {foo: 'bar'}, context: {environment: undefined, isServer: 'false', version: '1.0.0'} }) }) it('initialize tracker with tenant', () => { - initTracker({Mushroom, appName: 'test', version: '1.0.0', tenant: 'infojobs', config: {foo: 'bar'}}) + initTracker({Reporter, appName: 'test', version: '1.0.0', tenant: 'infojobs', config: {foo: 'bar'}}) - expect(mushroomStub.calledOnce).to.equal(true) - mushroomStub.calledWith('test', { + expect(reporterStub.calledOnce).to.equal(true) + reporterStub.calledWith('test', { config: {foo: 'bar'}, context: {environment: undefined, isServer: 'false', version: '1.0.0', tenant: 'infojobs'} }) }) it('initialize tracker with a defined environment', () => { initTracker({ - Mushroom, + Reporter, appName: 'test', environment: 'production', version: '1.0.0', config: {} }) - expect(mushroomStub.calledOnce).to.equal(true) + expect(reporterStub.calledOnce).to.equal(true) expect( - mushroomStub.calledWith('test', { + reporterStub.calledWith('test', { config: {}, context: { environment: 'production', diff --git a/packages/sui-logger/test/server/indexSpec.js b/packages/sui-logger/test/server/indexSpec.js index c950c8309..5edeecf23 100644 --- a/packages/sui-logger/test/server/indexSpec.js +++ b/packages/sui-logger/test/server/indexSpec.js @@ -5,7 +5,7 @@ import {initTracker} from '../../src/index.js' import * as loggerPkg from '../../src/logger.js' import * as server from '../../src/server.js' -const Mushroom = { +const Reporter = { start: () => {} } @@ -14,33 +14,33 @@ const Trackers = { } describe('initTracker', () => { - let mushroomStub + let reporterStub beforeEach(() => { - mushroomStub = sinon.stub(Mushroom, 'start') + reporterStub = sinon.stub(Reporter, 'start') }) afterEach(() => { - mushroomStub.restore() + reporterStub.restore() }) it('initialize tracker with the expected config', () => { - initTracker({Mushroom, appName: 'test', version: '1.0.0', config: {foo: 'bar'}}) + initTracker({Reporter, appName: 'test', version: '1.0.0', config: {foo: 'bar'}}) - expect(mushroomStub.calledOnce).to.equal(true) + expect(reporterStub.calledOnce).to.equal(true) expect( - mushroomStub.calledWith('test', { + reporterStub.calledWith('test', { config: {foo: 'bar'}, context: {environment: 'test', isServer: 'true', version: '1.0.0', tenant: undefined} }) ).to.equal(true) }) it('initialize tracker with tenant', () => { - initTracker({Mushroom, appName: 'test', version: '1.0.0', tenant: 'infojobs', config: {foo: 'bar'}}) + initTracker({Reporter, appName: 'test', version: '1.0.0', tenant: 'infojobs', config: {foo: 'bar'}}) - expect(mushroomStub.calledOnce).to.equal(true) + expect(reporterStub.calledOnce).to.equal(true) expect( - mushroomStub.calledWith('test', { + reporterStub.calledWith('test', { config: {foo: 'bar'}, context: {environment: 'test', isServer: 'true', version: '1.0.0', tenant: 'infojobs'} }) @@ -48,16 +48,16 @@ describe('initTracker', () => { }) it('initialize tracker with a defined environment', () => { initTracker({ - Mushroom, + Reporter, appName: 'test', environment: 'production', version: '1.0.0', config: {} }) - expect(mushroomStub.calledOnce).to.equal(true) + expect(reporterStub.calledOnce).to.equal(true) expect( - mushroomStub.calledWith('test', { + reporterStub.calledWith('test', { config: {}, context: {environment: 'production', isServer: 'true', version: '1.0.0', tenant: undefined} })