@@ -21,7 +21,6 @@ import type { ErrorEvent, Event, TransactionEvent } from '../../src/types-hoist/
2121import type { SpanJSON } from '../../src/types-hoist/span' ;
2222import * as debugLoggerModule from '../../src/utils/debug-logger' ;
2323import * as miscModule from '../../src/utils/misc' ;
24- import * as stringModule from '../../src/utils/string' ;
2524import * as timeModule from '../../src/utils/time' ;
2625import { getDefaultTestClientOptions , TestClient } from '../mocks/client' ;
2726import { AdHocIntegration , AsyncTestIntegration , TestIntegration } from '../mocks/integration' ;
@@ -37,7 +36,6 @@ const clientProcess = vi.spyOn(TestClient.prototype as any, '_process');
3736
3837vi . spyOn ( miscModule , 'uuid4' ) . mockImplementation ( ( ) => '12312012123120121231201212312012' ) ;
3938vi . spyOn ( debugLoggerModule , 'consoleSandbox' ) . mockImplementation ( cb => cb ( ) ) ;
40- vi . spyOn ( stringModule , 'truncate' ) . mockImplementation ( str => str ) ;
4139vi . spyOn ( timeModule , 'dateTimestampInSeconds' ) . mockImplementation ( ( ) => 2020 ) ;
4240
4341describe ( 'Client' , ( ) => {
@@ -263,6 +261,36 @@ describe('Client', () => {
263261 ) ;
264262 } ) ;
265263
264+ test ( 'does not truncate exception values by default' , ( ) => {
265+ const exceptionMessageLength = 10_000 ;
266+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
267+ const client = new TestClient ( options ) ;
268+
269+ client . captureException ( new Error ( 'a' . repeat ( exceptionMessageLength ) ) ) ;
270+ expect ( TestClient . instance ! . event ) . toEqual (
271+ expect . objectContaining ( {
272+ exception : {
273+ values : [ { type : 'Error' , value : 'a' . repeat ( exceptionMessageLength ) } ] ,
274+ } ,
275+ } ) ,
276+ ) ;
277+ } ) ;
278+
279+ test ( 'truncates exception values according to `maxValueLength` option' , ( ) => {
280+ const maxValueLength = 10 ;
281+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN , maxValueLength } ) ;
282+ const client = new TestClient ( options ) ;
283+
284+ client . captureException ( new Error ( 'a' . repeat ( 50 ) ) ) ;
285+ expect ( TestClient . instance ! . event ) . toEqual (
286+ expect . objectContaining ( {
287+ exception : {
288+ values : [ { type : 'Error' , value : `${ 'a' . repeat ( maxValueLength ) } ...` } ] ,
289+ } ,
290+ } ) ,
291+ ) ;
292+ } ) ;
293+
266294 test ( 'sets the correct lastEventId' , ( ) => {
267295 const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
268296 const client = new TestClient ( options ) ;
0 commit comments