Skip to content

Commit 72fa690

Browse files
author
Nicholas Smith
committed
Clean up error group naming and hash generation
1 parent 50223a2 commit 72fa690

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/Synchronizer.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export class Synchronizer {
196196
private createErrorGroup(error: Error, sourceName: string): ErrorGroup {
197197
// truncate the error to the first 500 characters
198198
const maxNameLength = 500;
199-
error.name = `[${sourceName}] ${error.name}`.substr(0, maxNameLength);
199+
error.name = error.name.substr(0, maxNameLength);
200200

201201
// wipe out line numbers
202202
let normalizedName = error.name;
@@ -205,15 +205,16 @@ export class Synchronizer {
205205
// remove TypeError prefix from client errors that some browsers may emit
206206
normalizedName = normalizedName.replace(/(TypeError:\s*)/i, '');
207207

208-
// generate clientId from the normalized name
209-
const hash = crypto.createHash('md5').update(normalizedName).digest('hex');
208+
// generate clientId from the error source name and normalized error name
209+
const clientIdInput = `${sourceName}:${normalizedName}`;
210+
const clientId = crypto.createHash('md5').update(clientIdInput).digest('hex');
210211

211212
return {
212213
name: normalizedName,
213214
sourceName,
214215
type: error.type,
215216
priority: ErrorPriority.P5,
216-
clientId: hash,
217+
clientId,
217218
count: error.count,
218219
countType: error.countType,
219220
ticket: null,

src/models/Error.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export enum ErrorPriority {
1010
}
1111

1212
export enum ErrorCountType {
13-
USERS = 'Users',
14-
TRX = 'Transactions',
13+
USERS = 'users',
14+
TRX = 'transactions',
1515
}
1616

1717
export enum ErrorType {
18-
CLIENT = 'Client',
19-
SERVER = 'Server',
18+
CLIENT = 'client',
19+
SERVER = 'server',
2020
}
2121

2222
export type Error = {

src/providers/JiraTicketProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class JiraTicketProvider implements TicketProviderInterface {
162162

163163
public async generateTicketContent(errorGroup: ErrorGroup): Promise<TicketContent> {
164164
const maxInstances = 10;
165-
const summary = `[${errorGroup.type}] ${errorGroup.name}`;
165+
const summary = `[${errorGroup.type}] [${errorGroup.sourceName}] ${errorGroup.name}`;
166166

167167
let description = errorGroup.name +
168168
'\nh3.Frequency\n' +

src/providers/OpsGenieAlertProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class OpsGenieAlertProvider implements AlertProviderInterface {
9696
}
9797

9898
public async generateAlertContent(errorGroup: ErrorGroup): Promise<AlertContent> {
99-
const summary = `[BUG] ${errorGroup.name}`.substr(0, 130);
99+
const summary = `[${errorGroup.type}] [${errorGroup.sourceName}] ${errorGroup.name}`.substr(0, 130);
100100

101101
return {
102102
clientId: errorGroup.clientId,

0 commit comments

Comments
 (0)