Skip to content

Commit

Permalink
Clean up error group naming and hash generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Smith committed Sep 14, 2021
1 parent 50223a2 commit 72fa690
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/Synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class Synchronizer {
private createErrorGroup(error: Error, sourceName: string): ErrorGroup {
// truncate the error to the first 500 characters
const maxNameLength = 500;
error.name = `[${sourceName}] ${error.name}`.substr(0, maxNameLength);
error.name = error.name.substr(0, maxNameLength);

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

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

return {
name: normalizedName,
sourceName,
type: error.type,
priority: ErrorPriority.P5,
clientId: hash,
clientId,
count: error.count,
countType: error.countType,
ticket: null,
Expand Down
8 changes: 4 additions & 4 deletions src/models/Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export enum ErrorPriority {
}

export enum ErrorCountType {
USERS = 'Users',
TRX = 'Transactions',
USERS = 'users',
TRX = 'transactions',
}

export enum ErrorType {
CLIENT = 'Client',
SERVER = 'Server',
CLIENT = 'client',
SERVER = 'server',
}

export type Error = {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/JiraTicketProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class JiraTicketProvider implements TicketProviderInterface {

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

let description = errorGroup.name +
'\nh3.Frequency\n' +
Expand Down
2 changes: 1 addition & 1 deletion src/providers/OpsGenieAlertProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class OpsGenieAlertProvider implements AlertProviderInterface {
}

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

return {
clientId: errorGroup.clientId,
Expand Down

0 comments on commit 72fa690

Please sign in to comment.