Skip to content

Commit 1896281

Browse files
committed
Now tracks clicks on conversion buttons, menu items, and other UI elements. Back button moved. Documentation is linked to snippets. Update notification has been changed to not activate unless the user is installing or still using a version below 4.0.
1 parent c66af89 commit 1896281

File tree

6 files changed

+86
-39
lines changed

6 files changed

+86
-39
lines changed

css/popup.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ div.convertable_apps .detected__app {
155155

156156
.back-button {
157157
display: none;
158+
position: relative;
159+
bottom: 3px;
158160
}
159161

160162
.converter-tabs {
@@ -700,6 +702,7 @@ img.tooltip_image {
700702
/*border-bottom: 1px solid #DDDDDD !important;*/
701703
border-radius: 0px !important;
702704
padding: 0;
705+
display: inline-block;
703706
}
704707

705708
.ui-widget.ui-widget-content {

extended_apps.json

Lines changed: 45 additions & 24 deletions
Large diffs are not rendered by default.

html/popup.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ <h3 class="not-supported title">
7070
</h3>
7171
</div>
7272
<div class="container"></div>
73+
7374
<div class="converter-tabs">
75+
<button class="back-button">
76+
<object type="image/svg+xml" data="../images/back_button.svg" id="back-icon">
77+
</object>
78+
</button>
7479
<ul></ul>
7580
</div>
76-
<button class="back-button">
77-
<object type="image/svg+xml" data="../images/back_button.svg" id="back-icon">
78-
</object>
79-
</button>
81+
8082
</body>
8183
</html>

js/driver.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fetch('https://raw.githubusercontent.com/AliasIO/Wappalyzer/master/src/apps.json
120120
})
121121
.catch(error => wappalyzer.log(`GET apps.json: ${error}`, 'driver', 'error'));
122122

123-
// Version check
123+
// Version check. We only show this notification for new users and users upgrading from versions below 4.0
124124
(async () => {
125125
const { version } = browser.runtime.getManifest();
126126
const previousVersion = await getOption('version');
@@ -129,7 +129,7 @@ fetch('https://raw.githubusercontent.com/AliasIO/Wappalyzer/master/src/apps.json
129129
console.log("previous version: " + previousVersion)
130130

131131

132-
if (previousVersion === null || version !== previousVersion) {
132+
if (previousVersion === null || previousVersion < 4.0) {
133133
openTab({
134134
url: `https://github.com/ampproject/amp-readiness/wiki/AMP-Readiness-4.0`,
135135
});

js/popup.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,30 @@ $(window).on('load', function() {
3030
* Handles click event on </> buttons for code conversion
3131
*/
3232
$('.detected__app-convert').click(function(e) {
33+
trackButton(e);
3334
e.preventDefault();
3435
e.stopPropagation();
3536
console.log("Converting code for: " + $(this).data('type'))
3637
convertApp($(this).data('type'));
3738
});
3839

3940
$('.settings-button').click(function(e) {
41+
trackButton(e);
4042
e.preventDefault();
4143
e.stopPropagation();
4244
console.log("Clicked settings button");
4345
$(".settings-dropdown").css("display", "block");
4446
});
4547

4648
$('.feedback-button').click(function(e) {
49+
trackButton(e);
4750
e.preventDefault();
4851
e.stopPropagation();
4952
window.open("https://github.com/ampproject/amp-readiness/issues/new");
5053
});
5154

5255
$('#license-button').click(function(e) {
56+
trackButton(e);
5357
if (chrome.runtime.openOptionsPage) {
5458
chrome.runtime.openOptionsPage();
5559
} else {
@@ -58,6 +62,7 @@ $(window).on('load', function() {
5862
});
5963

6064
$('.back-button').click(function(e) {
65+
trackButton(e);
6166
e.preventDefault();
6267
e.stopPropagation();
6368
$('.container').show();
@@ -137,7 +142,10 @@ $(window).on('load', function() {
137142
$('.converter-tabs').append("<div id='" + hash + "'></div>");
138143
});
139144

145+
140146
$('.converter-tabs').tabs();
147+
148+
141149

142150
$('.ui-tabs-tab').click(function(e) {
143151
var appName = $(this).first().text();
@@ -153,11 +161,12 @@ function convertApp(app) {
153161
if(!$('.converter-tabs #' + appHash).is(':empty')) {
154162
console.log("already generated snippet!");
155163
} else {
156-
var template, content = null;
164+
var template, content, link = null;
157165
var result = [];
158166
// Loop through regexes
159167
content = convertableApps[app].content;
160168
template = convertableApps[app].template;
169+
link = convertableApps[app].link;
161170
//We will revisit code completion later
162171
// var expressions = typeof convertableApps[app].regex === "string" ? [convertableApps[app].regex] : convertableApps[app].regex;
163172
// // Check for matches on the first regex
@@ -186,10 +195,12 @@ function convertApp(app) {
186195
// }
187196
console.log(template);
188197
console.log(content);
198+
console.log(link);
189199

190200
renderedHTML = renderAppConversionHtml(template, app);
191201
var html = content ? '<p class="converted-content">' + content + '</p>' : '';
192-
html += '<pre><code class="language-html">' + renderedHTML + '</code></pre>';
202+
html = '<pre><code class="language-html">' + renderedHTML + '</code></pre>';
203+
html += '<p class="converted-content">More documentation available <a target="_blank" href="' + link + '">here<a/></p>';
193204

194205
$('.converter-tabs #'+ appHash).prepend(html);
195206
}
@@ -217,9 +228,9 @@ function convertApp(app) {
217228
// function renderAppConversionHtml(html, result, app) {
218229
function renderAppConversionHtml(html, app) {
219230
if (convertableApps[app].type === "amp-analytics"){
220-
html = "//Add this to <head>\n" +
231+
html = "<!-- Add this to <head> -->\n" +
221232
"<script async custom-element=\"amp-analytics\" src=\"https://cdn.ampproject.org/v0/amp-analytics-0.1.js\"></script>\n" +
222-
"//Add this to <body>\n" +
233+
"<!-- Add this to <body> -->\n" +
223234
html;
224235
}
225236
// if (result != null) {
@@ -237,7 +248,6 @@ function renderAppConversionHtml(html, app) {
237248
function replaceDomWhenReady(dom) {
238249
if (/complete|interactive|loaded/.test(document.readyState)) {
239250
replaceDom(dom);
240-
241251
} else {
242252
document.addEventListener('DOMContentLoaded', () => {
243253
replaceDom(dom);
@@ -643,7 +653,18 @@ _gaq.push(['_setAccount', 'UA-58015925-3']);
643653
_gaq.push(['_trackPageview']);
644654

645655
(function() {
646-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
656+
var ga = document.createElement('script');
657+
ga.type = 'text/javascript';
658+
ga.async = true;
647659
ga.src = 'https://ssl.google-analytics.com/ga.js';
648-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
649-
})();
660+
var s = document.getElementsByTagName('script')[0];
661+
s.parentNode.insertBefore(ga, s);
662+
})();
663+
664+
function trackButton(e) {
665+
console.log(e);
666+
if (e.target.className === "detected__app-convert") {
667+
_gaq.push(['_trackEvent', "Conversion Button for " + e.target.dataset.type, 'clicked']);
668+
} else
669+
_gaq.push(['_trackEvent', "UI Button " + e.target.className, 'clicked']);
670+
};

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": "Jeffrey Jose, Phillip Kriegel, Frank Broersen",
55
"homepage_url": "https://github.com/ampproject/ampbench/tree/master/readiness-tool",
66
"description": "Identify web technologies that are relevant to AMP",
7-
"version": "4.0.1",
7+
"version": "4.0.2",
88
"default_locale": "en",
99
"manifest_version": 2,
1010
"icons": {

0 commit comments

Comments
 (0)