@sentry/browser 7.0.0-beta.0 → 7.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +2 -3
  2. package/cjs/client.js +125 -102
  3. package/cjs/client.js.map +1 -1
  4. package/cjs/eventbuilder.js +225 -165
  5. package/cjs/eventbuilder.js.map +1 -1
  6. package/cjs/exports.js +55 -59
  7. package/cjs/exports.js.map +1 -1
  8. package/cjs/flags.js +7 -3
  9. package/cjs/flags.js.map +1 -1
  10. package/cjs/helpers.js +125 -97
  11. package/cjs/helpers.js.map +1 -1
  12. package/cjs/index.js +77 -10
  13. package/cjs/index.js.map +1 -1
  14. package/cjs/integrations/breadcrumbs.js +222 -174
  15. package/cjs/integrations/breadcrumbs.js.map +1 -1
  16. package/cjs/integrations/dedupe.js +184 -142
  17. package/cjs/integrations/dedupe.js.map +1 -1
  18. package/cjs/integrations/globalhandlers.js +211 -170
  19. package/cjs/integrations/globalhandlers.js.map +1 -1
  20. package/cjs/integrations/httpcontext.js +51 -0
  21. package/cjs/integrations/httpcontext.js.map +1 -0
  22. package/cjs/integrations/index.js +18 -14
  23. package/cjs/integrations/index.js.map +1 -1
  24. package/cjs/integrations/linkederrors.js +81 -50
  25. package/cjs/integrations/linkederrors.js.map +1 -1
  26. package/cjs/integrations/trycatch.js +252 -208
  27. package/cjs/integrations/trycatch.js.map +1 -1
  28. package/cjs/sdk.js +166 -125
  29. package/cjs/sdk.js.map +1 -1
  30. package/cjs/stack-parsers.js +143 -93
  31. package/cjs/stack-parsers.js.map +1 -1
  32. package/cjs/transports/fetch.js +30 -15
  33. package/cjs/transports/fetch.js.map +1 -1
  34. package/cjs/transports/index.js +10 -6
  35. package/cjs/transports/index.js.map +1 -1
  36. package/cjs/transports/utils.js +56 -52
  37. package/cjs/transports/utils.js.map +1 -1
  38. package/cjs/transports/xhr.js +40 -30
  39. package/cjs/transports/xhr.js.map +1 -1
  40. package/esm/client.js +124 -101
  41. package/esm/client.js.map +1 -1
  42. package/esm/eventbuilder.js +218 -158
  43. package/esm/eventbuilder.js.map +1 -1
  44. package/esm/exports.js +12 -8
  45. package/esm/exports.js.map +1 -1
  46. package/esm/flags.js +5 -2
  47. package/esm/flags.js.map +1 -1
  48. package/esm/helpers.js +124 -96
  49. package/esm/helpers.js.map +1 -1
  50. package/esm/index.js +27 -7
  51. package/esm/index.js.map +1 -1
  52. package/esm/integrations/breadcrumbs.js +218 -171
  53. package/esm/integrations/breadcrumbs.js.map +1 -1
  54. package/esm/integrations/dedupe.js +181 -139
  55. package/esm/integrations/dedupe.js.map +1 -1
  56. package/esm/integrations/globalhandlers.js +208 -167
  57. package/esm/integrations/globalhandlers.js.map +1 -1
  58. package/esm/integrations/httpcontext.js +49 -0
  59. package/esm/integrations/httpcontext.js.map +1 -0
  60. package/esm/integrations/index.js +7 -7
  61. package/esm/integrations/index.js.map +1 -1
  62. package/esm/integrations/linkederrors.js +77 -46
  63. package/esm/integrations/linkederrors.js.map +1 -1
  64. package/esm/integrations/trycatch.js +249 -205
  65. package/esm/integrations/trycatch.js.map +1 -1
  66. package/esm/sdk.js +163 -123
  67. package/esm/sdk.js.map +1 -1
  68. package/esm/stack-parsers.js +134 -91
  69. package/esm/stack-parsers.js.map +1 -1
  70. package/esm/transports/fetch.js +28 -13
  71. package/esm/transports/fetch.js.map +1 -1
  72. package/esm/transports/index.js +3 -3
  73. package/esm/transports/index.js.map +1 -1
  74. package/esm/transports/utils.js +55 -51
  75. package/esm/transports/utils.js.map +1 -1
  76. package/esm/transports/xhr.js +38 -28
  77. package/esm/transports/xhr.js.map +1 -1
  78. package/package.json +4 -4
  79. package/types/client.d.ts +5 -4
  80. package/types/client.d.ts.map +1 -1
  81. package/types/exports.d.ts +3 -4
  82. package/types/exports.d.ts.map +1 -1
  83. package/types/helpers.d.ts +2 -1
  84. package/types/helpers.d.ts.map +1 -1
  85. package/types/index.d.ts +1 -1
  86. package/types/integrations/{useragent.d.ts → httpcontext.d.ts} +3 -3
  87. package/types/integrations/httpcontext.d.ts.map +1 -0
  88. package/types/integrations/index.d.ts +1 -1
  89. package/types/integrations/index.d.ts.map +1 -1
  90. package/types/sdk.d.ts +2 -2
  91. package/types/sdk.d.ts.map +1 -1
  92. package/types/transports/fetch.d.ts +3 -5
  93. package/types/transports/fetch.d.ts.map +1 -1
  94. package/types/transports/types.d.ts +10 -0
  95. package/types/transports/types.d.ts.map +1 -0
  96. package/types/transports/utils.d.ts +1 -1
  97. package/types/transports/utils.d.ts.map +1 -1
  98. package/types/transports/xhr.d.ts +3 -7
  99. package/types/transports/xhr.d.ts.map +1 -1
  100. package/cjs/client.d.ts +0 -63
  101. package/cjs/client.d.ts.map +0 -1
  102. package/cjs/eventbuilder.d.ts +0 -37
  103. package/cjs/eventbuilder.d.ts.map +0 -1
  104. package/cjs/exports.d.ts +0 -11
  105. package/cjs/exports.d.ts.map +0 -1
  106. package/cjs/flags.d.ts +0 -3
  107. package/cjs/flags.d.ts.map +0 -1
  108. package/cjs/helpers.d.ts +0 -47
  109. package/cjs/helpers.d.ts.map +0 -1
  110. package/cjs/index.d.ts +0 -15
  111. package/cjs/index.d.ts.map +0 -1
  112. package/cjs/integrations/breadcrumbs.d.ts +0 -46
  113. package/cjs/integrations/breadcrumbs.d.ts.map +0 -1
  114. package/cjs/integrations/dedupe.d.ts +0 -21
  115. package/cjs/integrations/dedupe.d.ts.map +0 -1
  116. package/cjs/integrations/globalhandlers.d.ts +0 -30
  117. package/cjs/integrations/globalhandlers.d.ts.map +0 -1
  118. package/cjs/integrations/index.d.ts +0 -7
  119. package/cjs/integrations/index.d.ts.map +0 -1
  120. package/cjs/integrations/linkederrors.d.ts +0 -42
  121. package/cjs/integrations/linkederrors.d.ts.map +0 -1
  122. package/cjs/integrations/trycatch.d.ts +0 -33
  123. package/cjs/integrations/trycatch.d.ts.map +0 -1
  124. package/cjs/integrations/useragent.d.ts +0 -17
  125. package/cjs/integrations/useragent.d.ts.map +0 -1
  126. package/cjs/integrations/useragent.js +0 -40
  127. package/cjs/integrations/useragent.js.map +0 -1
  128. package/cjs/sdk.d.ts +0 -112
  129. package/cjs/sdk.d.ts.map +0 -1
  130. package/cjs/stack-parsers.d.ts +0 -9
  131. package/cjs/stack-parsers.d.ts.map +0 -1
  132. package/cjs/transports/fetch.d.ts +0 -10
  133. package/cjs/transports/fetch.d.ts.map +0 -1
  134. package/cjs/transports/index.d.ts +0 -3
  135. package/cjs/transports/index.d.ts.map +0 -1
  136. package/cjs/transports/utils.d.ts +0 -48
  137. package/cjs/transports/utils.d.ts.map +0 -1
  138. package/cjs/transports/xhr.d.ts +0 -11
  139. package/cjs/transports/xhr.d.ts.map +0 -1
  140. package/cjs/version.d.ts +0 -2
  141. package/cjs/version.d.ts.map +0 -1
  142. package/cjs/version.js +0 -4
  143. package/cjs/version.js.map +0 -1
  144. package/esm/client.d.ts +0 -63
  145. package/esm/client.d.ts.map +0 -1
  146. package/esm/eventbuilder.d.ts +0 -37
  147. package/esm/eventbuilder.d.ts.map +0 -1
  148. package/esm/exports.d.ts +0 -11
  149. package/esm/exports.d.ts.map +0 -1
  150. package/esm/flags.d.ts +0 -3
  151. package/esm/flags.d.ts.map +0 -1
  152. package/esm/helpers.d.ts +0 -47
  153. package/esm/helpers.d.ts.map +0 -1
  154. package/esm/index.d.ts +0 -15
  155. package/esm/index.d.ts.map +0 -1
  156. package/esm/integrations/breadcrumbs.d.ts +0 -46
  157. package/esm/integrations/breadcrumbs.d.ts.map +0 -1
  158. package/esm/integrations/dedupe.d.ts +0 -21
  159. package/esm/integrations/dedupe.d.ts.map +0 -1
  160. package/esm/integrations/globalhandlers.d.ts +0 -30
  161. package/esm/integrations/globalhandlers.d.ts.map +0 -1
  162. package/esm/integrations/index.d.ts +0 -7
  163. package/esm/integrations/index.d.ts.map +0 -1
  164. package/esm/integrations/linkederrors.d.ts +0 -42
  165. package/esm/integrations/linkederrors.d.ts.map +0 -1
  166. package/esm/integrations/trycatch.d.ts +0 -33
  167. package/esm/integrations/trycatch.d.ts.map +0 -1
  168. package/esm/integrations/useragent.d.ts +0 -17
  169. package/esm/integrations/useragent.d.ts.map +0 -1
  170. package/esm/integrations/useragent.js +0 -38
  171. package/esm/integrations/useragent.js.map +0 -1
  172. package/esm/sdk.d.ts +0 -112
  173. package/esm/sdk.d.ts.map +0 -1
  174. package/esm/stack-parsers.d.ts +0 -9
  175. package/esm/stack-parsers.d.ts.map +0 -1
  176. package/esm/transports/fetch.d.ts +0 -10
  177. package/esm/transports/fetch.d.ts.map +0 -1
  178. package/esm/transports/index.d.ts +0 -3
  179. package/esm/transports/index.d.ts.map +0 -1
  180. package/esm/transports/utils.d.ts +0 -48
  181. package/esm/transports/utils.d.ts.map +0 -1
  182. package/esm/transports/xhr.d.ts +0 -11
  183. package/esm/transports/xhr.d.ts.map +0 -1
  184. package/esm/version.d.ts +0 -2
  185. package/esm/version.d.ts.map +0 -1
  186. package/esm/version.js +0 -3
  187. package/esm/version.js.map +0 -1
  188. package/types/integrations/useragent.d.ts.map +0 -1
  189. package/types/version.d.ts +0 -2
  190. package/types/version.d.ts.map +0 -1
