5htp-core 0.6.1-1 → 0.6.1-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common/errors/index.tsx
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.6.1-
|
|
4
|
+
"version": "0.6.1-2",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// Node
|
|
6
6
|
import { serialize } from 'v8';
|
|
7
7
|
import { formatWithOptions } from 'util';
|
|
8
|
+
import md5 from 'md5';
|
|
9
|
+
import dayjs from 'dayjs';
|
|
8
10
|
import Youch from 'youch';
|
|
9
11
|
import forTerminal from 'youch-terminal';
|
|
10
12
|
|
|
@@ -147,6 +149,12 @@ export default class Console {
|
|
|
147
149
|
public logger!: Logger<ILogObj>;
|
|
148
150
|
// Buffers
|
|
149
151
|
public logs: TJsonLog[] = [];
|
|
152
|
+
private reported: {
|
|
153
|
+
[hash: string]: {
|
|
154
|
+
times: number,
|
|
155
|
+
last: Date,
|
|
156
|
+
}
|
|
157
|
+
} = {};
|
|
150
158
|
|
|
151
159
|
/*----------------------------------
|
|
152
160
|
- LIFECYCLE
|
|
@@ -282,35 +290,12 @@ export default class Console {
|
|
|
282
290
|
// We don't prevent duplicates because we want to receive all variants of the same error
|
|
283
291
|
public async createBugReport( error: TCatchedError, request?: ServerRequest ) {
|
|
284
292
|
|
|
285
|
-
/*const youchRes = new Youch(error, {});
|
|
286
|
-
const jsonResponse = await youchRes.toJSON()
|
|
287
|
-
console.log( forTerminal(jsonResponse, {
|
|
288
|
-
// Defaults to false
|
|
289
|
-
displayShortPath: false,
|
|
290
|
-
|
|
291
|
-
// Defaults to single whitspace
|
|
292
|
-
prefix: ' ',
|
|
293
|
-
|
|
294
|
-
// Defaults to false
|
|
295
|
-
hideErrorTitle: false,
|
|
296
|
-
|
|
297
|
-
// Defaults to false
|
|
298
|
-
hideMessage: false,
|
|
299
|
-
|
|
300
|
-
// Defaults to false
|
|
301
|
-
displayMainFrameOnly: false,
|
|
302
|
-
|
|
303
|
-
// Defaults to 3
|
|
304
|
-
framesMaxLimit: 3,
|
|
305
|
-
}) );*/
|
|
306
|
-
|
|
307
293
|
const application = this.container.application;
|
|
308
294
|
if (application === undefined)
|
|
309
295
|
return console.error(LogPrefix, "Can't send bug report because the application is not instanciated");
|
|
310
296
|
|
|
311
297
|
// Get context
|
|
312
298
|
const now = new Date();
|
|
313
|
-
const hash = uuid();
|
|
314
299
|
const { channelType, channelId } = this.getChannel();
|
|
315
300
|
|
|
316
301
|
// On envoi l'email avant l'insertion dans bla bdd
|
|
@@ -353,10 +338,35 @@ export default class Console {
|
|
|
353
338
|
: undefined
|
|
354
339
|
}
|
|
355
340
|
|
|
341
|
+
// Genertae unique error hash
|
|
342
|
+
const hash = md5( stacktraces.join('\n') );
|
|
343
|
+
|
|
344
|
+
// Don't send the same error twice in a row (avoid email spamming)
|
|
345
|
+
const lastReport = this.reported[hash];
|
|
346
|
+
let isDuplicate = false;
|
|
347
|
+
if (lastReport === undefined) {
|
|
348
|
+
|
|
349
|
+
this.reported[hash] = {
|
|
350
|
+
times: 0,
|
|
351
|
+
last: new Date()
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// If error older than 1 day
|
|
355
|
+
} else if (dayjs(now).diff( dayjs(lastReport.last), 'day' ) > 1) {
|
|
356
|
+
|
|
357
|
+
lastReport.times++;
|
|
358
|
+
lastReport.last = now;
|
|
359
|
+
|
|
360
|
+
} else {
|
|
361
|
+
|
|
362
|
+
isDuplicate = true;
|
|
363
|
+
}
|
|
364
|
+
|
|
356
365
|
const bugReport: ServerBug = {
|
|
357
366
|
|
|
358
367
|
// Context
|
|
359
368
|
hash: hash,
|
|
369
|
+
isDuplicate,
|
|
360
370
|
date: now,
|
|
361
371
|
channelType,
|
|
362
372
|
channelId,
|
|
@@ -171,7 +171,7 @@ export default abstract class Email<TConfig extends Config>
|
|
|
171
171
|
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
-
console.info(LogPrefix, `Sending ${emailsToSend.length} emails
|
|
174
|
+
console.info(LogPrefix, `Sending ${emailsToSend.length} emails:`, emailsToSend[0].subject);
|
|
175
175
|
|
|
176
176
|
// Pas d'envoi d'email quand local
|
|
177
177
|
if (this.app.env.name === 'local' && this.config.simulateWhenLocal === true) {
|
|
@@ -245,7 +245,7 @@ export default class ServerRouter
|
|
|
245
245
|
});
|
|
246
246
|
|
|
247
247
|
if (response.statusCode !== 200) {
|
|
248
|
-
console.error(
|
|
248
|
+
console.error("[router] renderStatic: page returned code", response.statusCode, fullUrl);
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
251
|
|
package/types/icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TIcones = "solid/spinner-third"|"long-arrow-right"|"times-circle"|"brands/whatsapp"|"times"|"search"|"user"|"rocket"|"globe"|"bullhorn"|"briefcase"|"chart-line"|"handshake"|"ellipsis-h"|"brands/google"|"brands/reddit-alien"|"brands/linkedin-in"|"brands/github"|"robot"|"comments"|"user-friends"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"
|
|
1
|
+
export type TIcones = "solid/spinner-third"|"long-arrow-right"|"times-circle"|"brands/whatsapp"|"times"|"search"|"user"|"rocket"|"globe"|"bullhorn"|"briefcase"|"chart-line"|"handshake"|"ellipsis-h"|"brands/google"|"brands/reddit-alien"|"brands/linkedin-in"|"brands/github"|"robot"|"comments"|"user-friends"|"angle-down"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"info-circle"|"check-circle"|"exclamation-circle"|"comment-alt"|"chart-bar"|"power-off"|"home"|"user-circle"|"newspaper"|"plus-circle"|"brands/linkedin"|"brands/twitter"|"brands/facebook"|"heart"|"lock"|"eye"|"credit-card"|"at"|"key"|"bars"|"font"|"tag"|"compress"|"bolt"|"puzzle-piece"|"planet-ringed"|"database"|"solid/fire"|"usd-circle"|"lightbulb"|"solid/dollar-sign"|"download"|"code"|"solid/clock"|"exclamation"|"solid/download"|"seedling"|"palette"|"car"|"plane"|"university"|"hard-hat"|"graduation-cap"|"cogs"|"film"|"leaf"|"tshirt"|"utensils"|"map-marked-alt"|"dumbbell"|"stethoscope"|"concierge-bell"|"book"|"shield-alt"|"gavel"|"industry"|"square-root-alt"|"pills"|"medal"|"capsules"|"balance-scale"|"praying-hands"|"shopping-cart"|"flask"|"futbol"|"microchip"|"satellite-dish"|"shipping-fast"|"passport"|"tools"|"angle-left"|"angle-right"|"check"|"paper-plane"|"trash"|"arrow-left"|"arrow-right"|"meh-rolling-eyes"|"unlink"|"pen"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"link"|"file"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"plus"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
|