Skip to content

Commit 17e50d0

Browse files
Revert "add: logging for duplicate events (#138)" (#139)
This reverts commit e5c7b0a.
1 parent e5c7b0a commit 17e50d0

1 file changed

Lines changed: 0 additions & 52 deletions

File tree

apps/worker/src/jobs/import.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ export async function importJob(job: Job<ImportQueuePayload>) {
139139

140140
// Phase 1: Fetch & Transform - Process events in batches
141141
if (shouldRunStep('loading')) {
142-
// Track insert_ids to detect duplicates from Mixpanel
143-
const seenInsertIds: Record<string, number> = {};
144-
let totalDuplicatesDetected = 0;
145-
146142
let eventBatch: any = [];
147143
for await (const rawEvent of providerInstance.parseSource(
148144
resumeLoadingFrom,
@@ -162,26 +158,9 @@ export async function importJob(job: Job<ImportQueuePayload>) {
162158

163159
// Process batch when it reaches the batch size
164160
if (eventBatch.length >= BATCH_SIZE) {
165-
// Check for duplicate insert_ids in this batch
166-
let batchDuplicates = 0;
167-
for (const rawEvent of eventBatch) {
168-
const insertId = rawEvent.properties?.$insert_id;
169-
if (insertId) {
170-
const count = seenInsertIds[insertId] || 0;
171-
if (count > 0) {
172-
batchDuplicates++;
173-
totalDuplicatesDetected++;
174-
console.log(`🔄 Duplicate insert_id detected from Mixpanel: ${insertId} (occurrence: ${count + 1}, event: ${rawEvent.event})`);
175-
}
176-
seenInsertIds[insertId] = count + 1;
177-
}
178-
}
179-
180161
const memUsage = process.memoryUsage();
181162
jobLogger.info('Processing batch', {
182163
batchSize: eventBatch.length,
183-
duplicatesInBatch: batchDuplicates,
184-
totalDuplicates: totalDuplicatesDetected,
185164
heapUsedMB: Math.round(memUsage.heapUsed / 1024 / 1024),
186165
heapTotalMB: Math.round(memUsage.heapTotal / 1024 / 1024),
187166
externalMB: Math.round(memUsage.external / 1024 / 1024),
@@ -217,26 +196,9 @@ export async function importJob(job: Job<ImportQueuePayload>) {
217196

218197
// Process remaining events in the last batch
219198
if (eventBatch.length > 0) {
220-
// Check for duplicate insert_ids in final batch
221-
let batchDuplicates = 0;
222-
for (const rawEvent of eventBatch) {
223-
const insertId = rawEvent.properties?.$insert_id;
224-
if (insertId) {
225-
const count = seenInsertIds[insertId] || 0;
226-
if (count > 0) {
227-
batchDuplicates++;
228-
totalDuplicatesDetected++;
229-
console.log(`🔄 Duplicate insert_id detected from Mixpanel: ${insertId} (occurrence: ${count + 1}, event: ${rawEvent.event})`);
230-
}
231-
seenInsertIds[insertId] = count + 1;
232-
}
233-
}
234-
235199
const memUsage = process.memoryUsage();
236200
jobLogger.info('Processing final batch', {
237201
batchSize: eventBatch.length,
238-
duplicatesInBatch: batchDuplicates,
239-
totalDuplicates: totalDuplicatesDetected,
240202
heapUsedMB: Math.round(memUsage.heapUsed / 1024 / 1024),
241203
heapTotalMB: Math.round(memUsage.heapTotal / 1024 / 1024),
242204
externalMB: Math.round(memUsage.external / 1024 / 1024),
@@ -268,20 +230,6 @@ export async function importJob(job: Job<ImportQueuePayload>) {
268230
// Yield control back to event loop after processing final batch
269231
await yieldToEventLoop();
270232
}
271-
272-
// Log summary of duplicate detection
273-
const uniqueInsertIds = Object.keys(seenInsertIds).length;
274-
console.log('\n📊 Phase 1 Import Summary:');
275-
console.log(` Total events processed: ${processedEvents}`);
276-
console.log(` Unique insert_ids: ${uniqueInsertIds}`);
277-
console.log(` Duplicates detected: ${totalDuplicatesDetected}`);
278-
if (totalDuplicatesDetected > 0) {
279-
const duplicatePercentage = ((totalDuplicatesDetected / processedEvents) * 100).toFixed(2);
280-
console.log(` Duplication rate: ${duplicatePercentage}%`);
281-
console.log(`\n⚠️ Mixpanel sent ${totalDuplicatesDetected} duplicate events (same $insert_id multiple times)`);
282-
} else {
283-
console.log(`\n✅ No duplicates detected from Mixpanel`);
284-
}
285233
}
286234

287235
// Phase 2: Generate session IDs if provider requires it

0 commit comments

Comments
 (0)