@@ -1,165 +1,207 @@
1
1
  import { logger } from '@sentry/utils';
2
- import { IS_DEBUG_BUILD } from '../flags';
2
+ import { IS_DEBUG_BUILD } from '../flags.js';
3
+
3
4
  /** Deduplication filter */
4
- export class Dedupe {
5
- constructor() {
6
- /**
7
- * @inheritDoc
8
- */
9
- this.name = Dedupe.id;
10
- }
11
- /**
12
- * @inheritDoc
13
- */
14
- setupOnce(addGlobalEventProcessor, getCurrentHub) {
15
- const eventProcessor = currentEvent => {
16
- const self = getCurrentHub().getIntegration(Dedupe);
17
- if (self) {
18
- // Juuust in case something goes wrong
19
- try {
20
- if (_shouldDropEvent(currentEvent, self._previousEvent)) {
21
- IS_DEBUG_BUILD && logger.warn('Event dropped due to being a duplicate of previously captured event.');
22
- return null;
23
- }
24
- }
25
- catch (_oO) {
26
- return (self._previousEvent = currentEvent);
27
- }
28
- return (self._previousEvent = currentEvent);
29
- }
30
- return currentEvent;
31
- };
32
- eventProcessor.id = this.name;
33
- addGlobalEventProcessor(eventProcessor);
34
- }
35
- }
36
- /**
37
- * @inheritDoc
38
- */
39
- Dedupe.id = 'Dedupe';
5
+ class Dedupe {constructor() { Dedupe.prototype.__init.call(this); }
6
+ /**
7
+ * @inheritDoc
8
+ */
9
+ static __initStatic() {this.id = 'Dedupe';}
10
+
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ __init() {this.name = Dedupe.id;}
15
+
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+
20
+
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ setupOnce(addGlobalEventProcessor, getCurrentHub) {
25
+ var eventProcessor = currentEvent => {
26
+ var self = getCurrentHub().getIntegration(Dedupe);
27
+ if (self) {
28
+ // Juuust in case something goes wrong
29
+ try {
30
+ if (_shouldDropEvent(currentEvent, self._previousEvent)) {
31
+ IS_DEBUG_BUILD && logger.warn('Event dropped due to being a duplicate of previously captured event.');
32
+ return null;
33
+ }
34
+ } catch (_oO) {
35
+ return (self._previousEvent = currentEvent);
36
+ }
37
+
38
+ return (self._previousEvent = currentEvent);
39
+ }
40
+ return currentEvent;
41
+ };
42
+
43
+ eventProcessor.id = this.name;
44
+ addGlobalEventProcessor(eventProcessor);
45
+ }
46
+ } Dedupe.__initStatic();
47
+
40
48
  /** JSDoc */
