diff --git a/README.md b/README.md index dd9c519..a54eafb 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Web-Maker * Save as HTML file * Edit in CodePen +Follow [@webmaker_app](https://twitter.com/intent/follow?screen_name=webmaker_app) for updates or tweet out feature requests and suggestions. + ### License MIT Licensed diff --git a/src/analytics.js b/src/analytics.js new file mode 100644 index 0000000..12215b6 --- /dev/null +++ b/src/analytics.js @@ -0,0 +1,22 @@ +window.trackEvent = function (category, action, label, value) { + if (window.ga) { + ga('send', 'event', category, action, label, value); + } +} + +// if online, load after 2 seconds +if (navigator.onLine) { + setTimeout(function() { + (function(i,s,o,g,r,a,m){ + i['GoogleAnalyticsObject']=r; + i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); + + ga('create', 'UA-87786708-1', {'cookieDomain': 'none'}); + // required for chrome extension protocol + ga('set', 'checkProtocolTask', function(){ /* nothing */ }); + ga('send', 'pageview'); + }, 0); +} \ No newline at end of file diff --git a/src/index.html b/src/index.html index d91fdf2..cb97b3d 100644 --- a/src/index.html +++ b/src/index.html @@ -732,11 +732,11 @@ + - \ No newline at end of file diff --git a/src/manifest.json b/src/manifest.json index 983ab73..fc4ba6f 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { "name": "Web Maker", - "version": "1.7.1", + "version": "1.7.2", "manifest_version": 2, "description": "Convert new tabs into an offline playground for your web experiments", "homepage_url": "https://kushagragour.in/lab/web-maker", @@ -8,7 +8,7 @@ "storage", "tabs" ], - "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", + "content_security_policy": "script-src 'self' https://www.google-analytics.com 'unsafe-eval'; object-src 'self'", "options_ui": { "page": "options.html", "chrome_style": true diff --git a/src/script.js b/src/script.js index c31c56b..ae416ca 100644 --- a/src/script.js +++ b/src/script.js @@ -113,6 +113,7 @@ document.body.classList.add('layout-' + mode); resetSplitting(); + trackEvent('ui', 'toggleLayout', mode); } function saveSetting(setting, value, cb) { @@ -270,6 +271,7 @@ handleModeRequirements(value); editur.cm.html.setOption('mode', modes[value].cmMode); CodeMirror.autoLoadMode(editur.cm.html, modes[value].cmMode); + trackEvent('ui', 'updateCodeMode', 'html', value); } function updateCssMode(value) { cssMode = value; @@ -277,6 +279,7 @@ handleModeRequirements(value); editur.cm.css.setOption('mode', modes[value].cmMode); CodeMirror.autoLoadMode(editur.cm.css, modes[value].cmMode); + trackEvent('ui', 'updateCodeMode', 'css', value); } function updateJsMode(value) { jsMode = value; @@ -284,6 +287,7 @@ handleModeRequirements(value); editur.cm.js.setOption('mode', modes[value].cmMode); CodeMirror.autoLoadMode(editur.cm.js, modes[value].cmMode); + trackEvent('ui', 'updateCodeMode', 'js', value); // FIXME: Will be saved as part of global settings /* chrome.storage.sync.set({ @@ -469,6 +473,7 @@ document.body.appendChild(a); a.click(); a.remove(); + trackEvent('fn', 'saveFileComplete'); }); } @@ -524,6 +529,7 @@ utils.onButtonClick(helpBtn, function () { helpModal.classList.toggle('is-modal-visible'); + trackEvent('ui', 'helpButtonClick'); }); notificationsBtn.addEventListener('click', function () { @@ -535,6 +541,7 @@ lastSeenVersion: version }, function () {}); } + trackEvent('ui', 'notificationButtonClick'); return false; }); @@ -557,10 +564,14 @@ .replace(/'/g, "'") codepenForm.querySelector('input').value = json; codepenForm.submit(); + trackEvent('ui', 'openInCodepen'); e.preventDefault(); }); - utils.onButtonClick(saveHtmlBtn, saveFile); + utils.onButtonClick(saveHtmlBtn, function () { + saveFile(); + trackEvent('ui', 'saveHtmlClick'); + }); utils.onButtonClick(openBtn, openSavedItemsPane); utils.onButtonClick(saveBtn, saveItem); utils.onButtonClick(newBtn, createNewItem); @@ -622,6 +633,7 @@ if ((event.ctrlKey || event.metaKey) && (event.keyCode === 83)){ event.preventDefault(); saveFile(); + trackEvent('ui', 'saveFileKeyboardShortcut'); } }); @@ -646,6 +658,7 @@ url: 'chrome://extensions?options=' + chrome.i18n.getMessage('@@extension_id') }); } + trackEvent('ui', 'settingsBtnClick'); }); chrome.storage.local.get({