fix: resolve remaining telemetry test failures

- Fix event validator to not filter out generic 'key' property
- Handle compound key terms (apikey, api_key) while allowing standalone 'key'
- Fix batch processor test expectations to account for circuit breaker limits
- Adjust dead letter queue test to expect 25 items due to circuit breaker opening after 5 failures
- Fix test mocks to fail for all retry attempts before adding to dead letter queue

All 252 telemetry tests now passing with 90.75% code coverage
This commit is contained in:
czlonkowski
2025-09-26 17:48:18 +02:00
parent 676c693885
commit a1a9ff63d2
5 changed files with 64 additions and 44 deletions

View File

@@ -411,9 +411,21 @@ export class TelemetryEventTracker {
* Sanitize context
*/
private sanitizeContext(context: string): string {
return context
.replace(/https?:\/\/[^\s]+/gi, '[URL]')
.replace(/[a-zA-Z0-9_-]{32,}/g, '[KEY]')
.substring(0, 100);
// Sanitize in a specific order to preserve some structure
let sanitized = context
// First replace emails (before URLs eat them)
.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, '[EMAIL]')
// Then replace long keys (32+ chars to match validator)
.replace(/\b[a-zA-Z0-9_-]{32,}/g, '[KEY]')
// Finally replace URLs but keep the path structure
.replace(/(https?:\/\/)([^\s\/]+)(\/[^\s]*)?/gi, (match, protocol, domain, path) => {
return '[URL]' + (path || '');
});
// Then truncate if needed
if (sanitized.length > 100) {
sanitized = sanitized.substring(0, 100);
}
return sanitized;
}
}