41
49
  function _shouldDropEvent(currentEvent, previousEvent) {
42
- if (!previousEvent) {
43
- return false;
44
- }
45
- if (_isSameMessageEvent(currentEvent, previousEvent)) {
46
- return true;
47
- }
48
- if (_isSameExceptionEvent(currentEvent, previousEvent)) {
49
- return true;
50
- }
50
+ if (!previousEvent) {
51
51
  return false;
52
+ }
53
+
54
+ if (_isSameMessageEvent(currentEvent, previousEvent)) {
55
+ return true;
56
+ }
57
+
58
+ if (_isSameExceptionEvent(currentEvent, previousEvent)) {
59
+ return true;
60
+ }
61
+
62
+ return false;
52
63
  }
64
+
53
65
  /** JSDoc */
54
66
  function _isSameMessageEvent(currentEvent, previousEvent) {
55
- const currentMessage = currentEvent.message;
56
- const previousMessage = previousEvent.message;
57
- // If neither event has a message property, they were both exceptions, so bail out
58
- if (!currentMessage && !previousMessage) {
59
- return false;
60
- }
61
- // If only one event has a stacktrace, but not the other one, they are not the same
62
- if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) {
63
- return false;
64
- }
65
- if (currentMessage !== previousMessage) {
66
- return false;
67
- }
68
- if (!_isSameFingerprint(currentEvent, previousEvent)) {
69
- return false;
70
- }
71
- if (!_isSameStacktrace(currentEvent, previousEvent)) {
72
- return false;
73
- }
74
- return true;
67
+ var currentMessage = currentEvent.message;
68
+ var previousMessage = previousEvent.message;
69
+
70
+ // If neither event has a message property, they were both exceptions, so bail out
71
+ if (!currentMessage && !previousMessage) {
72
+ return false;
73
+ }
74
+
75
+ // If only one event has a stacktrace, but not the other one, they are not the same
76
+ if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) {
77
+ return false;
78
+ }
79
+
80
+ if (currentMessage !== previousMessage) {
81
+ return false;
82
+ }
83
+
84
+ if (!_isSameFingerprint(currentEvent, previousEvent)) {
85
+ return false;
86
+ }
87
+
88
+ if (!_isSameStacktrace(currentEvent, previousEvent)) {
89
+ return false;
90
+ }
91
+
92
+ return true;
75
93
  }
