0
# Error Deduplication
1
2
Removes duplicate error events to prevent spam from repeated errors. The integration compares incoming events against the previously captured event and drops duplicates based on message, exception details, stacktrace, and fingerprint.
3
4
## Capabilities
5
6
### Modern Function-based Integration
7
8
```typescript { .api }
9
/**
10
* Deduplication filter for error events
11
* @returns Integration instance that filters duplicate events
12
*/
13
function dedupeIntegration(): Integration;
14
```
15
16
### Legacy Class-based Integration (Deprecated)
17
18
```typescript { .api }
19
/**
20
* Legacy class-based deduplication integration
21
* @deprecated Use dedupeIntegration() instead
22
*/
23
class Dedupe implements Integration {
24
name: string;
25
processEvent(event: Event): Event | null;
26
}
27
```
28
29
## Behavior
30
31
### Event Filtering
32
33
The integration maintains a reference to the previously processed event and compares each new event against it. Events are filtered out (return `null`) if they match the previous event.
34
35
### Comparison Logic
36
37
Events are considered duplicates if they match on:
38
39
1. **Message Events**: Same message text, fingerprint, and stacktrace
40
2. **Exception Events**: Same exception type, value, fingerprint, and stacktrace
41
42
### Fingerprint Comparison
43
44
Events with custom fingerprints are compared by joining fingerprint arrays:
45
- If both events have no fingerprint: considered matching
46
- If only one has fingerprint: not matching
47
- If both have fingerprints: compared by joining array elements
48
49
### Stacktrace Comparison
50
51
Stacktraces are compared frame by frame:
52
- Same number of frames required
53
- Each frame compared on: filename, line number, column number, function name
54
- Missing stacktraces on both events: considered matching
55
- Stacktrace on only one event: not matching
56
57
## Usage Examples
58
59
```typescript
60
import { dedupeIntegration } from '@sentry/integrations';
61
import * as Sentry from '@sentry/browser';
62
63
Sentry.init({
64
dsn: 'YOUR_DSN',
65
integrations: [
66
dedupeIntegration()
67
]
68
});
69
70
// First occurrence - will be sent
71
throw new Error('Network timeout');
72
73
// Immediate duplicate - will be filtered out
74
throw new Error('Network timeout');
75
76
// Different error - will be sent
77
throw new Error('Validation failed');
78
```
79
80
## Test Utilities
81
82
For testing purposes, the integration exports internal comparison functions:
83
84
```typescript { .api }
85
/**
86
* Determines if current event should be dropped as duplicate
87
* Only exported for testing purposes
88
*/
89
function _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean;
90
```
91
92
## Event Types Processed
93
94
- **Error events**: Events with exception information
95
- **Message events**: Events with message text
96
- **Non-error events**: Transaction and replay events are ignored (never deduped)
97
98
The integration only processes error-type events and ignores other event types like transactions or replays to avoid interfering with performance monitoring data.