PromucFlow_constructor/app/client/public/index.html
Nikhil Nandagopal e411df0a64
Added check so that existing installs don't get telemetry (#1698)
* Adding the segment key to the tagged release
* Also opting out of telemetry data in CI builds

Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2020-11-11 23:54:19 +05:30

153 lines
6.9 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon"
href="https://res.cloudinary.com/dwpfockn8/image/upload/v1597920848/favicons/favicon-orange_pxfmdc.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Appsmith</title>
<style>
#loader {
position: fixed;
left: 0;
top: 0;
height: 4px;
background: #D36500;
transition: all ease-in 0.3s;
}
</style>
<script async src="https://www.googletagmanager.com/gtag/js?id=%REACT_APP_GOOGLE_ANALYTICS_ID%"></script>
<script>
// GA SETUP
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', "%REACT_APP_GOOGLE_ANALYTICS_ID%");
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="loader" style="width: 30vw;"></div>
<div id="root"></div>
<script type="text/javascript">
// Note: The following handler is necessary for when we have a new deployment.
// What happens?
// The chunk hashes change, resulting in the server not able to find
// the previous chunks which the client will keep requesting, until the "new" index.html
// is loaded. This new index.html is loaded on page reload.
// Current solution:
// 1. Make sure it is indeed Appsmith's chunk which failed to fetch (regex match)
// 2. Reload once, and don't reload again.
// Pitfalls:
// 1. First reload will not fetch the new index.html, if the server isn't yet ready to serve it.
// this can happen when the server is still deploying.
// TODO(abhinav): A comprehensive solution is involve the user when repeated
// reloads are necessary.
// 1. Delay reloads in increasing durations
// 2. Allow the user to pre-emptively reload or cancel reloads altogether.
window.onerror = function(message, url) {
const regex = /\/static\/js\/(\w.+).js$/;
const chunkLoadErrorMessage = "Unexpected token '<'"
if(regex.test(url) && url.indexOf(window.location.host) > -1 && message.includes(chunkLoadErrorMessage)) {
console.log("chunk load failed!", url);
// First check if we've set the flag to not reload on chunk load fail
const donotReload = window.localStorage.getItem("donotReloadOnChunkLoadFail");
if(!donotReload){
// If donotReload is set to false or undefined, we can set it to true and reload
// This signifies that this is the first time this happened in this session.
window.localStorage.setItem("donotReloadOnChunkLoadFail", true);
window.location.assign(window.location.href);
}
}
};
window.addEventListener("DOMContentLoaded", (event) => {
document.getElementById("loader").style.width = "50vw";
});
window.addEventListener("load", (event) => {
// This signifies that we've had a chunk load failure in this session
// We clear the entry, as otherwise, we will have a repeated reload scenario.
window.localStorage.removeItem("donotReloadOnChunkLoadFail");
document.getElementById("loader").style.width = "100vw";
setTimeout(() => {
document.getElementById("loader").style.opacity = 0;
});
});
const registerPageServiceWorker = () => {
if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
navigator.serviceWorker.register("/pageService.js").catch(error => {
console.log("Service Worker Registration failed: " + error);
});
});
}
};
registerPageServiceWorker();
</script>
<script type="text/javascript">
const parseConfig = (config) => {
if (config.indexOf("__") === 0 || config.indexOf("$") === 0)
return "";
return config.trim();
}
const LOG_LEVELS = ["debug", "error"];
const CONFIG_LOG_LEVEL_INDEX = LOG_LEVELS.indexOf(parseConfig("__APPSMITH_CLIENT_LOG_LEVEL__"));
const APP_ID = parseConfig("__APPSMITH_INTERCOM_APP_ID__");
const CLOUD_HOSTING = parseConfig("__APPSMITH_CLOUD_HOSTING__").length > 0;
const DISABLE_TELEMETRY = parseConfig("__APPSMITH_DISABLE_TELEMETRY__").toLowerCase();
// Initialize the Intercom library
if (APP_ID.length && APP_ID[0] !== "%" && CLOUD_HOSTING) {
(function () { var w = window; var ic = w.Intercom; if (typeof ic === "function") { ic('reattach_activator'); ic('update', w.intercomSettings); } else { var d = document; var i = function () { i.c(arguments); }; i.q = []; i.c = function (args) { i.q.push(args); }; w.Intercom = i; var l = function () { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.intercom.io/widget/' + APP_ID; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); }; if (document.readyState === 'complete') { l(); } else if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })();
}
window.SENTRY_CONFIG = parseConfig("__APPSMITH_SENTRY_DSN__");
window.APPSMITH_FEATURE_CONFIGS = {
sentry: {
dsn: parseConfig("__APPSMITH_SENTRY_DSN__"),
release: parseConfig("__APPSMITH_SENTRY_RELEASE__"),
environment: parseConfig("__APPSMITH_SENTRY_ENVIRONMENT__"),
},
smartLook: {
id: parseConfig("__APPSMITH_SMART_LOOK_ID__"),
},
enableGoogleOAuth: parseConfig("__APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__").length > 0,
enableGithubOAuth: parseConfig("__APPSMITH_OAUTH2_GITHUB_CLIENT_ID__").length > 0,
enableRapidAPI: parseConfig("__APPSMITH_MARKETPLACE_ENABLED__").length > 0,
segment: {
apiKey: parseConfig("__APPSMITH_SEGMENT_KEY__"),
ceKey: parseConfig("__APPSMITH_SEGMENT_CE_KEY__"),
},
optimizely: parseConfig("__APPSMITH_OPTIMIZELY_KEY__"),
enableMixpanel: parseConfig("__APPSMITH_SEGMENT_KEY__").length > 0,
algolia: {
apiId: parseConfig("__APPSMITH_ALGOLIA_API_ID__"),
apiKey: parseConfig("__APPSMITH_ALGOLIA_API_KEY__"),
indexName: parseConfig("__APPSMITH_ALGOLIA_SEARCH_INDEX_NAME__"),
},
logLevel: CONFIG_LOG_LEVEL_INDEX > -1 ? LOG_LEVELS[CONFIG_LOG_LEVEL_INDEX] : LOG_LEVELS[1],
google: parseConfig("__APPSMITH_GOOGLE_MAPS_API_KEY__"),
cloudHosting: CLOUD_HOSTING,
enableTNCPP: parseConfig("__APPSMITH_TNC_PP__").length > 0,
appVersion: {
id: parseConfig("__APPSMITH_VERSION_ID__"),
releaseDate: parseConfig("__APPSMITH_VERSION_RELEASE_DATE__")
},
intercomAppID: APP_ID,
mailEnabled: parseConfig("__APPSMITH_MAIL_ENABLED__").length > 0,
disableTelemetry: DISABLE_TELEMETRY === "" || DISABLE_TELEMETRY === 'true' ,
};
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.4.0/tinymce.min.js" referrerpolicy="origin"></script>
</body>
</html>