94
+
76
95
  /** JSDoc */
77
96
  function _isSameExceptionEvent(currentEvent, previousEvent) {
78
- const previousException = _getExceptionFromEvent(previousEvent);
79
- const currentException = _getExceptionFromEvent(currentEvent);
80
- if (!previousException || !currentException) {
81
- return false;
82
- }
83
- if (previousException.type !== currentException.type || previousException.value !== currentException.value) {
84
- return false;
85
- }
86
- if (!_isSameFingerprint(currentEvent, previousEvent)) {
87
- return false;
88
- }
89
- if (!_isSameStacktrace(currentEvent, previousEvent)) {
90
- return false;
91
- }
92
- return true;
97
+ var previousException = _getExceptionFromEvent(previousEvent);
98
+ var currentException = _getExceptionFromEvent(currentEvent);
99
+
100
+ if (!previousException || !currentException) {
101
+ return false;
102
+ }
103
+
104
+ if (previousException.type !== currentException.type || previousException.value !== currentException.value) {
105
+ return false;
106
+ }
107
+
108
+ if (!_isSameFingerprint(currentEvent, previousEvent)) {
109
+ return false;
110
+ }
111
+
112
+ if (!_isSameStacktrace(currentEvent, previousEvent)) {
113
+ return false;
114
+ }
115
+
116
+ return true;
93
117
  }
