From 9c0daa5e2e1adf80eb65d10a809298cf07eb0020 Mon Sep 17 00:00:00 2001 From: Lee Moody Date: Mon, 15 Jan 2024 18:19:32 +0000 Subject: [PATCH 1/8] Add local sass build time monitoring --- packages/dotcom-build-sass/src/index.ts | 2 +- .../src/monitored-sass-loader.ts | 105 ++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 packages/dotcom-build-sass/src/monitored-sass-loader.ts diff --git a/packages/dotcom-build-sass/src/index.ts b/packages/dotcom-build-sass/src/index.ts index acf91fb24..8533336ae 100644 --- a/packages/dotcom-build-sass/src/index.ts +++ b/packages/dotcom-build-sass/src/index.ts @@ -115,7 +115,7 @@ export class PageKitSassPlugin { // Enable use of Sass for CSS preprocessing // https://github.com/webpack-contrib/sass-loader { - loader: require.resolve('sass-loader'), + loader: require.resolve('./monitored-sass-loader'), options: sassLoaderOptions } ] diff --git a/packages/dotcom-build-sass/src/monitored-sass-loader.ts b/packages/dotcom-build-sass/src/monitored-sass-loader.ts new file mode 100644 index 000000000..c21b45dd5 --- /dev/null +++ b/packages/dotcom-build-sass/src/monitored-sass-loader.ts @@ -0,0 +1,105 @@ +import fs from 'fs' +import path from 'path' +import os from 'os' +import sassLoader from 'sass-loader' + +class SassStats { + #noticeThrottle = 10 * 1000 + #stats = { totalTime: 0, notice: null } + #directory = path.join(os.tmpdir(), 'dotcom-build-sass') + #file = path.join(this.#directory, 'sass-stats.json') + #startTime + + constructor() { + fs.mkdirSync(path.dirname(this.#directory), { recursive: true }) + } + + start = () => { + this.#read() + this.#startTime = performance.now() + } + + end = () => { + const endTime = performance.now() + const updatedTotal = (this.#stats.totalTime += endTime - this.#startTime) + this.#write({ totalTime: updatedTotal }) + } + + #read = () => { + try { + // Restore stats from a temporary file if it exists. + // Reading from disk ensures that we can track stats across builds. + const statsFile = fs.readFileSync(this.#file, 'utf-8') + this.#stats = JSON.parse(statsFile) + } catch {} + return this.#stats + } + + #write = (stats) => { + this.#stats = Object.assign(this.#stats, stats) + fs.writeFileSync(this.#file, JSON.stringify(this.#stats)) + } + + throttledReport = () => { + if (!this.#stats.notice || this.#stats.notice < Date.now() - this.#noticeThrottle) { + this.#write({ notice: Date.now() }) + this.#report() + } + } + + #report = () => { + const seconds = Math.floor(this.#stats.totalTime / 1000) + const minutes = Math.floor(seconds / 60) + const hours = Math.floor(seconds / 3600) + const time = hours > 2 ? `${hours} hours` : minutes > 2 ? `${minutes} minutes` : `${seconds} seconds` + + // eslint-disable-next-line no-console + console.log( + `\n\nYou have spent at least 🔥😱 ${time} 😱🔥 waiting on FT Sass to compile.` + + `\nLet's fix that! 🎉 [link to support to optimise / remove Sass]\n\n` + ) + } +} + +// We're proxying a few functions for monitoring purposes, +// we want to catch any monitoring errors silently. +const forgivingProxy = (target, task) => { + return new Proxy(target, { + apply(...args) { + try { + return task(...args) + } catch (error) { + Reflect.apply(...args) + // eslint-disable-next-line no-console + console.log('dotcom-build-sass: Failed to monitor Sass build.', error) + } + } + }) +} + +const localStats = new SassStats() +const monitoredSassLoaderProxy = forgivingProxy(sassLoader, (target, sassLoaderThis, argumentsList) => { + // Start the timer, sass-loader has been called with Sass content. + // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L19 + localStats.start() + // Assign our proxy to sass-loaders async function. + // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L29 + const sassLoaderAsyncProxy = forgivingProxy(sassLoaderThis.async, (target, thisArg, argumentsList) => { + // Run sass-loader's async function as normal. + // Proxy the callback it returns. + // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L113 + const sassLoaderCallback = Reflect.apply(target, thisArg, argumentsList) + return forgivingProxy(sassLoaderCallback, (target, thisArg, argumentsList) => { + // sass-loader's callback has been... called. + // Either we have sass, or the build failed. + localStats.end() + localStats.throttledReport() + return Reflect.apply(target, thisArg, argumentsList) + }) + }) + sassLoaderThis.async = sassLoaderAsyncProxy + // Run sass-loader as normal. + return Reflect.apply(target, sassLoaderThis, argumentsList) +}) + +export default monitoredSassLoaderProxy From 024d4cc296a9796a26665ea6419f50637538a0ba Mon Sep 17 00:00:00 2001 From: Lee Moody Date: Tue, 23 Jan 2024 18:13:57 +0000 Subject: [PATCH 2/8] Update local sass build time monitoring Set a notification strategy to avoid spam and allow configuration --- .../src/monitored-sass-loader.ts | 76 +++++++++++++++---- 1 file changed, 63 insertions(+), 13 deletions(-) diff --git a/packages/dotcom-build-sass/src/monitored-sass-loader.ts b/packages/dotcom-build-sass/src/monitored-sass-loader.ts index c21b45dd5..b70f62353 100644 --- a/packages/dotcom-build-sass/src/monitored-sass-loader.ts +++ b/packages/dotcom-build-sass/src/monitored-sass-loader.ts @@ -4,8 +4,19 @@ import os from 'os' import sassLoader from 'sass-loader' class SassStats { - #noticeThrottle = 10 * 1000 - #stats = { totalTime: 0, notice: null } + #noticeStrategies = ['throttle', 'never', 'always'] + #noticeStrategy = this.#noticeStrategies.includes(process.env.FT_SASS_STATS_NOTICE) + ? process.env.FT_SASS_STATS_NOTICE + : 'throttle' + #noticeThrottleSeconds = + typeof process.env.FT_SASS_STATS_NOTICE_THROTTLE_SECONDS === 'number' + ? process.env.FT_SASS_STATS_NOTICE_THROTTLE_SECONDS + : 60 * 60 * 0.5 // show throttled notice given 30 mins since last notice + #noticeThrottlePercentage = + typeof process.env.FT_SASS_STATS_NOTICE_THROTTLE_PERCENTAGE === 'number' + ? process.env.FT_SASS_STATS_NOTICE_THROTTLE_PERCENTAGE + : 30 // show throttled notice given a 30% increase + #stats = { totalTime: 0, noticeDate: null, totalTimeAtLastNotice: 0 } #directory = path.join(os.tmpdir(), 'dotcom-build-sass') #file = path.join(this.#directory, 'sass-stats.json') #startTime @@ -40,24 +51,60 @@ class SassStats { fs.writeFileSync(this.#file, JSON.stringify(this.#stats)) } - throttledReport = () => { - if (!this.#stats.notice || this.#stats.notice < Date.now() - this.#noticeThrottle) { - this.#write({ notice: Date.now() }) + reportAccordingToNoticeStrategy = () => { + let shouldReport + + switch (this.#noticeStrategy) { + case 'never': + shouldReport = false + break + + case 'always': + shouldReport = true + break + + case 'throttle': + // Throttle notices to show a limited number per hour, or if the total sass build time + // has increased by a significant percentage. This favours more frequent reports to begin with. + const noticeTimeThrottle = Date.now() >= this.#stats.noticeDate + this.#noticeThrottleSeconds * 1000 + const percentageTotalTimeThrottle = + this.#stats.totalTime > 0 && + (this.#stats.totalTime / this.#stats.totalTimeAtLastNotice - 1) * 100 >= + this.#noticeThrottlePercentage // % increase + shouldReport = !this.#stats.noticeDate || noticeTimeThrottle || percentageTotalTimeThrottle + break + + default: + break + } + + if (shouldReport) { this.#report() } } #report = () => { - const seconds = Math.floor(this.#stats.totalTime / 1000) - const minutes = Math.floor(seconds / 60) - const hours = Math.floor(seconds / 3600) - const time = hours > 2 ? `${hours} hours` : minutes > 2 ? `${minutes} minutes` : `${seconds} seconds` + const seconds = this.#stats.totalTime / 1000 + const minutes = seconds / 60 + const hours = seconds / 3600 + const time = + hours > 1 + ? `${hours.toFixed(1)} hours` + : minutes > 1 + ? `${minutes.toFixed(0)} minutes` + : `${seconds.toFixed(0)} seconds` + const emoji = + hours > 2 ? ['🔥', '😭', '😱'] : hours >= 1 ? ['🔥', '😱'] : minutes > 10 ? ['⏱️', '😬'] : ['⏱️'] // eslint-disable-next-line no-console console.log( - `\n\nYou have spent at least 🔥😱 ${time} 😱🔥 waiting on FT Sass to compile.` + - `\nLet's fix that! 🎉 [link to support to optimise / remove Sass]\n\n` + `\n\nYou have spent at least ${emoji.join(' ')} ${time} ${emoji + .reverse() + .join(' ')} waiting on FT Sass to compile.` + + `\nLet's fix that! 🎉 https://origami.ft.com/blog/2024/01/24/sass-build-times/\n\n` ) + + this.#write({ noticeDate: Date.now(), totalTimeAtLastNotice: this.#stats.totalTime }) } } @@ -71,7 +118,10 @@ const forgivingProxy = (target, task) => { } catch (error) { Reflect.apply(...args) // eslint-disable-next-line no-console - console.log('dotcom-build-sass: Failed to monitor Sass build.', error) + console.log( + 'dotcom-build-sass: Failed to monitor Sass build. Please report to #origami-support', + error + ) } } }) @@ -93,7 +143,7 @@ const monitoredSassLoaderProxy = forgivingProxy(sassLoader, (target, sassLoaderT // sass-loader's callback has been... called. // Either we have sass, or the build failed. localStats.end() - localStats.throttledReport() + localStats.reportAccordingToNoticeStrategy() return Reflect.apply(target, thisArg, argumentsList) }) }) From 4600197cd9a93a95e6b143689697dd1299d31fac Mon Sep 17 00:00:00 2001 From: Lee Moody Date: Wed, 24 Jan 2024 12:44:59 +0000 Subject: [PATCH 3/8] Send sass-build-time metrics to biz-ops Do this async --- .../src/monitored-sass-loader.ts | 72 +++++++++++++++++-- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/packages/dotcom-build-sass/src/monitored-sass-loader.ts b/packages/dotcom-build-sass/src/monitored-sass-loader.ts index b70f62353..d8c425283 100644 --- a/packages/dotcom-build-sass/src/monitored-sass-loader.ts +++ b/packages/dotcom-build-sass/src/monitored-sass-loader.ts @@ -2,6 +2,7 @@ import fs from 'fs' import path from 'path' import os from 'os' import sassLoader from 'sass-loader' +import https from 'https' class SassStats { #noticeStrategies = ['throttle', 'never', 'always'] @@ -20,6 +21,7 @@ class SassStats { #directory = path.join(os.tmpdir(), 'dotcom-build-sass') #file = path.join(this.#directory, 'sass-stats.json') #startTime + #endTime constructor() { fs.mkdirSync(path.dirname(this.#directory), { recursive: true }) @@ -31,8 +33,8 @@ class SassStats { } end = () => { - const endTime = performance.now() - const updatedTotal = (this.#stats.totalTime += endTime - this.#startTime) + this.#endTime = performance.now() + const updatedTotal = (this.#stats.totalTime += this.#endTime - this.#startTime) this.#write({ totalTime: updatedTotal }) } @@ -51,6 +53,63 @@ class SassStats { fs.writeFileSync(this.#file, JSON.stringify(this.#stats)) } + sendMetric = () => { + if (process.env.FT_SASS_STATS_MONITOR === 'off') { + return + } + + if (!process.env.FT_SASS_BIZ_OPS_API_KEY) { + // eslint-disable-next-line no-console + console.log( + 'dotcom-build-sass: Could not monitor Sass your build time. Please help us improve build times by including a FT_SASS_BIZ_OPS_API_KEY. Please contact #origami-support with any questions.' + ) + } + + const date = new Date() + const postData = JSON.stringify({ + type: 'System', + metric: 'sass-build-time', + value: (this.#endTime - this.#startTime) / 1000, + date: date.toISOString(), + code: 'page-kit', + metadata: { + 'node-env': process.env.NODE_ENV + } + }) + + const options = { + hostname: 'api.ft.com', + port: 443, + path: '/biz-ops-metrics/metric/add', + method: 'POST', + headers: { + 'x-api-key': process.env.FT_SASS_BIZ_OPS_API_KEY, + 'client-id': 'page-kit', + 'Content-Type': 'application/json', + 'Content-Length': postData.length + } + } + + const request = https + .request(options, (response) => { + if (response.statusCode !== 200) { + // eslint-disable-next-line no-console + console.log( + `dotcom-build-sass: Failed to send Sass build metrics to biz-ops. Status code: ${response.statusCode}. Please report to #origami-support` + ) + } + }) + .on('error', (error) => { + // eslint-disable-next-line no-console + console.log( + 'dotcom-build-sass: Failed to send Sass build metrics to biz-ops. Please report to #origami-support', + error + ) + }) + request.write(postData) + request.end() + } + reportAccordingToNoticeStrategy = () => { let shouldReport @@ -127,11 +186,11 @@ const forgivingProxy = (target, task) => { }) } -const localStats = new SassStats() +const stats = new SassStats() const monitoredSassLoaderProxy = forgivingProxy(sassLoader, (target, sassLoaderThis, argumentsList) => { // Start the timer, sass-loader has been called with Sass content. // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L19 - localStats.start() + stats.start() // Assign our proxy to sass-loaders async function. // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L29 const sassLoaderAsyncProxy = forgivingProxy(sassLoaderThis.async, (target, thisArg, argumentsList) => { @@ -142,8 +201,9 @@ const monitoredSassLoaderProxy = forgivingProxy(sassLoader, (target, sassLoaderT return forgivingProxy(sassLoaderCallback, (target, thisArg, argumentsList) => { // sass-loader's callback has been... called. // Either we have sass, or the build failed. - localStats.end() - localStats.reportAccordingToNoticeStrategy() + stats.end() + stats.sendMetric() + stats.reportAccordingToNoticeStrategy() return Reflect.apply(target, thisArg, argumentsList) }) }) From 807a2a09d80999206b15a831c0d884fbf95f61f2 Mon Sep 17 00:00:00 2001 From: Lee Moody Date: Wed, 24 Jan 2024 12:46:55 +0000 Subject: [PATCH 4/8] Do not send sass-build-time metrics to biz-ops by default We should turn it on at the same time we provide an api key to projects, to avoid annoying messages --- packages/dotcom-build-sass/src/monitored-sass-loader.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/dotcom-build-sass/src/monitored-sass-loader.ts b/packages/dotcom-build-sass/src/monitored-sass-loader.ts index d8c425283..ab637d8c2 100644 --- a/packages/dotcom-build-sass/src/monitored-sass-loader.ts +++ b/packages/dotcom-build-sass/src/monitored-sass-loader.ts @@ -54,14 +54,14 @@ class SassStats { } sendMetric = () => { - if (process.env.FT_SASS_STATS_MONITOR === 'off') { + if (process.env.FT_SASS_STATS_MONITOR !== 'on') { return } if (!process.env.FT_SASS_BIZ_OPS_API_KEY) { // eslint-disable-next-line no-console console.log( - 'dotcom-build-sass: Could not monitor Sass your build time. Please help us improve build times by including a FT_SASS_BIZ_OPS_API_KEY. Please contact #origami-support with any questions.' + 'dotcom-build-sass: Could not monitor your Sass build time. Please help us improve build times by including a FT_SASS_BIZ_OPS_API_KEY. Please contact #origami-support with any questions.' ) } From 41c706ec2f976534d28a7bae7e9188f9c12cc4ff Mon Sep 17 00:00:00 2001 From: Lee Moody Date: Wed, 24 Jan 2024 15:22:02 +0000 Subject: [PATCH 5/8] Update sass build time report message --- packages/dotcom-build-sass/src/monitored-sass-loader.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/dotcom-build-sass/src/monitored-sass-loader.ts b/packages/dotcom-build-sass/src/monitored-sass-loader.ts index ab637d8c2..7b800cf25 100644 --- a/packages/dotcom-build-sass/src/monitored-sass-loader.ts +++ b/packages/dotcom-build-sass/src/monitored-sass-loader.ts @@ -159,8 +159,9 @@ class SassStats { console.log( `\n\nYou have spent at least ${emoji.join(' ')} ${time} ${emoji .reverse() - .join(' ')} waiting on FT Sass to compile.` + - `\nLet's fix that! 🎉 https://origami.ft.com/blog/2024/01/24/sass-build-times/\n\n` + .join(' ')} waiting on FT Sass to compile.\n` + + `Share your pain in Slack #sass-to-css, and help fix that! 🎉\n` + + `https://origami.ft.com/blog/2024/01/24/sass-build-times/\n\n` ) this.#write({ noticeDate: Date.now(), totalTimeAtLastNotice: this.#stats.totalTime }) From d014a383cf670dcddd224f6ac901146c14f4f6cc Mon Sep 17 00:00:00 2001 From: Lee Moody Date: Wed, 24 Jan 2024 18:18:11 +0000 Subject: [PATCH 6/8] Sass monitoring: improve error prompts and readme --- packages/dotcom-build-sass/README.md | 17 ++++++ .../src/monitored-sass-loader.ts | 59 +++++++++++-------- 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/packages/dotcom-build-sass/README.md b/packages/dotcom-build-sass/README.md index 5ebffee9c..becfe30e3 100644 --- a/packages/dotcom-build-sass/README.md +++ b/packages/dotcom-build-sass/README.md @@ -71,3 +71,20 @@ The CSS loader has `@import` and `url()` resolution disabled as these should be | `webpackImporter` | Boolean | `false` | See https://github.com/webpack-contrib/sass-loader#webpackimporter | | `prependData` | String | `''` | See https://webpack.js.org/loaders/sass-loader/#prependdata | | `includePaths` | String[] | `[]` | See https://sass-lang.com/documentation/js-api#includepaths | + +## Sass build monitoring + +Sass build times are stored locally and remotely, where your project sets relevant API keys. Alternatively, you may turn both these features off using environment variable. + +- Local reporting: A running total of your local Sass build times are stored in a temporary file on your machine. This statistic is reported periodically for your interest, along with a prompt to support FT efforts to move away from Sass. +- Alongside this, your local Sass build times are sent to the [biz-ops metrics api](https://github.com/Financial-Times/biz-ops-metrics-api), provided the below environment variables are set. + + +| Environment Variable | Required | Default | Description | +|--------------------------------------------|------------|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `FT_SASS_STATS_NOTICE` | no | `throttle` | How often to log Sass statistics out to terminal. One of `throttle`, `never`, `always` | +| `FT_SASS_STATS_NOTICE_THROTTLE_SECONDS` | no | `1800` | How many seconds to wait between logging Sass statistics out to terminal. | +| `FT_SASS_STATS_NOTICE_THROTTLE_PERCENTAGE` | no | `30` | A percentage increase in total Sass build time in which to log out statistics to the terminal regardless of time. | +| `FT_SASS_STATS_MONITOR` | no | `off` | Set to `on` to send Sass build time statistics to [biz-ops metrics api](https://github.com/Financial-Times/biz-ops-metrics-api) Requires `FT_SASS_BIZ_OPS_API_KEY` and `FT_SASS_BIZ_OPS_SYSTEM_CODE`. | +| `FT_SASS_BIZ_OPS_API_KEY` | no | `` | A [Biz-Ops Metrics API Key](https://github.com/Financial-Times/biz-ops-metrics-api/blob/main/docs/API_DEFINITION.md#authentication) for your system. | +| `FT_SASS_BIZ_OPS_SYSTEM_CODE` | no | `` | The [biz-ops](https://biz-ops.in.ft.com/) system code of your project. Use `page-kit` if your system does not have a biz-ops code yet. | diff --git a/packages/dotcom-build-sass/src/monitored-sass-loader.ts b/packages/dotcom-build-sass/src/monitored-sass-loader.ts index 7b800cf25..5fccd2a70 100644 --- a/packages/dotcom-build-sass/src/monitored-sass-loader.ts +++ b/packages/dotcom-build-sass/src/monitored-sass-loader.ts @@ -4,7 +4,15 @@ import os from 'os' import sassLoader from 'sass-loader' import https from 'https' +const logError = (message) => { + // eslint-disable-next-line no-console + console.log( + `\n⛔️😭dotcom-build-sass: ${message}. Please report to #origami-support in Slack, so we can help move us away from Sass.\n` + ) +} + class SassStats { + #monitorRemotely = process.env.FT_SASS_STATS_MONITOR === 'on' #noticeStrategies = ['throttle', 'never', 'always'] #noticeStrategy = this.#noticeStrategies.includes(process.env.FT_SASS_STATS_NOTICE) ? process.env.FT_SASS_STATS_NOTICE @@ -54,15 +62,21 @@ class SassStats { } sendMetric = () => { - if (process.env.FT_SASS_STATS_MONITOR !== 'on') { + if (!this.#monitorRemotely) { return } if (!process.env.FT_SASS_BIZ_OPS_API_KEY) { - // eslint-disable-next-line no-console - console.log( - 'dotcom-build-sass: Could not monitor your Sass build time. Please help us improve build times by including a FT_SASS_BIZ_OPS_API_KEY. Please contact #origami-support with any questions.' + logError( + 'We couldn\'t share your Sass build time, we\'re missing the environment variable "FT_SASS_BIZ_OPS_API_KEY". Please contact #origami-support with any questions.' + ) + return + } + if (!process.env.FT_SASS_BIZ_OPS_SYSTEM_CODE) { + logError( + 'We couldn\'t share your Sass build time, we\'re missing the environment variable "FT_SASS_BIZ_OPS_SYSTEM_CODE". Please contact #origami-support with any questions.' ) + return } const date = new Date() @@ -71,7 +85,7 @@ class SassStats { metric: 'sass-build-time', value: (this.#endTime - this.#startTime) / 1000, date: date.toISOString(), - code: 'page-kit', + code: process.env.FT_SASS_BIZ_OPS_SYSTEM_CODE, metadata: { 'node-env': process.env.NODE_ENV } @@ -93,18 +107,13 @@ class SassStats { const request = https .request(options, (response) => { if (response.statusCode !== 200) { - // eslint-disable-next-line no-console - console.log( - `dotcom-build-sass: Failed to send Sass build metrics to biz-ops. Status code: ${response.statusCode}. Please report to #origami-support` + logError( + `We couldn\'t send your Sass build time metrics to biz-ops. Status code: ${response.statusCode}.` ) } }) .on('error', (error) => { - // eslint-disable-next-line no-console - console.log( - 'dotcom-build-sass: Failed to send Sass build metrics to biz-ops. Please report to #origami-support', - error - ) + logError(`We couldn\'t send your Sass build time metrics to biz-ops. Error: ${error}.`) }) request.write(postData) request.end() @@ -155,13 +164,21 @@ class SassStats { const emoji = hours > 2 ? ['🔥', '😭', '😱'] : hours >= 1 ? ['🔥', '😱'] : minutes > 10 ? ['⏱️', '😬'] : ['⏱️'] + let cta = + `Share your pain in Slack #sass-to-css, and help fix that! 🎉\n` + + `https://origami.ft.com/blog/2024/01/24/sass-build-times/\n\n` + + if (!this.#monitorRemotely) { + cta = + `Help us improve build times by setting the "FT_SASS_STATS_MONITOR" environment variable.\n` + + `https://github.com/Financial-Times/biz-ops-metrics-api/blob/main/docs/API_DEFINITION.md#sass-build-monitoring \n\n` + } + // eslint-disable-next-line no-console console.log( - `\n\nYou have spent at least ${emoji.join(' ')} ${time} ${emoji + `\n\ndotcom-build-sass:\nYou have spent at least ${emoji.join(' ')} ${time} ${emoji .reverse() - .join(' ')} waiting on FT Sass to compile.\n` + - `Share your pain in Slack #sass-to-css, and help fix that! 🎉\n` + - `https://origami.ft.com/blog/2024/01/24/sass-build-times/\n\n` + .join(' ')} waiting on FT Sass to compile.\n${cta}` ) this.#write({ noticeDate: Date.now(), totalTimeAtLastNotice: this.#stats.totalTime }) @@ -177,11 +194,7 @@ const forgivingProxy = (target, task) => { return task(...args) } catch (error) { Reflect.apply(...args) - // eslint-disable-next-line no-console - console.log( - 'dotcom-build-sass: Failed to monitor Sass build. Please report to #origami-support', - error - ) + logError(`Failed to monitor Sass build. Error: ${error}`) } } }) @@ -203,8 +216,8 @@ const monitoredSassLoaderProxy = forgivingProxy(sassLoader, (target, sassLoaderT // sass-loader's callback has been... called. // Either we have sass, or the build failed. stats.end() - stats.sendMetric() stats.reportAccordingToNoticeStrategy() + stats.sendMetric() return Reflect.apply(target, thisArg, argumentsList) }) }) From 22b2009751d6a60eef6b000632cb3969650f67b8 Mon Sep 17 00:00:00 2001 From: Lee Moody Date: Fri, 26 Jan 2024 16:51:40 +0000 Subject: [PATCH 7/8] chore: add Origami to codeowners --- CODEOWNERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CODEOWNERS b/CODEOWNERS index 8c3afe192..777c4ecf5 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,6 @@ # See https://help.github.com/articles/about-codeowners/ for more information about this file. * @financial-times/platforms + +# The Origami team are responsible for sass-loader modifications. +/packages/dotcom-build-sass/src/monitored-sass-loader.ts @financial-times/origami-core From 5f4b7435edc1d76e6123ac9ba5862ad3f98bc442 Mon Sep 17 00:00:00 2001 From: Lee Moody Date: Fri, 26 Jan 2024 16:55:34 +0000 Subject: [PATCH 8/8] chore: update Origami to codeowners --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 777c4ecf5..c2efb6d7d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -3,4 +3,4 @@ * @financial-times/platforms # The Origami team are responsible for sass-loader modifications. -/packages/dotcom-build-sass/src/monitored-sass-loader.ts @financial-times/origami-core +packages/dotcom-build-sass/ @Financial-Times/origami-core