Skip to content

Commit bdec71a

Browse files
committed
Increment error and resource counter
1 parent 225dc46 commit bdec71a

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

packages/electron/src/domain/rum/mainProcessTracking.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,30 @@ export function startMainProcessTracking(
5656
},
5757
},
5858
_dd: {
59-
document_version: 1,
59+
document_version: 0,
6060
},
6161
} as RumViewEvent
6262

63-
onRumEventObservable.notify({ event: applicationLaunch, source: 'main-process' })
63+
onRumEventObservable.subscribe(({ event, source }) => {
64+
if (source === 'renderer') {
65+
return
66+
}
67+
switch (event.type) {
68+
case RumEventType.RESOURCE:
69+
;(applicationLaunch.view.resource.count as any) += 1
70+
updateView()
71+
break
72+
case RumEventType.ERROR:
73+
;(applicationLaunch.view.error.count as any) += 1
74+
updateView()
75+
break
76+
}
77+
})
78+
79+
updateView()
80+
onActivityObservable.subscribe(updateView)
6481

65-
onActivityObservable.subscribe(() => {
82+
function updateView() {
6683
applicationLaunch = combine(applicationLaunch, {
6784
view: {
6885
time_spent: toServerDuration(elapsed(applicationStart, timeStampNow())),
@@ -72,7 +89,7 @@ export function startMainProcessTracking(
7289
},
7390
})
7491
onRumEventObservable.notify({ event: applicationLaunch, source: 'main-process' })
75-
})
92+
}
7693
// TODO session expiration / renewal
7794
// TODO useragent
7895
}

0 commit comments

Comments
 (0)