analytics menu
This commit is contained in:
@@ -1,30 +1,11 @@
|
|||||||
class BaseCtrl {
|
class BaseCtrl {
|
||||||
constructor(syncManager, dbManager, authManager) {
|
constructor(syncManager, dbManager, analyticsManager) {
|
||||||
dbManager.openDatabase(null, function(){
|
dbManager.openDatabase(null, function(){
|
||||||
// new database, delete syncToken so that items can be refetched entirely from server
|
// new database, delete syncToken so that items can be refetched entirely from server
|
||||||
syncManager.clearSyncToken();
|
syncManager.clearSyncToken();
|
||||||
syncManager.sync();
|
syncManager.sync();
|
||||||
})
|
})
|
||||||
|
|
||||||
// load analytics
|
|
||||||
window._paq = window._paq || [];
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var u="https://piwik.standardnotes.org/";
|
|
||||||
window._paq.push(['setTrackerUrl', u+'piwik.php']);
|
|
||||||
window._paq.push(['setSiteId', '2']);
|
|
||||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
|
||||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
|
||||||
})();
|
|
||||||
|
|
||||||
var analyticsId = authManager.getUserAnalyticsId();
|
|
||||||
if(analyticsId) {
|
|
||||||
window._paq.push(['setUserId', analyticsId]);
|
|
||||||
}
|
|
||||||
window._paq.push(['trackPageView']);
|
|
||||||
window._paq.push(['enableLinkTracking']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||||
|
|||||||
51
app/assets/javascripts/app/services/analyticsManager.js
Normal file
51
app/assets/javascripts/app/services/analyticsManager.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
class AnalyticsManager {
|
||||||
|
|
||||||
|
constructor(authManager) {
|
||||||
|
this.authManager = authManager;
|
||||||
|
|
||||||
|
var status = localStorage.getItem("analyticsEnabled");
|
||||||
|
if(status === null) {
|
||||||
|
this.enabled = true;
|
||||||
|
} else {
|
||||||
|
this.enabled = JSON.parse(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.enabled === true) {
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatus(enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
localStorage.setItem("analyticsEnabled", JSON.stringify(enabled));
|
||||||
|
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleStatus() {
|
||||||
|
this.setStatus(!this.enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize() {
|
||||||
|
// load analytics
|
||||||
|
window._paq = window._paq || [];
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var u="https://piwik.standardnotes.org/";
|
||||||
|
window._paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||||
|
window._paq.push(['setSiteId', '2']);
|
||||||
|
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||||
|
g.type='text/javascript'; g.id="piwik", g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
||||||
|
})();
|
||||||
|
|
||||||
|
var analyticsId = this.authManager.getUserAnalyticsId();
|
||||||
|
if(analyticsId) {
|
||||||
|
window._paq.push(['setUserId', analyticsId]);
|
||||||
|
}
|
||||||
|
window._paq.push(['trackPageView', "AppInterface"]);
|
||||||
|
window._paq.push(['enableLinkTracking']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
angular.module('app.frontend').service('analyticsManager', AnalyticsManager);
|
||||||
@@ -6,7 +6,7 @@ class AccountMenu {
|
|||||||
this.scope = {};
|
this.scope = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
controller($scope, authManager, modelManager, syncManager, dbManager, $timeout) {
|
controller($scope, authManager, modelManager, syncManager, dbManager, analyticsManager, $timeout) {
|
||||||
'ngInject';
|
'ngInject';
|
||||||
|
|
||||||
$scope.formData = {mergeLocal: true, url: syncManager.serverURL};
|
$scope.formData = {mergeLocal: true, url: syncManager.serverURL};
|
||||||
@@ -14,6 +14,7 @@ class AccountMenu {
|
|||||||
$scope.server = syncManager.serverURL;
|
$scope.server = syncManager.serverURL;
|
||||||
|
|
||||||
$scope.syncStatus = syncManager.syncStatus;
|
$scope.syncStatus = syncManager.syncStatus;
|
||||||
|
$scope.analyticsManager = analyticsManager;
|
||||||
|
|
||||||
$scope.encryptionKey = function() {
|
$scope.encryptionKey = function() {
|
||||||
return authManager.keys().mk;
|
return authManager.keys().mk;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
.panel-body.large-padding
|
.panel-body.large-padding
|
||||||
%div{"ng-if" => "!user"}
|
%div{"ng-if" => "!user"}
|
||||||
%div{"ng-if" => "!formData.confirmPassword"}
|
%div{"ng-if" => "!formData.confirmPassword"}
|
||||||
%p Enter your <a href="https://standardnotes.org" target="_blank">Standard File</a> account information. You can also register for free using the default server address.
|
%p Enter your account information. You can also register for free using the default server address.
|
||||||
.small-v-space
|
.small-v-space
|
||||||
|
|
||||||
%form.mt-5
|
%form.mt-5
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
%button.btn.dark-button.half-button{"ng-click" => "submitRegistrationForm()"}
|
%button.btn.dark-button.half-button{"ng-click" => "submitRegistrationForm()"}
|
||||||
%span Register
|
%span Register
|
||||||
%br
|
%br
|
||||||
.block{"style" => "margin-top: 10px; font-size: 14px; font-weight: bold; text-align: center;"}
|
.block.bold.center-align{"style" => "font-size: 14px;"}
|
||||||
%a.btn{"ng-click" => "showResetForm = !showResetForm"} Passwords cannot be forgotten.
|
%a.btn.mt-5{"ng-click" => "formData.showResetForm = !formData.showResetForm"} Passwords cannot be forgotten.
|
||||||
|
|
||||||
%div{"ng-if" => "formData.confirmPassword"}
|
%div{"ng-if" => "formData.confirmPassword"}
|
||||||
%h3 Confirm your password.
|
%h3 Confirm your password.
|
||||||
@@ -33,10 +33,12 @@
|
|||||||
|
|
||||||
%em.block.center-align.mt-10{"ng-if" => "formData.status", "style" => "font-size: 14px;"} {{formData.status}}
|
%em.block.center-align.mt-10{"ng-if" => "formData.status", "style" => "font-size: 14px;"} {{formData.status}}
|
||||||
|
|
||||||
%div{"ng-if" => "showResetForm"}
|
.gray-bg.medium-padding{"ng-if" => "formData.showResetForm"}
|
||||||
%p{"style" => "font-size: 13px; text-align: center;"}
|
%p{"style" => "font-size: 13px;"}
|
||||||
Because notes are locally encrypted using a secret key derived from your password, there's no way to decrypt these notes if you forget your password.
|
Because notes are locally encrypted using a secret key derived from your password, there's no way to decrypt these notes if you forget your password.
|
||||||
For this reason, Standard Notes cannot offer a password reset option. You <strong>must</strong> make sure to store or remember your password.
|
For this reason, Standard Notes cannot offer a password reset option. You
|
||||||
|
%span.bold must
|
||||||
|
make sure to store or remember your password.
|
||||||
|
|
||||||
%div{"ng-if" => "user"}
|
%div{"ng-if" => "user"}
|
||||||
%h2 {{user.email}}
|
%h2 {{user.email}}
|
||||||
@@ -92,7 +94,7 @@
|
|||||||
%input{"type" => "radio", "ng-model" => "archiveFormData.encrypted", "ng-value" => "false", "ng-change" => "archiveFormData.encrypted = false"}
|
%input{"type" => "radio", "ng-model" => "archiveFormData.encrypted", "ng-value" => "false", "ng-change" => "archiveFormData.encrypted = false"}
|
||||||
Decrypted
|
Decrypted
|
||||||
|
|
||||||
%a.block{"ng-click" => "downloadDataArchive()"} Download Data Archive
|
%a.block{"ng-click" => "downloadDataArchive()", "ng-class" => "{'mt-5' : !user}"} Download Data Archive
|
||||||
|
|
||||||
%label.block.mt-5
|
%label.block.mt-5
|
||||||
%input{"type" => "file", "style" => "display: none;", "file-change" => "->", "handler" => "importFileSelected(files)"}
|
%input{"type" => "file", "style" => "display: none;", "file-change" => "->", "handler" => "importFileSelected(files)"}
|
||||||
@@ -107,4 +109,14 @@
|
|||||||
|
|
||||||
.spinner.mt-10{"ng-if" => "importData.loading"}
|
.spinner.mt-10{"ng-if" => "importData.loading"}
|
||||||
|
|
||||||
|
.mt-25
|
||||||
|
%h4 Analytics
|
||||||
|
%p
|
||||||
|
Help Standard Notes improve by sending anonymous data on general usage. Learn more
|
||||||
|
%a{"href" => "https://standardnotes.org/philosophy", "target" => "_blank"} here.
|
||||||
|
%div.mt-5
|
||||||
|
%label Status:
|
||||||
|
{{analyticsManager.enabled ? "Enabled" : "Disabled"}}
|
||||||
|
%a{"ng-click" => "analyticsManager.toggleStatus()"} {{analyticsManager.enabled ? "Disable" : "Enable"}}
|
||||||
|
|
||||||
%a.block.mt-25.red{"ng-click" => "destroyLocalData()"} {{ user ? "Sign out and clear local data" : "Clear all local data" }}
|
%a.block.mt-25.red{"ng-click" => "destroyLocalData()"} {{ user ? "Sign out and clear local data" : "Clear all local data" }}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
%global-extensions-menu{"ng-if" => "ctrl.showExtensionsMenu"}
|
%global-extensions-menu{"ng-if" => "ctrl.showExtensionsMenu"}
|
||||||
|
|
||||||
.footer-bar-link
|
.footer-bar-link
|
||||||
%a{"href" => "https://standardnotes.org", "target" => "_blank"}
|
%a{"href" => "https://standardnotes.org/help", "target" => "_blank"}
|
||||||
Help
|
Help
|
||||||
|
|
||||||
.pull-right
|
.pull-right
|
||||||
|
|||||||
Reference in New Issue
Block a user