Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/memoize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function memoize(options: MemoizeOptions = {}): MethodDecorator {
max = 50,
ttl = 1000 * 60 * 30,
strategy = 'concat',
skipCache = []
skipCache = [],
} = options;
/* eslint-enable */

Expand Down
14 changes: 7 additions & 7 deletions workers/archiver/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class ArchiverWorker extends Worker {

const projects = await this.projectCollection.find({}).project({
_id: 1,
name: 1
name: 1,
});
const projectsData: ReportDataByProject[] = [];

Expand Down Expand Up @@ -155,11 +155,11 @@ export default class ArchiverWorker extends Worker {
await this.projectCollection.updateOne({
_id: project._id,
},
{
$inc: {
archivedEventsCount: deletedCount,
},
});
{
$inc: {
archivedEventsCount: deletedCount,
},
});
}

/**
Expand Down Expand Up @@ -351,7 +351,7 @@ export default class ArchiverWorker extends Worker {
this.logger.info('Report notification response:', {
status: response?.status,
statusText: response?.statusText,
data: response?.data
data: response?.data,
});
}

Expand Down
2 changes: 1 addition & 1 deletion workers/email/scripts/emailOverview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class EmailTestServer {
tariffPlanId: '5f47f031ff71510040f433c1',
password: '1as2eadd321a3cDf',
plan: {
name: 'Корпоративный'
name: 'Корпоративный',
},
workspaceName: workspace.name,
};
Expand Down
7 changes: 6 additions & 1 deletion workers/email/src/templates/emails/event/html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{% set utmParams = 'utm_source=email&utm_medium=transactional&utm_campaign=event' %}

{% set event = events[0].event %}
{% set repetitionId = events[0].repetitionId %}
{% set daysRepeated = events[0].daysRepeated %}
{% set newCount = events[0].newCount %}
{% set usersAffected = events[0].usersAffected %}
Expand Down Expand Up @@ -56,7 +57,11 @@

<tr>
<td style="padding-top: 30px;padding-right: 20px;padding-left: 20px;padding-bottom: 40px;">
{% set eventURL = host ~ '/project/' ~ project._id ~ '/event/' ~ event._id ~ '?' ~ utmParams %}
{% if repetitionId %}
{% set eventURL = host ~ '/project/' ~ project._id ~ '/event/' ~ event._id ~ '/' ~ repetitionId ~ '/overview?' ~ utmParams %}
{% else %}
{% set eventURL = host ~ '/project/' ~ project._id ~ '/event/' ~ event._id ~ '?' ~ utmParams %}
{% endif %}
{% include '../../components/button.twig' with {href: eventURL, label: 'Смотреть детали'} %}
</td>
</tr>
Expand Down
7 changes: 6 additions & 1 deletion workers/email/src/templates/emails/event/text.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% set event = events[0].event %}
{% set repetitionId = events[0].repetitionId %}
{% set daysRepeated = events[0].daysRepeated %}
{% set newCount = events[0].newCount %}
{% set usersAffected = events[0].usersAffected %}
Expand All @@ -25,7 +26,11 @@

Это событие произошло {{ event.totalCount }} {{ pluralize_ru(event.totalCount, ['раз', 'раза', 'раз']) }} за {{ daysRepeated }} {{ pluralize_ru(daysRepeated, ['день', 'дня', 'дней']) }}.

Смотреть детали: {{ host }}/project/{{ project._id }}/event/{{ event._id }}?{{ utmParams }}
{% if repetitionId %}
Смотреть детали: {{ host }}/project/{{ project._id }}/event/{{ event._id }}/{{ repetitionId }}/overview?{{ utmParams }}
{% else %}
Смотреть детали: {{ host }}/project/{{ project._id }}/event/{{ event._id }}/overview?{{ utmParams }}
{% endif %}

***

Expand Down
1 change: 1 addition & 0 deletions workers/grouper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export default class GrouperWorker extends Worker {
title: task.payload.title,
groupHash: uniqueEventHash,
isNew: isFirstOccurrence,
repetitionId: repetitionId ? repetitionId.toString() : null,
},
});
}
Expand Down
1 change: 1 addition & 0 deletions workers/grouper/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ describe('GrouperWorker', () => {
title: task.payload.title,
groupHash: expect.any(String),
isNew: true,
repetitionId: null,
},
});

Expand Down
1 change: 0 additions & 1 deletion workers/javascript/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,5 +442,4 @@ describe('JavaScript event worker', () => {

await worker.finish();
});

});
2 changes: 1 addition & 1 deletion workers/limiter/tests/dbHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe('DbHelper', () => {
/**
* Act
*/
await dbHelper.updateWorkspacesEventsCountAndIsBlocked([updatedWorkspace]);
await dbHelper.updateWorkspacesEventsCountAndIsBlocked([ updatedWorkspace ]);

/**
* Assert
Expand Down
1 change: 1 addition & 0 deletions workers/notifier/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export default class NotifierWorker extends Worker {
await this.sendToSenderWorker(channelKey, [ {
key: event.groupHash,
count: 1,
repetitionId: event.repetitionId,
} ]);
}
}
Expand Down
6 changes: 6 additions & 0 deletions workers/notifier/types/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export interface SenderData {
* Number of events received
*/
count: number;

