File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,46 @@ export default class SentryEventWorker extends Worker {
155155 * Skip non-event items
156156 */
157157 if ( itemHeader . type !== 'event' ) {
158+ if ( itemHeader . type === 'client_report' ) {
159+ /**
160+ * Sentry "client_report" items are useful for debugging dropped events.
161+ * We log internals here to make diagnosing SDK/reporting issues easier.
162+ */
163+ try {
164+ let decodedPayload : unknown = itemPayload ;
165+
166+ /**
167+ * Sometimes Sentry parses the itemPayload as a Uint8Array.
168+ * Decode it to JSON so it can be logged meaningfully.
169+ */
170+ if ( decodedPayload instanceof Uint8Array ) {
171+ const textDecoder = new TextDecoder ( ) ;
172+ decodedPayload = textDecoder . decode ( decodedPayload as Uint8Array ) ;
173+ }
174+
175+ if ( typeof decodedPayload === 'string' ) {
176+ try {
177+ decodedPayload = JSON . parse ( decodedPayload ) ;
178+ } catch {
179+ /**
180+ * Keep the raw string if it isn't valid JSON.
181+ */
182+ }
183+ }
184+
185+ this . logger . info ( 'Received client_report item; logging internals:' ) ;
186+ this . logger . json ( {
187+ envelopeHeaders,
188+ itemHeader,
189+ payload : decodedPayload ,
190+ } ) ;
191+ } catch ( clientReportError ) {
192+ this . logger . warn ( 'Failed to decode/log client_report item:' , clientReportError ) ;
193+ this . logger . info ( '👇 Here is the raw client_report item:' ) ;
194+ this . logger . json ( item ) ;
195+ }
196+ }
197+
158198 this . logger . info ( `Skipping non-event item of type: ${ itemHeader . type } ` ) ;
159199 return 'skipped' ;
160200 }
You can’t perform that action at this time.
0 commit comments