11import type { Client , Envelope , ErrorEvent , Event , TransactionEvent } from '@sentry/types' ;
22import { SentryError , SyncPromise , dsnToString , logger } from '@sentry/utils' ;
33
4- import { Scope , addBreadcrumb , getCurrentScope , getIsolationScope , makeSession , setCurrentClient } from '../../src' ;
4+ import {
5+ Scope ,
6+ addBreadcrumb ,
7+ getCurrentScope ,
8+ getIsolationScope ,
9+ lastEventId ,
10+ makeSession ,
11+ setCurrentClient ,
12+ } from '../../src' ;
513import * as integrationModule from '../../src/integration' ;
614import { TestClient , getDefaultTestClientOptions } from '../mocks/client' ;
715import { AdHocIntegration , TestIntegration } from '../mocks/integration' ;
@@ -226,7 +234,6 @@ describe('BaseClient', () => {
226234 const client = new TestClient ( options ) ;
227235
228236 client . captureException ( new Error ( 'test exception' ) ) ;
229-
230237 expect ( TestClient . instance ! . event ) . toEqual (
231238 expect . objectContaining ( {
232239 environment : 'production' ,
@@ -244,6 +251,14 @@ describe('BaseClient', () => {
244251 ) ;
245252 } ) ;
246253
254+ test ( 'sets the correct lastEventId' , ( ) => {
255+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
256+ const client = new TestClient ( options ) ;
257+
258+ const eventId = client . captureException ( new Error ( 'test exception' ) ) ;
259+ expect ( eventId ) . toEqual ( lastEventId ( ) ) ;
260+ } ) ;
261+
247262 test ( 'allows for providing explicit scope' , ( ) => {
248263 const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
249264 const client = new TestClient ( options ) ;
@@ -343,6 +358,14 @@ describe('BaseClient', () => {
343358 ) ;
344359 } ) ;
345360
361+ test ( 'sets the correct lastEventId' , ( ) => {
362+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
363+ const client = new TestClient ( options ) ;
364+
365+ const eventId = client . captureMessage ( 'test message' ) ;
366+ expect ( eventId ) . toEqual ( lastEventId ( ) ) ;
367+ } ) ;
368+
346369 test ( 'should call `eventFromException` if input to `captureMessage` is not a primitive' , ( ) => {
347370 const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
348371 const client = new TestClient ( options ) ;
@@ -444,6 +467,14 @@ describe('BaseClient', () => {
444467 ) ;
445468 } ) ;
446469
470+ test ( 'sets the correct lastEventId' , ( ) => {
471+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
472+ const client = new TestClient ( options ) ;
473+
474+ const eventId = client . captureEvent ( { message : 'message' } , undefined ) ;
475+ expect ( eventId ) . toEqual ( lastEventId ( ) ) ;
476+ } ) ;
477+
447478 test ( 'does not overwrite existing timestamp' , ( ) => {
448479 expect . assertions ( 2 ) ;
449480
0 commit comments