Skip to content

Commit 289bf60

Browse files
committed
Trim grouper event titles
1 parent b9fd948 commit 289bf60

3 files changed

Lines changed: 10 additions & 15 deletions

File tree

workers/grouper/src/data-filter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { rightTrim } from '../../../lib/utils/string';
88
const MAX_TRAVERSAL_DEPTH = 20;
99

1010
/**
11-
* Maximum length for event title
11+
* Maximum length for event title before appending ellipsis
1212
*/
13-
const MAX_TITLE_LENGTH = 1000;
13+
const MAX_TITLE_LENGTH = 400;
1414

1515
/**
1616
* Recursively iterate through object and call function on each key
@@ -141,6 +141,8 @@ export default class DataFilter {
141141
* @param event - event to process
142142
*/
143143
public processEvent(event: EventData<EventAddons>): void {
144+
this.trimEventTitle(event);
145+
144146
unsafeFields.forEach(field => {
145147
if (event[field]) {
146148
this.processField(event[field]);
@@ -152,8 +154,6 @@ export default class DataFilter {
152154
* Trim event title to the maximum allowed length.
153155
* It mutates the original object.
154156
*
155-
* Should be called before hashing so the hash and the stored title stay consistent.
156-
*
157157
* @param event - event to process
158158
*/
159159
public trimEventTitle(event: EventData<EventAddons>): void {

workers/grouper/src/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ export default class GrouperWorker extends Worker {
198198
this.grouperMetrics.observePayloadSize(taskPayloadSize);
199199
this.memoryMonitor.logBeforeHandle(memoryBeforeHandle, handledTasksCount, taskPayloadSize, task.projectId);
200200

201-
this.logger.info(`[handle] project=${task.projectId} catcher=${task.catcherType} title="${task.payload.title}" payloadSize=${taskPayloadSize}b backtraceFrames=${task.payload.backtrace?.length ?? 0}`);
202-
203201
// FIX RELEASE TYPE
204202
// TODO: REMOVE AFTER 01.01.2026, after the most of the users update to new js catcher
205203
if (task.payload && task.payload.release !== undefined) {
@@ -210,9 +208,11 @@ export default class GrouperWorker extends Worker {
210208
}
211209

212210
/**
213-
* Trim title before hashing so hash and stored title stay consistent
211+
* Filter event data before logging and hashing so logs, hash and stored event stay consistent.
214212
*/
215-
this.dataFilter.trimEventTitle(task.payload);
213+
this.dataFilter.processEvent(task.payload);
214+
215+
this.logger.info(`[handle] project=${task.projectId} catcher=${task.catcherType} title="${task.payload.title}" payloadSize=${taskPayloadSize}b backtraceFrames=${task.payload.backtrace?.length ?? 0}`);
216216

217217
let uniqueEventHash = await session.measureStep('hash', () => this.getUniqueEventHash(task));
218218
let existedEvent: GroupedEventDBScheme;
@@ -224,11 +224,6 @@ export default class GrouperWorker extends Worker {
224224
* Trim source code lines to prevent memory leaks
225225
*/
226226
this.trimSourceCodeLines(task.payload);
227-
228-
/**
229-
* Filter sensitive information
230-
*/
231-
this.dataFilter.processEvent(task.payload);
232227
});
233228

234229
/**

workers/grouper/tests/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ describe('GrouperWorker', () => {
181181
const savedEvent = await eventsCollection.findOne({});
182182

183183
/**
184-
* 1000 chars + ellipsis
184+
* 400 chars + ellipsis
185185
*/
186-
expect(savedEvent.payload.title.length).toBe(1001);
186+
expect(savedEvent.payload.title.length).toBe(401);
187187
expect(savedEvent.payload.title.endsWith('…')).toBe(true);
188188
});
189189

0 commit comments

Comments
 (0)