chore: metrics infrastructure for first-time events#483
Conversation
There was a problem hiding this comment.
Would it be simpler just to maintain an array in the store of the unique event names that have been sent?
That way we don't have to default the map of every single event during initialisation, we don't have to worry about adding new events down the line and ensuring we default those also, plus we can simplify the logic here and always append the event name and just save the Set to remove any duplicates?
There was a problem hiding this comment.
Indeed, removed the initialisation in the constructor and as you mentioned much simpler to just maintain what we already sent and not bother with new events.
There was a problem hiding this comment.
We discussed the importance of keeping this state as isolated as possible to potentially persist between installs, so should this be in it's own electron store and therefore a separate file?
I'm not sure what segmentApiCalls does in truth, but I'm assuming it could still function in a separate store.
There was a problem hiding this comment.
I've just put this state isolated in its own electron store, now should be fine.
Now the segmentApiCalls I'm removing it as there is no usage at the moment with this approach.
packages/app/src/app/ui/preload.ts
Outdated
There was a problem hiding this comment.
As mentioned in the other PR, i'd vote to put these directly on the electronBridge and to remove this helper method.
5550b15 to
9e4b3fd
Compare
abb6d50 to
919ced6
Compare
a01a817 to
5b0a191
Compare
bb2db6c to
544efea
Compare
499291e to
b544d3d
Compare
There was a problem hiding this comment.
Do we need the Boolean( here? Won't includes return a boolean already and the negation keep it as a boolean?
There was a problem hiding this comment.
Would it be clearer to rename this processedEvents or seenEvents?
There was a problem hiding this comment.
As this is visible in the filesystem, should we keep it generic and maybe just call it mmd-desktop-metrics?
There was a problem hiding this comment.
Just for visibility as we discussed in a channel apart, I'm not using mmd-desktop-metrics just because it will clash with the first electron store we have in metrics.
There was a problem hiding this comment.
Shouldn't those be saved only if MetricsDecision.PENDING?
There was a problem hiding this comment.
this.saveProcessedEvents is saving the names of the events that were already triggered that way we know if it's the first time we track the event and include a property to further be filtered.
There was a problem hiding this comment.
Makes sense. Naming is confusing though. Should we rename it to saveProcessedEventName? Also we should rename the method signature. Should reveive an eventName: string instead of a event: string. That will make the signature consistent with both the saveProcessedEvents and the ipcMain.handle('analytics-track'....
d21726f to
5f3e6ff
Compare
32df9e1 to
634f27c
Compare
5f3e6ff to
66e52f0
Compare
634f27c to
0bbaf10
Compare
66e52f0 to
dc0c381
Compare
* feat: metrics infrastructure for first-time events (#483)
Overview
The aim of this PR is to implement the infrastructure for first-time events and send events to the segment whenever the main process is started and also when UI is loaded.
Changes
metrics-service.ts: created the infrastructure for first-time events.pageandscreenmethods from segment SDK on the analytics wrapper.ipcMain. handlerstometrics-service.ts.DESKTOP_APP_STARTINGsending right beforeDesktopApp.init()in themain.tsDESKTOP_UI_LOADEDsending fromroutes.component.jsUI_CRITICAL_ERRORincluded an additional event because either routes loaded orcomponentDidCatchin case of an error.Issues
resolves: #416 and #481