0
# Transaction Integration
1
2
Legacy integration that adds transaction names to events based on stack frame analysis. **This integration is deprecated** and will be removed in version 8.
3
4
**Deprecation Notice**: This integration is no longer maintained and will be removed in future versions. Modern Sentry SDKs provide better transaction tracking through performance monitoring features.
5
6
## Capabilities
7
8
### Legacy Class-based Integration (Deprecated)
9
10
```typescript { .api }
11
/**
12
* Adds node transaction names to events based on stack frames
13
* @deprecated This integration will be removed in v8
14
*/
15
class Transaction implements Integration {
16
name: string;
17
processEvent(event: Event): Event;
18
}
19
```
20
21
## Behavior
22
23
### Transaction Name Generation
24
25
The integration analyzes stack frames to generate transaction names:
26
27
1. **Frame Analysis**: Iterates through stack frames in reverse order (newest to oldest)
28
2. **In-App Detection**: Looks for frames marked as `in_app: true`
29
3. **Name Generation**: Creates transaction name from first in-app frame found
30
4. **Event Enhancement**: Adds `transaction` property to the event
31
32
### Transaction Name Format
33
34
Transaction names follow the pattern: `module/function`
35
36
- **With module and function**: `utils/validateInput`
37
- **Module only**: `utils/?`
38
- **Function only**: `?/validateInput`
39
- **Neither**: `<unknown>`
40
41
### Frame Priority
42
43
The integration processes frames in reverse stack order:
44
- **Newest frame first**: Most recent function call gets priority
45
- **First in-app frame**: Only the first matching frame is used
46
- **Skip non-app frames**: Frames from libraries/dependencies are ignored
47
48
## Usage Examples
49
50
```typescript
51
import { Transaction } from '@sentry/integrations';
52
import * as Sentry from '@sentry/browser';
53
54
// Add transaction names to events
55
Sentry.init({
56
dsn: 'YOUR_DSN',
57
integrations: [
58
new Transaction()
59
]
60
});
61
62
// Example stack trace processing:
63
function userAction() { // in_app: true
64
helperFunction();
65
}
66
67
function helperFunction() { // in_app: true
68
throw new Error('Something failed');
69
}
70
71
// Results in event with transaction: "helperFunction/?"
72
// (assuming no module information available)
73
```
74
75
## Internal Functions
76
77
The integration uses internal helper functions:
78
79
```typescript { .api }
80
/**
81
* Extracts stack frames from an event
82
* @param event - Sentry event to process
83
* @returns Array of stack frames or empty array
84
*/
85
function _getFramesFromEvent(event: Event): StackFrame[];
86
87
/**
88
* Generates transaction name from a stack frame
89
* @param frame - Stack frame to process
90
* @returns Transaction name string
91
*/
92
function _getTransaction(frame: StackFrame): string;
93
```
94
95
## Event Processing
96
97
### Frame Extraction
98
99
The integration extracts frames from the exception stacktrace:
100
- **Exception events only**: Only processes events with exception data
101
- **First exception**: Uses the first exception value if multiple exist
102
- **Stacktrace frames**: Accesses frames from exception.stacktrace.frames
103
104
### Transaction Assignment
105
106
Once a suitable frame is found:
107
- **Event modification**: Adds `transaction` property to the root event object
108
- **Single assignment**: Only the first matching frame determines the transaction name
109
- **Permanent**: Transaction name remains with the event through processing
110
111
## Migration Path
112
113
For modern transaction tracking, use:
114
115
### Performance Monitoring
116
117
```typescript
118
import * as Sentry from '@sentry/browser';
119
120
Sentry.init({
121
dsn: 'YOUR_DSN',
122
tracesSampleRate: 1.0, // Enable performance monitoring
123
});
124
125
// Manual transaction creation
126
const transaction = Sentry.startTransaction({
127
name: 'User Action',
128
op: 'navigation'
129
});
130
131
// Automatic transaction tracking (framework-specific)
132
// React, Vue, Angular SDKs provide automatic transaction naming
133
```
134
135
### Custom Transaction Names
136
137
```typescript
138
// Set transaction name directly
139
Sentry.configureScope((scope) => {
140
scope.setTransactionName('Custom Transaction Name');
141
});
142
143
// Or use transaction context
144
Sentry.withScope((scope) => {
145
scope.setTransactionName('Specific Action');
146
Sentry.captureException(error);
147
});
148
```
149
150
## Limitations
151
152
- **No configuration**: Integration has no customization options
153
- **Simple naming**: Basic module/function pattern only
154
- **Exception events only**: Does not process other event types
155
- **Single frame**: Only uses first in-app frame found
156
- **No context**: Does not consider call context or parameters
157
158
This integration was designed for basic transaction identification in older Node.js applications but has been superseded by comprehensive performance monitoring and transaction tracking features in modern Sentry SDKs.