Skip to content

Commit

Permalink
Enabled opt-in/out to sentry telemetry per #57
Browse files Browse the repository at this point in the history
  • Loading branch information
rooey committed Jun 13, 2020
1 parent a6c5afe commit 809df1c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/manifest.json
Expand Up @@ -3,8 +3,8 @@
"name": "__MSG_appName__",
"short_name": "__MSG_shortName__",
"description": "__MSG_appDescription__",
"version": "3.0.0.36113",
"version_name": "3.0.0 Beta 2 - Build 36113",
"version": "3.0.0.36134",
"version_name": "3.0.0 Alpha - Build 36134",
"default_locale": "en",
"permissions": [
"identity",
Expand Down
11 changes: 10 additions & 1 deletion src/scripts/onedrive_client.js
Expand Up @@ -3,6 +3,8 @@
let storedAppInfo = null;

let appInfo = {
// Use set debugMode to true to enable verbose logging (alpha builds)
"debugMode": true,
"clientId": "7bee6942-63fb-4fbd-88d6-00394941de08",
"clientSecret": "KEYGOESINHERE",
"redirectUrl": chrome.identity.getRedirectURL(""),
Expand Down Expand Up @@ -31,7 +33,6 @@ class OneDriveClient {
authorize(successCallback, errorCallback) {
this.access_token_ = this.getTokenFromCookie('access');
if (this.access_token_) {
//console.log('already good');
successCallback();
}
else {
Expand Down Expand Up @@ -1026,6 +1027,14 @@ class OneDriveClient {
return '{' + entries.join(',') + '}';
}

writeLog(messageType, message, payload) {
var appInfo = this.getAppInfo();

if ((messageType === 'debug') && (appInfo.debugMode !==false)) return;
console.log('[' + messageType + '] ' + message, payload);
return;
};

};

// Export
Expand Down
42 changes: 26 additions & 16 deletions src/scripts/onedrive_fs.js
Expand Up @@ -23,7 +23,8 @@ class OneDriveFS {
onedriveClient.authorize(() => {
onedriveClient.getDriveData((driveInfo) => {
onedriveClient.getUserInfo((userInfo) => {
console.log(driveInfo);
onedriveClient.writeLog('debug', 'driveInfo', driveInfo);

const fileSystemId = this.createFileSystemID(driveInfo.id);
chrome.fileSystemProvider.getAll(fileSystems => {
let mounted = false;
Expand Down Expand Up @@ -55,15 +56,12 @@ class OneDriveFS {
}
});
}, reason => {
console.log(reason);
errorCallback(reason);
});
}, reason => {
console.log(reason);
errorCallback(reason);
});
}, reason => {
console.log(reason);
errorCallback(reason);
});
}
Expand Down Expand Up @@ -364,6 +362,7 @@ class OneDriveFS {
});
});
} else {
this.sendMessageToSentry('It worked', 'hooray');
callback(options, successCallback, errorCallback);
}
};
Expand Down Expand Up @@ -477,16 +476,20 @@ class OneDriveFS {
};

sendMessageToSentry(message, extra) {
/*if (Raven.isSetup()) {
Raven.captureMessage(new Error(message), {
extra: extra,
tags: {
'app.version': chrome.runtime.getManifest().version
}
});
}*/
console.log('sentrylognotsent:', message, extra);
};
this.useOptions('useSentry', use => {
if (!use) {
return;
}
if (Raven.isSetup()) {
Raven.captureMessage(new Error(message), {
extra: extra,
tags: {
'app.version': chrome.runtime.getManifest().version
}
});
}
});
}

getWatchers(fileSystemId) {
let watchers = this.watchers_[fileSystemId];
Expand All @@ -501,15 +504,22 @@ class OneDriveFS {
delete this.watchers_[fileSystemId];
}

useWatcher(callback) {
/*useWatcher(callback) {
chrome.storage.local.get('settings', items => {
const settings = items.settings || {};
callback(settings.useWatcher || false);
});
}*/

useOptions(options, callback) {
chrome.storage.local.get('settings', items => {
const settings = items.settings || {};
callback(settings[options] || false);
});
}

watchDirectory(fileSystemId, onedriveClient, entryPath) {
this.useWatcher(use => {
this.useOptions('useWatcher', use => {
if (!use) {
return;
}
Expand Down
25 changes: 21 additions & 4 deletions src/scripts/window.js
Expand Up @@ -52,12 +52,17 @@ class MountWindow {
});
}
document.querySelector('#useWatcherOn').addEventListener('click', () => {
this.onChangedUseWatcher(true);
this.onChangedUseOption('useWatcher', true);
});
document.querySelector('#useWatcherOff').addEventListener('click', () => {
this.onChangedUseWatcher(false);
this.onChangedUseOption('useWatcher', false);
});
}
document.querySelector('#useSentryOn').addEventListener('click', () => {
this.onChangedUseOption('useSentry', true);
});
document.querySelector('#useSentryOff').addEventListener('click', () => {
this.onChangedUseOption('useSentry', false);
}); }

onClickedBtnMount(evt) {
const btnMount = document.querySelector('#btnMount');
Expand Down Expand Up @@ -126,8 +131,10 @@ class MountWindow {
const settings = items.settings || {};
const openedFilesLimit = settings.openedFilesLimit || '10';
const useWatcher = settings.useWatcher || false;
const useSentry = settings.useSentry || false;
document.querySelector('#openedFilesLimit' + openedFilesLimit).checked = true;
document.querySelector('#useWatcher' + (useWatcher ? 'On' : 'Off')).checked = true;
document.querySelector('#useSentry' + (useSentry ? 'On' : 'Off')).checked = true;
$('#settingsDialog').modal('show');
});
}
Expand All @@ -144,14 +151,24 @@ class MountWindow {
});
}

onChangedUseWatcher(use) {
/*onChangedUseWatcher(use) {
chrome.storage.local.get('settings', items => {
const settings = items.settings || {};
settings.useWatcher = use;
chrome.storage.local.set({settings: settings}, () => {
console.log('Saving settings done.');
});
});
}*/

onChangedUseOption(options, use) {
chrome.storage.local.get('settings', items => {
const settings = items.settings || {};
settings[options] = use;
chrome.storage.local.set({settings: settings}, () => {
console.log('Saving settings done.');
});
});
}

};
Expand Down

0 comments on commit 809df1c

Please sign in to comment.