content,internal: move HaTS trigger to download doc pages

Moves the HaTS trigger to the install doc pages so
that surveys will prompt while file downloads are
in progress.

Change-Id: I9437909c96907740fa21a0176d86b6adfe45d574
Reviewed-on: https://go-review.googlesource.com/c/website/+/286775
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Trust: Jamal Carvalho <jamal@golang.org>
This commit is contained in:
Jamal Carvalho 2021-01-26 11:17:53 -05:00
Родитель 1007538d29
Коммит 0c2f86a568
5 изменённых файлов: 67 добавлений и 61 удалений

Просмотреть файл

@ -0,0 +1,62 @@
/**
* @license
* Copyright 2021 The Go Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
(function () {
var cookieName = 'HaTS_BKT_DIST';
var inBucket;
var cookies = decodeURIComponent(document.cookie).split(';');
for (let i = 0; i < cookies.length; i++) {
var c = cookies[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(cookieName + '=') == 0) {
inBucket = c.substring((cookieName + '=').length, c.length);
}
}
if (typeof inBucket === 'undefined') {
inBucket = String(Math.random() < 0.01);
document.cookie =
cookieName + '=' + inBucket + '; path=/; max-age=2592000;';
}
if (inBucket === 'true') {
document.cookie = cookieName + '=false ; path=/; max-age=2592000;';
var tag = document.createElement('script');
tag.src =
'https://www.gstatic.com/feedback/js/help/prod/service/lazy.min.js';
tag.type = 'text/javascript';
document.head.appendChild(tag);
tag.onload = function () {
var helpApi = window.help.service.Lazy.create(0, {
apiKey: 'AIzaSyDfBPfajByU2G6RAjUf5sjkMSSLNTj7MMc',
locale: 'en-US',
});
helpApi.requestSurvey({
triggerId: 'dz6fkRxyz0njVvnD1rP0QxCXzhSX',
callback: function (requestSurveyCallbackParam) {
if (!requestSurveyCallbackParam.surveyData) {
return;
}
helpApi.presentSurvey({
surveyData: requestSurveyCallbackParam.surveyData,
colorScheme: 1, // light
customZIndex: 10000,
});
},
});
};
}
})();

Просмотреть файл

@ -202,3 +202,4 @@ $ go version
</p>
<script async src="/doc/download.js"></script>
<script async src="/doc/hats.js"></script>

Просмотреть файл

@ -51,6 +51,7 @@ var files = []string{
"doc/docs.html",
"doc/download.js",
"doc/gopath_code.html",
"doc/hats.js",
"doc/install.html",
"doc/install-source.html",
"doc/manage-install.html",

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -242,66 +242,6 @@ $(document).ready(function() {
});
});
</script>
<script>
(function () {
var cookieName = 'HaTS_BKT_DIST';
var inBucket;
var cookies = decodeURIComponent(document.cookie).split(';');
for (let i = 0; i < cookies.length; i++) {
var c = cookies[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(cookieName + '=') == 0) {
inBucket = c.substring((cookieName + '=').length, c.length);
}
}
if (typeof inBucket === 'undefined') {
inBucket = String(Math.random() < 0.03);
document.cookie =
cookieName + '=' + inBucket + '; path=/; max-age=2592000;';
}
if (inBucket === 'true') {
var shouldPrompt = Math.random() < 0.1;
if (shouldPrompt) {
document.cookie = cookieName + '=false ; path=/; max-age=2592000;';
var tag = document.createElement('script');
tag.src =
'https://www.gstatic.com/feedback/js/help/prod/service/lazy.min.js';
tag.type = 'text/javascript';
document.head.appendChild(tag);
tag.onload = function () {
var helpApi = window.help.service.Lazy.create(0, {
apiKey: 'AIzaSyDfBPfajByU2G6RAjUf5sjkMSSLNTj7MMc',
locale: 'en-US',
});
helpApi.requestSurvey({
triggerId: 'dz6fkRxyz0njVvnD1rP0QxCXzhSX',
callback: function (requestSurveyCallbackParam) {
if (!requestSurveyCallbackParam.surveyData) {
return;
}
helpApi.presentSurvey({
surveyData: requestSurveyCallbackParam.surveyData,
colorScheme: 1, // light
customZIndex: 10000,
});
},
});
};
}
}
})();
</script>
{{end}}
{{define "releases"}}