118
+
94
119
  /** JSDoc */
95
120
  function _isSameStacktrace(currentEvent, previousEvent) {
96
- let currentFrames = _getFramesFromEvent(currentEvent);
97
- let previousFrames = _getFramesFromEvent(previousEvent);
98
- // If neither event has a stacktrace, they are assumed to be the same
99
- if (!currentFrames && !previousFrames) {
100
- return true;
101
- }
102
- // If only one event has a stacktrace, but not the other one, they are not the same
103
- if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) {
104
- return false;
105
- }
106
- currentFrames = currentFrames;
107
- previousFrames = previousFrames;
108
- // If number of frames differ, they are not the same
109
- if (previousFrames.length !== currentFrames.length) {
110
- return false;
111
- }
112
- // Otherwise, compare the two
113
- for (let i = 0; i < previousFrames.length; i++) {
114
- const frameA = previousFrames[i];
115
- const frameB = currentFrames[i];
116
- if (frameA.filename !== frameB.filename ||
117
- frameA.lineno !== frameB.lineno ||
118
- frameA.colno !== frameB.colno ||
119
- frameA.function !== frameB.function) {
120
- return false;
121
- }
122
- }
121
+ let currentFrames = _getFramesFromEvent(currentEvent);
122
+ let previousFrames = _getFramesFromEvent(previousEvent);
123
+
124
+ // If neither event has a stacktrace, they are assumed to be the same
125
+ if (!currentFrames && !previousFrames) {
123
126
  return true;
127
+ }
128
+
129
+ // If only one event has a stacktrace, but not the other one, they are not the same
130
+ if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) {
131
+ return false;
132
+ }
133
+
134
+ currentFrames = currentFrames ;
135
+ previousFrames = previousFrames ;
136
+
137
+ // If number of frames differ, they are not the same
138
+ if (previousFrames.length !== currentFrames.length) {
139
+ return false;
140
+ }
141
+
142
+ // Otherwise, compare the two
143
+ for (let i = 0; i < previousFrames.length; i++) {
144
+ var frameA = previousFrames[i];
145
+ var frameB = currentFrames[i];
146
+
147
+ if (
148
+ frameA.filename !== frameB.filename ||
149
+ frameA.lineno !== frameB.lineno ||
150
+ frameA.colno !== frameB.colno ||
151
+ frameA.function !== frameB.function
152
+ ) {
153
+ return false;
154
+ }
155
+ }
156
+
157
+ return true;
124
158
  }
159
+
125
160
  /** JSDoc */
