@@ -16,6 +16,7 @@ import { ipcChannelUtils, IPCMode, IpcUtils, RendererStatus } from '../common/ip
1616import { registerProtocol } from './electron-normalize.js' ;
1717import { createRendererEventLoopBlockStatusHandler } from './integrations/renderer-anr.js' ;
1818import { rendererProfileFromIpc } from './integrations/renderer-profiling.js' ;
19+ import { getOsDeviceLogAttributes } from './log.js' ;
1920import { mergeEvents } from './merge.js' ;
2021import { normalizeReplayEnvelope } from './normalize.js' ;
2122import { ElectronMainOptionsInternal } from './sdk.js' ;
@@ -55,7 +56,7 @@ function captureEventFromRenderer(
5556 event : Event ,
5657 dynamicSamplingContext : Partial < DynamicSamplingContext > | undefined ,
5758 attachments : Attachment [ ] ,
58- contents ? : WebContents ,
59+ contents : WebContents | undefined ,
5960) : void {
6061 const process = contents ? options ?. getRendererName ?.( contents ) || 'renderer' : 'renderer' ;
6162
@@ -160,7 +161,14 @@ function handleScope(options: ElectronMainOptionsInternal, jsonScope: string): v
160161 }
161162}
162163
163- function handleLogFromRenderer ( client : Client , options : ElectronMainOptionsInternal , log : SerializedLog ) : void {
164+ function handleLogFromRenderer (
165+ client : Client ,
166+ options : ElectronMainOptionsInternal ,
167+ log : SerializedLog ,
168+ contents : WebContents | undefined ,
169+ ) : void {
170+ const process = contents ? options ?. getRendererName ?.( contents ) || 'renderer' : 'renderer' ;
171+
164172 log . attributes = log . attributes || { } ;
165173
166174 if ( options . release ) {
@@ -174,6 +182,26 @@ function handleLogFromRenderer(client: Client, options: ElectronMainOptionsInter
174182 log . attributes [ 'sentry.sdk.name' ] = { value : 'sentry.javascript.electron' , type : 'string' } ;
175183 log . attributes [ 'sentry.sdk.version' ] = { value : SDK_VERSION , type : 'string' } ;
176184
185+ log . attributes [ 'electron.process' ] = { value : process , type : 'string' } ;
186+
187+ const osDeviceAttributes = getOsDeviceLogAttributes ( client ) ;
188+
189+ if ( osDeviceAttributes [ 'os.name' ] ) {
190+ log . attributes [ 'os.name' ] = { value : osDeviceAttributes [ 'os.name' ] , type : 'string' } ;
191+ }
192+ if ( osDeviceAttributes [ 'os.version' ] ) {
193+ log . attributes [ 'os.version' ] = { value : osDeviceAttributes [ 'os.version' ] , type : 'string' } ;
194+ }
195+ if ( osDeviceAttributes [ 'device.brand' ] ) {
196+ log . attributes [ 'device.brand' ] = { value : osDeviceAttributes [ 'device.brand' ] , type : 'string' } ;
197+ }
198+ if ( osDeviceAttributes [ 'device.model' ] ) {
199+ log . attributes [ 'device.model' ] = { value : osDeviceAttributes [ 'device.model' ] , type : 'string' } ;
200+ }
201+ if ( osDeviceAttributes [ 'device.family' ] ) {
202+ log . attributes [ 'device.family' ] = { value : osDeviceAttributes [ 'device.family' ] , type : 'string' } ;
203+ }
204+
177205 _INTERNAL_captureSerializedLog ( client , log ) ;
178206}
179207
@@ -218,7 +246,7 @@ function configureProtocol(client: Client, ipcUtil: IpcUtils, options: ElectronM
218246 } else if ( ipcUtil . urlMatches ( request . url , 'envelope' ) && data ) {
219247 handleEnvelope ( client , options , data , getWebContents ( ) ) ;
220248 } else if ( ipcUtil . urlMatches ( request . url , 'structured-log' ) && data ) {
221- handleLogFromRenderer ( client , options , JSON . parse ( data . toString ( ) ) ) ;
249+ handleLogFromRenderer ( client , options , JSON . parse ( data . toString ( ) ) , getWebContents ( ) ) ;
222250 } else if ( rendererStatusChanged && ipcUtil . urlMatches ( request . url , 'status' ) && data ) {
223251 const contents = getWebContents ( ) ;
224252 if ( contents ) {
@@ -258,8 +286,8 @@ function configureClassic(client: Client, ipcUtil: IpcUtils, options: ElectronMa
258286 ipcMain . on ( ipcUtil . createKey ( 'envelope' ) , ( { sender } , env : Uint8Array | string ) =>
259287 handleEnvelope ( client , options , env , sender ) ,
260288 ) ;
261- ipcMain . on ( ipcUtil . createKey ( 'structured-log' ) , ( _ , log : SerializedLog ) =>
262- handleLogFromRenderer ( client , options , log ) ,
289+ ipcMain . on ( ipcUtil . createKey ( 'structured-log' ) , ( { sender } , log : SerializedLog ) =>
290+ handleLogFromRenderer ( client , options , log , sender ) ,
263291 ) ;
264292
265293 const rendererStatusChanged = createRendererEventLoopBlockStatusHandler ( client ) ;
0 commit comments