/**
* ID of the repetition that triggered this notification
* null for first occurrence, ObjectId string for repetitions
*/
repetitionId: string | null;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions workers/notifier/types/notifier-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export type NotifierEvent = Pick<EventData<EventAddons>, 'title'> & {
* Flag to show if event is received first time
*/
isNew: boolean;

/**
* ID of the repetition that triggered this notification
* null for first occurrence, string for repetitions
*/
repetitionId: string | null;
};

/**
Expand Down
5 changes: 4 additions & 1 deletion workers/paymaster/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,17 @@ export default class PaymasterWorker extends Worker {

/**
* Finds plan by id from cached plans
*
* @param planId
*/
private findPlanById(planId: WorkspaceDBScheme['tariffPlanId']): PlanDBScheme | undefined {
return this.plans.find((plan) => plan._id.toString() === planId.toString());
}

/**
* Returns workspace plan, refreshes cache when plan is missing
*
* @param workspace
*/
private async getWorkspacePlan(workspace: WorkspaceDBScheme): Promise<PlanDBScheme> {
let currentPlan = this.findPlanById(workspace.tariffPlanId);
Expand Down Expand Up @@ -413,7 +417,6 @@ export default class PaymasterWorker extends Worker {
});
}


/**
* Sends reminder emails to blocked workspace admins
*
Expand Down
1 change: 1 addition & 0 deletions workers/paymaster/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ describe('PaymasterWorker', () => {
}

MockDate.reset();

return addTaskSpy;
};

Expand Down
1 change: 1 addition & 0 deletions workers/release/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export default class ReleaseWorker extends Worker {
/**
* Some bundlers could skip file in the source map content since it duplicates in map name
* Like map name bundle.js.map is a source map for a bundle.js
*
* @see https://sourcemaps.info/spec.html - format
*/
originFileName: mapContent.file ?? file.name.replace(/\.map$/, ''),
Expand Down
3 changes: 2 additions & 1 deletion workers/sender/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ export default abstract class SenderWorker extends Worker {

const eventsData = await Promise.all(
events.map(
async ({ key: groupHash, count }: { key: string; count: number }): Promise<TemplateEventData> => {
async ({ key: groupHash, count, repetitionId }: { key: string; count: number; repetitionId?: string | null }): Promise<TemplateEventData> => {
const [event, daysRepeated] = await this.getEventDataByGroupHash(projectId, groupHash);

return {
event,
newCount: count,
daysRepeated,
repetitionId: repetitionId ?? null,
};
}
)
Expand Down
5 changes: 5 additions & 0 deletions workers/sender/types/template-variables/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export interface TemplateEventData {
* Number of affected users for this event
*/
usersAffected?: number;

/**
* ID of the particular repetition of occurred event
*/
repetitionId?: string | null;
}

/**
Expand Down
39 changes: 33 additions & 6 deletions workers/sentry/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ export default class SentryEventWorker extends Worker {

/**
* Filter out binary items that crash parseEnvelope
* Also filters out all Sentry Replay events (replay_event and replay_recording)
*/
private filterOutBinaryItems(rawEvent: string): string {
const lines = rawEvent.split('\n');
const filteredLines = [];
let isInReplayBlock = false;

for (let i = 0; i < lines.length; i++) {
const line = lines[i];
Expand All @@ -90,17 +92,42 @@ export default class SentryEventWorker extends Worker {
// Try to parse as JSON to check if it's a header
const parsed = JSON.parse(line);

// If it's a replay header, skip this line and the next one (payload)
// Check if this is a replay event type
if (parsed.type === 'replay_recording' || parsed.type === 'replay_event') {
// Skip the next line too (which would be the payload)
i++;
// Mark that we're in a replay block and skip this line
isInReplayBlock = true;
continue;
}

// Keep valid headers and other JSON data
filteredLines.push(line);
// If we're in a replay block, check if this is still part of it
if (isInReplayBlock) {
// Check if this line is part of replay data (segment_id, length, etc.)
if ('segment_id' in parsed || ('length' in parsed && parsed.type !== 'event') || 'replay_id' in parsed) {
// Still in replay block, skip this line
continue;
}

// If it's a new envelope item (like event), we've exited the replay block
if (parsed.type === 'event' || parsed.type === 'transaction' || parsed.type === 'session') {
isInReplayBlock = false;
} else {
// Unknown type, assume we're still in replay block
continue;
}
}

// Keep valid headers and other JSON data (not in replay block)
if (!isInReplayBlock) {
filteredLines.push(line);
}
} catch {
// If line doesn't parse as JSON, it might be binary data - skip it
// If line doesn't parse as JSON, it might be binary data
// If we're in a replay block, skip it (it's part of replay recording)
if (isInReplayBlock) {
continue;
}

// If not in replay block and not JSON, it might be corrupted data - skip it
continue;
}
}
Expand Down
Loading
Loading