@@ -17,15 +17,15 @@ import {
1717
1818import { isWeb , notWeb } from '../utils/environment' ;
1919import type { Screenshot } from '../wrapper' ;
20- import { getDataFromUri } from '../wrapper' ;
20+ import { getDataFromUri , NATIVE } from '../wrapper' ;
2121import { sentryLogo } from './branding' ;
2222import { defaultConfiguration } from './defaults' ;
2323import defaultStyles from './FeedbackWidget.styles' ;
2424import { getTheme } from './FeedbackWidget.theme' ;
2525import type { FeedbackGeneralConfiguration , FeedbackTextConfiguration , FeedbackWidgetProps , FeedbackWidgetState , FeedbackWidgetStyles , ImagePickerConfiguration } from './FeedbackWidget.types' ;
2626import { lazyLoadFeedbackIntegration } from './lazy' ;
2727import { getCapturedScreenshot } from './ScreenshotButton' ;
28- import { base64ToUint8Array , feedbackAlertDialog , isValidEmail , uint8ArrayToBase64 } from './utils' ;
28+ import { base64ToUint8Array , feedbackAlertDialog , isValidEmail } from './utils' ;
2929
3030/**
3131 * @beta
@@ -344,9 +344,16 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
344344 private _setCapturedScreenshot = ( screenshot : Screenshot ) : void => {
345345 if ( screenshot . data != null ) {
346346 logger . debug ( 'Setting captured screenshot:' , screenshot . filename ) ;
347- const base64String : string = uint8ArrayToBase64 ( screenshot . data ) ;
348- const dataUri = `data:${ screenshot . contentType } ;base64,${ base64String } ` ;
349- this . setState ( { filename : screenshot . filename , attachment : screenshot . data , attachmentUri : dataUri } ) ;
347+ NATIVE . encodeToBase64 ( screenshot . data ) . then ( ( base64String ) => {
348+ if ( base64String != null ) {
349+ const dataUri = `data:${ screenshot . contentType } ;base64,${ base64String } ` ;
350+ this . setState ( { filename : screenshot . filename , attachment : screenshot . data , attachmentUri : dataUri } ) ;
351+ } else {
352+ logger . error ( 'Failed to read image data from:' , screenshot . filename ) ;
353+ }
354+ } ) . catch ( ( error ) => {
355+ logger . error ( 'Failed to read image data from:' , screenshot . filename , 'error: ' , error ) ;
356+ } ) ;
350357 } else {
351358 logger . error ( 'Failed to read image data from:' , screenshot . filename ) ;
352359 }
0 commit comments