<commit_before>import { app, BrowserWindow } from 'electron';
import { argv } from 'yargs';
import path from 'path';
import ua from 'universal-analytics';
import uuid from 'uuid';
import winston from 'winston';

import configureApp from './main/configureApp';
import generateBrowserConfig from './main/configureBrowser';
import { positionOnScreen } from './_util';

import EmitterClass from './main/utils/Emitter';
import SettingsClass from './main/utils/Settings';
import WindowManagerClass from './main/utils/WindowManager';
import PlaybackAPIClass from './main/utils/PlaybackAPI';
import I3IpcHelperClass from './main/utils/I3IpcHelper';

import handleStartupEvent from './squirrel';

import { updateShortcuts } from './main/utils/_shortcutManager';

app.setAppUserModelId('com.marshallofsound.gpmdp.core');
updateShortcuts();

(() => {
  if (handleStartupEvent()) {
    return;
  }

  // Keep a global reference of the window object, if you don't, the window will
  // be closed automatically when the JavaScript object is garbage collected.
  let mainWindow = null;

  // DEV: Make the app single instance
  const shouldQuit = app.makeSingleInstance(() => {
    if (mainWindow) {
      if (mainWindow.isMinimized()) mainWindow.restore();
      mainWindow.focus();
      mainWindow.show();
      mainWindow.setSkipTaskbar(false);
      if (app.dock && app.dock.show) app.dock.show();
    }
  });

  if (shouldQuit) {
    app.quit();
    return;
  }

  if (process.env.TEST_SPEC) {
    global.Settings = new SettingsClass('.test', true);
  } else {
    global.Settings = new SettingsClass();
  }

  global.DEV_MODE = process.env['TEST_SPEC'] || argv.development || argv.dev; // eslint-disable-line

  // Initialize the logger with some default logging levels.
  const defaultFileLogLevel = 'info';
  const defaultConsoleLogLevel = global.DEV_MODE ? 'debug' : 'error';
  global.Logger = new (winston.Logger)({
    transports: [
      new (winston.transports.File)({
        filename: path.resolve(app.getPath('userData'), 'gpmdp.log'),
        level: defaultFileLogLevel,
        maxsize: 5000000,
        maxfiles: 2,
      }),
      new (winston.transports.Console)({
        level: defaultConsoleLogLevel,
      }),
    ],
  });

  Logger.info('Application started.');

  configureApp(app);

  global.Emitter = new EmitterClass();
  global.WindowManager = new WindowManagerClass();
  global.PlaybackAPI = new PlaybackAPIClass();

  // UA for GA
  // This is for user reporting<commit_msg>Fix development mode recognition in production<commit_after>import { app, BrowserWindow } from 'electron';
import path from 'path';
import ua from 'universal-analytics';
import uuid from 'uuid';
import winston from 'winston';

import configureApp from './main/configureApp';
import generateBrowserConfig from './main/configureBrowser';
import { positionOnScreen } from './_util';

import EmitterClass from './main/utils/Emitter';
import SettingsClass from './main/utils/Settings';
import WindowManagerClass from './main/utils/WindowManager';
import PlaybackAPIClass from './main/utils/PlaybackAPI';
import I3IpcHelperClass from './main/utils/I3IpcHelper';

import handleStartupEvent from './squirrel';

import { updateShortcuts } from './main/utils/_shortcutManager';

app.setAppUserModelId('com.marshallofsound.gpmdp.core');
updateShortcuts();

(() => {
  if (handleStartupEvent()) {
    return;
  }

  // Keep a global reference of the window object, if you don't, the window will
  // be closed automatically when the JavaScript object is garbage collected.
  let mainWindow = null;

  // DEV: Make the app single instance
  const shouldQuit = app.makeSingleInstance(() => {
    if (mainWindow) {
      if (mainWindow.isMinimized()) mainWindow.restore();
      mainWindow.focus();
      mainWindow.show();
      mainWindow.setSkipTaskbar(false);
      if (app.dock && app.dock.show) app.dock.show();
    }
  });

  if (shouldQuit) {
    app.quit();
    return;
  }

  if (process.env.TEST_SPEC) {
    global.Settings = new SettingsClass('.test', true);
  } else {
    global.Settings = new SettingsClass();
  }

  global.DEV_MODE = process.env['TEST_SPEC'] || process.argv.some(arg => arg === '--development') || process.argv.some(arg => arg === '--dev'); // eslint-disable-line

  // Initialize the logger with some default logging levels.
  const defaultFileLogLevel = 'info';
  const defaultConsoleLogLevel = global.DEV_MODE ? 'debug' : 'error';
  global.Logger = new (winston.Logger)({
    transports: [
      new (winston.transports.File)({
        filename: path.resolve(app.getPath('userData'), 'gpmdp.log'),
        level: defaultFileLogLevel,
        maxsize: 5000000,
        maxfiles: 2,
      }),
      new (winston.transports.Console)({
        level: defaultConsoleLogLevel,
      }),
    ],
  });

  Logger.info('Application started.');

  configureApp(app);

  global.Emitter = new EmitterClass();
  global.WindowManager = new WindowManagerClass();
  global.PlaybackAPI = new PlaybackAPIClass();

  // UA for GA
  // This is for user reporting
{'fraction_non_alphanumeric': 0.13392680514342237, 'fraction_numerical': 0.003956478733926805, 'mean_word_length': 3.6728280961182995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2428093', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1478, 'n_words': 388}