@@ -19,6 +19,9 @@ export class Hub {
19
19
/** Is a {@link Layer}[] containing the client and scope */
20
20
private readonly stack : Layer [ ] = [ ] ;
21
21
22
+ /** Contains the last event id of a captured event. */
23
+ private _lastEventId ?: string ;
24
+
22
25
/**
23
26
* Creates a new instance of the hub, will push one {@link Layer} into the
24
27
* internal stack on creation.
@@ -169,7 +172,7 @@ export class Hub {
169
172
* @returns The generated eventId.
170
173
*/
171
174
public captureException ( exception : any , hint ?: SentryEventHint ) : string {
172
- const eventId = uuid4 ( ) ;
175
+ const eventId = ( this . _lastEventId = uuid4 ( ) ) ;
173
176
this . invokeClientAsync ( 'captureException' , exception , {
174
177
...hint ,
175
178
event_id : eventId ,
@@ -186,7 +189,7 @@ export class Hub {
186
189
* @returns The generated eventId.
187
190
*/
188
191
public captureMessage ( message : string , level ?: Severity , hint ?: SentryEventHint ) : string {
189
- const eventId = uuid4 ( ) ;
192
+ const eventId = ( this . _lastEventId = uuid4 ( ) ) ;
190
193
this . invokeClientAsync ( 'captureMessage' , message , level , {
191
194
...hint ,
192
195
event_id : eventId ,
@@ -200,13 +203,20 @@ export class Hub {
200
203
* @param event The event to send to Sentry.
201
204
*/
202
205
public captureEvent ( event : SentryEvent ) : string {
203
- const eventId = uuid4 ( ) ;
206
+ const eventId = ( this . _lastEventId = uuid4 ( ) ) ;
204
207
this . invokeClientAsync ( 'captureEvent' , event , {
205
208
event_id : eventId ,
206
209
} ) ;
207
210
return eventId ;
208
211
}
209
212
213
+ /**
214
+ * @returns The last event id of a captured event.
215
+ */
216
+ public lastEventId ( ) : string | undefined {
217
+ return this . _lastEventId ;
218
+ }
219
+
210
220
/**
211
221
* Records a new breadcrumb which will be attached to future events.
212
222
*
0 commit comments