Мониторинг: логи, ошибки и запись экрана портала заявок в monitoring.tnsu.kz

initMonitoring в onInit веб-части (один раз на страницу), service.name = requestPortal, токен — молча
через AAD веб-части (spfxTokenProvider). В package-solution.json запрос Logs.Write к регистрации
мониторинга. Хэш коммита сборки — патч webpack (config/webpack-patch.json): GIT_COMMIT, GITHUB_SHA или git.
Пакет @tnsu/monitoring-web ставится отдельно.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gorbenko.pavel
2026-10-30 16:16:55 +05:00
parent b1060433d0
commit ee78449131
4 changed files with 38 additions and 0 deletions
+4
View File
@@ -30,6 +30,10 @@
"resource": "9232d9e2-9807-4753-808f-07250e5474b0",
"scope": "Reports.Read"
},
{
"resource": "9232d9e2-9807-4753-808f-07250e5474b0",
"scope": "Logs.Write"
},
{
"resource": "Microsoft Flow Service",
"scope": "Flows.Read.All"
+4
View File
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/webpack-patch.schema.json",
"patchFiles": ["./config/webpack-patch/monitoring.js"]
}
+20
View File
@@ -0,0 +1,20 @@
// Хэш коммита сборки — в логи (git.commit) и записи экрана мониторинга: @tnsu/monitoring-web читает
// __TNSU_GIT_COMMIT__, а webpack подставляет его при сборке. Хэш — GIT_COMMIT или GITHUB_SHA пайплайна, иначе git.
const { execSync } = require('node:child_process');
const webpack = require('webpack');
function gitCommit() {
const fromEnv = process.env.GIT_COMMIT || process.env.GITHUB_SHA;
if (fromEnv) return fromEnv;
try {
return execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
} catch {
return '';
}
}
module.exports = function monitoringPatch(config) {
config.plugins = config.plugins || [];
config.plugins.push(new webpack.DefinePlugin({ __TNSU_GIT_COMMIT__: JSON.stringify(gitCommit()) }));
return config;
};