126
161
  function _isSameFingerprint(currentEvent, previousEvent) {
127
- let currentFingerprint = currentEvent.fingerprint;
128
- let previousFingerprint = previousEvent.fingerprint;
129
- // If neither event has a fingerprint, they are assumed to be the same
130
- if (!currentFingerprint && !previousFingerprint) {
131
- return true;
132
- }
133
- // If only one event has a fingerprint, but not the other one, they are not the same
134
- if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) {
135
- return false;
136
- }
137
- currentFingerprint = currentFingerprint;
138
- previousFingerprint = previousFingerprint;
139
- // Otherwise, compare the two
140
- try {
141
- return !!(currentFingerprint.join('') === previousFingerprint.join(''));
142
- }
143
- catch (_oO) {
144
- return false;
145
- }
162
+ let currentFingerprint = currentEvent.fingerprint;
163
+ let previousFingerprint = previousEvent.fingerprint;
164
+
165
+ // If neither event has a fingerprint, they are assumed to be the same
166
+ if (!currentFingerprint && !previousFingerprint) {
167
+ return true;
168
+ }
169
+
170
+ // If only one event has a fingerprint, but not the other one, they are not the same
171
+ if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) {
172
+ return false;
173
+ }
174
+
175
+ currentFingerprint = currentFingerprint ;
176
+ previousFingerprint = previousFingerprint ;
177
+
178
+ // Otherwise, compare the two
179
+ try {
180
+ return !!(currentFingerprint.join('') === previousFingerprint.join(''));
181
+ } catch (_oO) {
182
+ return false;
183
+ }
146
184
  }
185
+
147
186
  /** JSDoc */
148
187
  function _getExceptionFromEvent(event) {
149
- return event.exception && event.exception.values && event.exception.values[0];
188
+ return event.exception && event.exception.values && event.exception.values[0];
150
189
  }
190
+
151
191
  /** JSDoc */
