import UserStore from '../stores/UserStore';
import StateStore from '../stores/StateStore';
import path from 'path';
var stateFile = StateStore.stateFilePath;
var libraryDir = StateStore.libraryDirectory;

import walk from 'walk';
import fs from 'fs';

class BugReportService {
  submitReport(description) {
    let directories = [];

    let options = {
      listeners: {
        names: function (root, nodeNamesArray) {
          nodeNamesArray.sort(function (a, b) {
            if (a > b) return 1;
            if (a < b) return -1;
            return 0;
          });
        }
      , directories: function (root, dirStatsArray, next) {
          directories.push(root);
          next();
        }
      , file: function (root, fileStats, next) {
          next();
        }
      , errors: function (root, nodeStatsArray, next) {
          next();
        }
      }
    };

    let walker = walk.walkSync(libraryDir, options);

    fs.readFile(stateFile, 'utf8', function (err, data) {
      let stateObj = JSON.parse(data);
      _LTracker.push({
              'text': 'Complaint Report',
              'description': description,
              'system_info': {
                appVersion: window.navigator.appVersion,
                language: window.navigator.language,
                oscpu: window.navigator.oscpu
              },
              'username': UserStore.user.sub,
              'client_version': StateStore.getClientVersion(),
              'kimochi-temp': directories,
              'settings.json': stateObj,
          });
    });
  }
}

export default new BugReportService()

import UserStore from '../stores/UserStore';
import StateStore from '../stores/StateStore';
import path from 'path';
var stateFile = StateStore.stateFilePath;
var libraryDir = StateStore.libraryDirectory;

import walk from 'walk';
import fs from 'fs';

class BugReportService {
  submitReport(description) {
    let directories = [];

    let options = {
      listeners: {
        names: function (root, nodeNamesArray) {
          nodeNamesArray.sort(function (a, b) {
            if (a > b) return 1;
            if (a < b) return -1;
            return 0;
          });
        }
      , directories: function (root, dirStatsArray, next) {
          directories.push(root);
          next();
        }
      , file: function (root, fileStats, next) {
          next();
        }
      , errors: function (root, nodeStatsArray, next) {
          next();
        }
      }
    };

    let walker = walk.walkSync(libraryDir, options);

    fs.readFile(stateFile, 'utf8', function (err, data) {
      let stateObj = JSON.parse(data);
      _LTracker.push({
              'text': 'Complaint Report',
              'description': description,
              'system_info': {
                appVersion: window.navigator.appVersion,
                language: window.navigator.language,
                oscpu: window.navigator.oscpu
              },
              'username': UserStore.user ? UserStore.user.sub : 'not logged in',
              'client_version': StateStore.getClientVersion(),
              'kimochi-temp': directories,
              'settings.json': stateObj,
          });
    });
  }
}

export default new BugReportService()

fix null bug on login page complaint form