1 |
|
2 | class Transaction {constructor() { Transaction.prototype.__init.call(this); }
|
3 | |
4 |
|
5 |
|
6 | static __initStatic() {this.id = 'Transaction';}
|
7 |
|
8 | |
9 |
|
10 |
|
11 | __init() {this.name = Transaction.id;}
|
12 |
|
13 | |
14 |
|
15 |
|
16 | setupOnce(addGlobalEventProcessor, getCurrentHub) {
|
17 | addGlobalEventProcessor(event => {
|
18 | const self = getCurrentHub().getIntegration(Transaction);
|
19 | if (self) {
|
20 | return self.process(event);
|
21 | }
|
22 | return event;
|
23 | });
|
24 | }
|
25 |
|
26 | |
27 |
|
28 |
|
29 | process(event) {
|
30 | const frames = this._getFramesFromEvent(event);
|
31 |
|
32 |
|
33 | for (let i = frames.length - 1; i >= 0; i--) {
|
34 | const frame = frames[i];
|
35 |
|
36 | if (frame.in_app === true) {
|
37 | event.transaction = this._getTransaction(frame);
|
38 | break;
|
39 | }
|
40 | }
|
41 |
|
42 | return event;
|
43 | }
|
44 |
|
45 |
|
46 | _getFramesFromEvent(event) {
|
47 | const exception = event.exception && event.exception.values && event.exception.values[0];
|
48 | return (exception && exception.stacktrace && exception.stacktrace.frames) || [];
|
49 | }
|
50 |
|
51 |
|
52 | _getTransaction(frame) {
|
53 | return frame.module || frame.function ? `${frame.module || '?'}/${frame.function || '?'}` : '<unknown>';
|
54 | }
|
55 | } Transaction.__initStatic();
|
56 |
|
57 | export { Transaction };
|
58 |
|