Add measure to track app launches from the Downloads folder

This commit is contained in:
Sergio Padrino 2020-12-23 14:10:59 +01:00
parent 3cef97f340
commit 229c43f213
4 changed files with 47 additions and 0 deletions

View file

@ -355,6 +355,12 @@ export interface IDailyMeasures {
/** Number of times the user has encountered an unhandled rejection */
readonly unhandledRejectionCount: number
/**
* Whether the app was launched from the Downloads folder or not. This is only
* relevant on macOS, null will be sent otherwise.
*/
readonly launchedFromDownloadsFolder: boolean | null
}
export class StatsDatabase extends Dexie {

View file

@ -139,6 +139,7 @@ const DefaultDailyMeasures: IDailyMeasures = {
diffOptionsViewedCount: 0,
repositoryViewChangeCount: 0,
unhandledRejectionCount: 0,
launchedFromDownloadsFolder: null,
}
interface IOnboardingStats {
@ -1375,6 +1376,14 @@ export class StatsStore implements IStatsStore {
}))
}
public recordLaunchedFromDownloadsFolder(
launchedFromDownloadsFolder: boolean
) {
return this.updateDailyMeasures(m => ({
launchedFromDownloadsFolder,
}))
}
/** Post some data to our stats endpoint. */
private post(body: object): Promise<Response> {
const options: RequestInit = {

View file

@ -295,6 +295,15 @@ export class App extends React.Component<IAppProps, IAppState> {
log.info(`launching: ${getVersion()} (${getOS()})`)
log.info(`execPath: '${process.execPath}'`)
const launchedFromDownloadsFolder = this.isLaunchedFromDownloadsFolder(
process.execPath
)
if (launchedFromDownloadsFolder !== null) {
this.props.dispatcher.recordLaunchedFromDownloadsFolder(
launchedFromDownloadsFolder
)
}
}
private onMenuEvent(name: MenuEvent): any {
@ -2658,6 +2667,21 @@ export class App extends React.Component<IAppProps, IAppState> {
private isTutorialPaused() {
return this.state.currentOnboardingTutorialStep === TutorialStep.Paused
}
/**
* Whether the app was launched from the Downloads folder or not. This is only
* relevant on macOS, null will be returned otherwise.
*
* @param execPath Path of the process executable.
*/
private isLaunchedFromDownloadsFolder(execPath: string): boolean | null {
if (!__DARWIN__) {
return null
}
const downloadsPath = remote.app.getPath('downloads')
return execPath.startsWith(downloadsPath)
}
}
function NoRepositorySelected() {

View file

@ -2482,4 +2482,12 @@ export class Dispatcher {
public recordDiffOptionsViewed() {
return this.statsStore.recordDiffOptionsViewed()
}
public recordLaunchedFromDownloadsFolder(
launchedFromDownloadsFolder: boolean
) {
this.statsStore.recordLaunchedFromDownloadsFolder(
launchedFromDownloadsFolder
)
}
}