152
192
  function _getFramesFromEvent(event) {
153
- const exception = event.exception;
154
- if (exception) {
155
- try {
156
- // @ts-ignore Object could be undefined
157
- return exception.values[0].stacktrace.frames;
158
- }
159
- catch (_oO) {
160
- return undefined;
161
- }
193
+ var exception = event.exception;
194
+
195
+ if (exception) {
196
+ try {
197
+ // @ts-ignore Object could be undefined
198
+ return exception.values[0].stacktrace.frames;
199
+ } catch (_oO) {
200
+ return undefined;
162
201
  }
163
- return undefined;
202
+ }
203
+ return undefined;
164
204
  }
165
- //# sourceMappingURL=dedupe.js.map
205
+
206
+ export { Dedupe };
207
+ //# sourceMappingURL=dedupe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dedupe.js","sourceRoot":"","sources":["../../../../src/integrations/dedupe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,2BAA2B;AAC3B,MAAM,OAAO,MAAM;IAAnB;QAME;;WAEG;QACI,SAAI,GAAW,MAAM,CAAC,EAAE,CAAC;IAgClC,CAAC;IAzBC;;OAEG;IACI,SAAS,CAAC,uBAA2D,EAAE,aAAwB;QACpG,MAAM,cAAc,GAAmB,YAAY,CAAC,EAAE;YACpD,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACpD,IAAI,IAAI,EAAE;gBACR,sCAAsC;gBACtC,IAAI;oBACF,IAAI,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE;wBACvD,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;wBACtG,OAAO,IAAI,CAAC;qBACb;iBACF;gBAAC,OAAO,GAAG,EAAE;oBACZ,OAAO,CAAC,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC;iBAC7C;gBAED,OAAO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IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,YAAY;AACZ,SAAS,mBAAmB,CAAC,KAAY;IACvC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAElC,IAAI,SAAS,EAAE;QACb,IAAI;YACF,uCAAuC;YACvC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;SAC9C;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,SAAS,CAAC;SAClB;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { Event, EventProcessor, Exception, Hub, Integration, StackFrame } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { IS_DEBUG_BUILD } from '../flags';\n\n/** Deduplication filter */\nexport class Dedupe implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Dedupe';\n\n /**\n * @inheritDoc\n */\n public name: string = Dedupe.id;\n\n /**\n * @inheritDoc\n */\n private _previousEvent?: Event;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n const eventProcessor: EventProcessor = currentEvent => {\n const self = getCurrentHub().getIntegration(Dedupe);\n if (self) {\n // Juuust in case something goes wrong\n try {\n if (_shouldDropEvent(currentEvent, self._previousEvent)) {\n IS_DEBUG_BUILD && logger.warn('Event dropped due to being a duplicate of previously captured event.');\n return null;\n }\n } catch (_oO) {\n return (self._previousEvent = currentEvent);\n }\n\n return (self._previousEvent = currentEvent);\n }\n return currentEvent;\n };\n\n eventProcessor.id = this.name;\n addGlobalEventProcessor(eventProcessor);\n }\n}\n\n/** JSDoc */\nfunction _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean {\n if (!previousEvent) {\n return false;\n }\n\n if (_isSameMessageEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n if (_isSameExceptionEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n return false;\n}\n\n/** JSDoc */\nfunction _isSameMessageEvent(currentEvent: Event, previousEvent: Event): boolean {\n const currentMessage = currentEvent.message;\n const previousMessage = previousEvent.message;\n\n // If neither event has a message property, they were both exceptions, so bail out\n if (!currentMessage && !previousMessage) {\n return false;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) {\n return false;\n }\n\n if (currentMessage !== previousMessage) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameExceptionEvent(currentEvent: Event, previousEvent: Event): boolean {\n const previousException = _getExceptionFromEvent(previousEvent);\n const currentException = _getExceptionFromEvent(currentEvent);\n\n if (!previousException || !currentException) {\n return false;\n }\n\n if (previousException.type !== currentException.type || previousException.value !== currentException.value) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameStacktrace(currentEvent: Event, previousEvent: Event): boolean {\n let currentFrames = _getFramesFromEvent(currentEvent);\n let previousFrames = _getFramesFromEvent(previousEvent);\n\n // If neither event has a stacktrace, they are assumed to be the same\n if (!currentFrames && !previousFrames) {\n return true;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) {\n return false;\n }\n\n currentFrames = currentFrames as StackFrame[];\n previousFrames = previousFrames as StackFrame[];\n\n // If number of frames differ, they are not the same\n if (previousFrames.length !== currentFrames.length) {\n return false;\n }\n\n // Otherwise, compare the two\n for (let i = 0; i < previousFrames.length; i++) {\n const frameA = previousFrames[i];\n const frameB = currentFrames[i];\n\n if (\n frameA.filename !== frameB.filename ||\n frameA.lineno !== frameB.lineno ||\n frameA.colno !== frameB.colno ||\n frameA.function !== frameB.function\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameFingerprint(currentEvent: Event, previousEvent: Event): boolean {\n let currentFingerprint = currentEvent.fingerprint;\n let previousFingerprint = previousEvent.fingerprint;\n\n // If neither event has a fingerprint, they are assumed to be the same\n if (!currentFingerprint && !previousFingerprint) {\n return true;\n }\n\n // If only one event has a fingerprint, but not the other one, they are not the same\n if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) {\n return false;\n }\n\n currentFingerprint = currentFingerprint as string[];\n previousFingerprint = previousFingerprint as string[];\n\n // Otherwise, compare the two\n try {\n return !!(currentFingerprint.join('') === previousFingerprint.join(''));\n } catch (_oO) {\n return false;\n }\n}\n\n/** JSDoc */\nfunction _getExceptionFromEvent(event: Event): Exception | undefined {\n return event.exception && event.exception.values && event.exception.values[0];\n}\n\n/** JSDoc */\nfunction _getFramesFromEvent(event: Event): StackFrame[] | undefined {\n const exception = event.exception;\n\n if (exception) {\n try {\n // @ts-ignore Object could be undefined\n return exception.values[0].stacktrace.frames;\n } catch (_oO) {\n return undefined;\n }\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"dedupe.js","sources":["../../../../src/integrations/dedupe.ts"],"sourcesContent":["import { Event, EventProcessor, Exception, Hub, Integration, StackFrame } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { IS_DEBUG_BUILD } from '../flags';\n\n/** Deduplication filter */\nexport class Dedupe implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Dedupe';\n\n /**\n * @inheritDoc\n */\n public name: string = Dedupe.id;\n\n /**\n * @inheritDoc\n */\n private _previousEvent?: Event;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n const eventProcessor: EventProcessor = currentEvent => {\n const self = getCurrentHub().getIntegration(Dedupe);\n if (self) {\n // Juuust in case something goes wrong\n try {\n if (_shouldDropEvent(currentEvent, self._previousEvent)) {\n IS_DEBUG_BUILD && logger.warn('Event dropped due to being a duplicate of previously captured event.');\n return null;\n }\n } catch (_oO) {\n return (self._previousEvent = currentEvent);\n }\n\n return (self._previousEvent = currentEvent);\n }\n return currentEvent;\n };\n\n eventProcessor.id = this.name;\n addGlobalEventProcessor(eventProcessor);\n }\n}\n\n/** JSDoc */\nfunction _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean {\n if (!previousEvent) {\n return false;\n }\n\n if (_isSameMessageEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n if (_isSameExceptionEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n return false;\n}\n\n/** JSDoc */\nfunction _isSameMessageEvent(currentEvent: Event, previousEvent: Event): boolean {\n const currentMessage = currentEvent.message;\n const previousMessage = previousEvent.message;\n\n // If neither event has a message property, they were both exceptions, so bail out\n if (!currentMessage && !previousMessage) {\n return false;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) {\n return false;\n }\n\n if (currentMessage !== previousMessage) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameExceptionEvent(currentEvent: Event, previousEvent: Event): boolean {\n const previousException = _getExceptionFromEvent(previousEvent);\n const currentException = _getExceptionFromEvent(currentEvent);\n\n if (!previousException || !currentException) {\n return false;\n }\n\n if (previousException.type !== currentException.type || previousException.value !== currentException.value) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameStacktrace(currentEvent: Event, previousEvent: Event): boolean {\n let currentFrames = _getFramesFromEvent(currentEvent);\n let previousFrames = _getFramesFromEvent(previousEvent);\n\n // If neither event has a stacktrace, they are assumed to be the same\n if (!currentFrames && !previousFrames) {\n return true;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) {\n return false;\n }\n\n currentFrames = currentFrames as StackFrame[];\n previousFrames = previousFrames as StackFrame[];\n\n // If number of frames differ, they are not the same\n if (previousFrames.length !== currentFrames.length) {\n return false;\n }\n\n // Otherwise, compare the two\n for (let i = 0; i < previousFrames.length; i++) {\n const frameA = previousFrames[i];\n const frameB = currentFrames[i];\n\n if (\n frameA.filename !== frameB.filename ||\n frameA.lineno !== frameB.lineno ||\n frameA.colno !== frameB.colno ||\n frameA.function !== frameB.function\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameFingerprint(currentEvent: Event, previousEvent: Event): boolean {\n let currentFingerprint = currentEvent.fingerprint;\n let previousFingerprint = previousEvent.fingerprint;\n\n // If neither event has a fingerprint, they are assumed to be the same\n if (!currentFingerprint && !previousFingerprint) {\n return true;\n }\n\n // If only one event has a fingerprint, but not the other one, they are not the same\n if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) {\n return false;\n }\n\n currentFingerprint = currentFingerprint as string[];\n previousFingerprint = previousFingerprint as string[];\n\n // Otherwise, compare the two\n try {\n return !!(currentFingerprint.join('') === previousFingerprint.join(''));\n } catch (_oO) {\n return false;\n }\n}\n\n/** JSDoc */\nfunction _getExceptionFromEvent(event: Event): Exception | undefined {\n return event.exception && event.exception.values && event.exception.values[0];\n}\n\n/** JSDoc */\nfunction _getFramesFromEvent(event: Event): StackFrame[] | undefined {\n const exception = event.exception;\n\n if (exception) {\n try {\n // @ts-ignore Object could be undefined\n return exception.values[0].stacktrace.frames;\n } catch (_oO) {\n return undefined;\n }\n }\n return undefined;\n}\n"],"names":[],"mappings":";;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}