Remove hardcoded /badge page that is DEV-only ✂️✂️✂️ (#16303)
* Remove hardcoded /badge page that is DEV-only * Remove /badge test * Remove scheduled job
This commit is contained in:
parent
e85aec1d11
commit
1ae10d7e6f
4 changed files with 0 additions and 143 deletions
|
|
@ -1,128 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title><%= community_name %> ❤️</title>
|
||||
</head>
|
||||
<body>
|
||||
<% if @html_variant %>
|
||||
<%= @html_variant.html.html_safe %>
|
||||
<div id="html-variant-element" data-variant-id="<%= @html_variant.id %>"></div>
|
||||
<script>
|
||||
setTimeout(function () {
|
||||
var tokenMeta = document.querySelector("meta[name='csrf-token']")
|
||||
var isBot = /bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex/i.test(navigator.userAgent) // is crawler
|
||||
var variantEl = document.getElementById("html-variant-element")
|
||||
if (tokenMeta && !isBot) {
|
||||
var dataBody = {
|
||||
html_variant_id: variantEl.dataset.variantId
|
||||
};
|
||||
var csrfToken = tokenMeta.getAttribute('content');
|
||||
trackHTMLVariantTrial(dataBody, csrfToken)
|
||||
var successLinks = document.querySelectorAll('a,button'); //track all links and button clicks within nav
|
||||
for (var i = 0; i < successLinks.length; i++) {
|
||||
successLinks[i].addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
var goTo = e.target.href
|
||||
trackHtmlVariantSuccess(dataBody, csrfToken)
|
||||
setTimeout(function () {
|
||||
window.location.href = goTo;
|
||||
}, 250)
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 1500)
|
||||
|
||||
function trackHTMLVariantTrial(dataBody, csrfToken) {
|
||||
var randomNumber = Math.floor(Math.random() * 10); // 1 in 10; Only track 1 in 10 impressions
|
||||
if (randomNumber) {
|
||||
window.fetch('/html_variant_trials', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-Token': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(dataBody),
|
||||
credentials: 'same-origin',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function trackHtmlVariantSuccess(dataBody, csrfToken) {
|
||||
window.fetch('/html_variant_successes', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-Token': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(dataBody),
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
}
|
||||
|
||||
fetchBaseData();
|
||||
|
||||
function fetchBaseData() {
|
||||
var xmlhttp;
|
||||
if (window.XMLHttpRequest) {
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
} else {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
xmlhttp.onreadystatechange = function () {
|
||||
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
|
||||
var json = JSON.parse(xmlhttp.responseText);
|
||||
if (json.token) {
|
||||
removeExistingCSRF();
|
||||
}
|
||||
var meta = document.createElement('meta');
|
||||
var metaTag = document.querySelector("meta[name='csrf-token']");
|
||||
meta.name = "csrf-param";
|
||||
meta.content = json.param;
|
||||
document.head.appendChild(meta);
|
||||
var meta = document.createElement('meta');
|
||||
meta.name = "csrf-token";
|
||||
meta.content = json.token;
|
||||
document.head.appendChild(meta);
|
||||
document.body.dataset.loaded = "true";
|
||||
}
|
||||
};
|
||||
|
||||
xmlhttp.open("GET", "/async_info/base_data", true);
|
||||
xmlhttp.send();
|
||||
}
|
||||
|
||||
function removeExistingCSRF() {
|
||||
var csrfTokenMeta = document.querySelector("meta[name='csrf-token']");
|
||||
var csrfParamMeta = document.querySelector("meta[name='csrf-param']");
|
||||
if (csrfTokenMeta && csrfParamMeta) {
|
||||
csrfTokenMeta.parentNode.removeChild(csrfTokenMeta);
|
||||
csrfParamMeta.parentNode.removeChild(csrfParamMeta);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<% if Settings::General.ga_tracking_id %>
|
||||
<script>
|
||||
(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', '<%= Settings::General.ga_tracking_id %>', 'auto');
|
||||
ga('set', 'anonymizeIp', true);
|
||||
ga('send', 'pageview');
|
||||
ga('send', 'event', 'view', '/badge version impression', '<%= @html_variant.name %>', null);
|
||||
</script>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -255,7 +255,6 @@ Rails.application.routes.draw do
|
|||
get "/welcome", to: "pages#welcome"
|
||||
get "/challenge", to: "pages#challenge"
|
||||
get "/checkin", to: "pages#checkin"
|
||||
get "/badge", to: "pages#badge", as: :pages_badge
|
||||
get "/💸", to: redirect("t/hiring")
|
||||
get "/survey", to: redirect("https://dev.to/ben/final-thoughts-on-the-state-of-the-web-survey-44nn")
|
||||
get "/sponsors", to: "pages#sponsors"
|
||||
|
|
|
|||
|
|
@ -100,12 +100,6 @@ hourly_feed_cache_bust:
|
|||
class: "BustCachePathWorker"
|
||||
args:
|
||||
- "/feed.xml"
|
||||
hourly_badge_cache_bust:
|
||||
description: "Busts the edge cache of badges (runs hourly on the hour)"
|
||||
cron: "0 * * * *"
|
||||
class: "BustCachePathWorker"
|
||||
args:
|
||||
- "/badge"
|
||||
daily_home_cache_bust:
|
||||
description: "Busts the edge cache of the homepage (runs daily at 00:00 UTC)"
|
||||
cron: "0 0 * * *"
|
||||
|
|
|
|||
|
|
@ -219,14 +219,6 @@ RSpec.describe "Pages", type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /badge" do
|
||||
it "has proper headline" do
|
||||
html_variant = create(:html_variant, group: "badge_landing_page", published: true, approved: true)
|
||||
get "/badge"
|
||||
expect(response.body).to include(html_variant.html)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /robots.txt" do
|
||||
it "has proper text" do
|
||||
get "/robots.txt"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue