Skip to content

Commit

Permalink
Checkout: Do not log errorMessage in checkout logstash if message is …
Browse files Browse the repository at this point in the history
…the same (#97477)

* Do not log errorMessage in checkout logstash if message is the same

* Only log tags once
  • Loading branch information
sirbrillig authored Dec 13, 2024
1 parent bf5ac71 commit c172fd4
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions client/my-sites/checkout/src/lib/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ export function logStashLoadErrorEvent(
message: additionalData.message
? String( additionalData.message )
: convertErrorToString( error ),
errorMessage: convertErrorToString( error ),
...( additionalData.message
? // No need to log the `errorMessage` separately if it's the same as
// the `message` property.
{
errorMessage: convertErrorToString( error ),
}
: {} ),
tags: [ 'checkout-error-boundary' ],
} );
}
Expand All @@ -88,15 +94,22 @@ export function logStashEvent(
dataForLog: DataForLog,
severity: 'error' | 'warning' | 'info' = 'error'
): Promise< void > {
const tags = dataForLog.tags ?? [];
const extra: Record< string, string | string[] > = {
env: config( 'env_id' ),
};
Object.keys( dataForLog ).forEach( ( key ) => {
if ( key === 'tags' ) {
return;
}
extra[ key ] = dataForLog[ key ];
} );
return logToLogstash( {
feature: 'calypso_client',
message,
severity: config( 'env_id' ) === 'production' ? severity : 'debug',
extra: {
env: config( 'env_id' ),
...dataForLog,
},
tags: dataForLog.tags ?? [],
extra,
tags,
} );
}

Expand Down

0 comments on commit c172fd4

Please sign in to comment.