1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-02 03:25:53 +01:00

Expose Git SHA to window (#1847)

* expose git sha

* move to global.d.ts

* fix vercel domain
This commit is contained in:
Kostas Bariotis 2020-06-30 22:03:13 +01:00 committed by GitHub
parent 9a5ae05bbf
commit 2a25480272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

1
src/global.d.ts vendored

@ -10,6 +10,7 @@ interface Document {
interface Window { interface Window {
ClipboardItem: any; ClipboardItem: any;
__EXCALIDRAW_SHA__: string;
} }
interface Clipboard extends EventTarget { interface Clipboard extends EventTarget {

@ -25,12 +25,16 @@ if (
const SentryEnvHostnameMap: { [key: string]: string } = { const SentryEnvHostnameMap: { [key: string]: string } = {
"excalidraw.com": "production", "excalidraw.com": "production",
"now.sh": "staging", "vercel.app": "staging",
}; };
const REACT_APP_DISABLE_SENTRY =
process.env.REACT_APP_DISABLE_SENTRY === "true";
const REACT_APP_GIT_SHA = process.env.REACT_APP_GIT_SHA as string;
// Disable Sentry locally or inside the Docker to avoid noise/respect privacy // Disable Sentry locally or inside the Docker to avoid noise/respect privacy
const onlineEnv = const onlineEnv =
process.env.REACT_APP_DISABLE_SENTRY !== "true" && !REACT_APP_DISABLE_SENTRY &&
Object.keys(SentryEnvHostnameMap).find( Object.keys(SentryEnvHostnameMap).find(
(item) => window.location.hostname.indexOf(item) >= 0, (item) => window.location.hostname.indexOf(item) >= 0,
); );
@ -40,7 +44,7 @@ Sentry.init({
? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260" ? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260"
: undefined, : undefined,
environment: onlineEnv ? SentryEnvHostnameMap[onlineEnv] : undefined, environment: onlineEnv ? SentryEnvHostnameMap[onlineEnv] : undefined,
release: process.env.REACT_APP_GIT_SHA, release: REACT_APP_GIT_SHA,
ignoreErrors: [ ignoreErrors: [
"undefined is not an object (evaluating 'window.__pad.performLoop')", // Only happens on Safari, but spams our servers. Doesn't break anything "undefined is not an object (evaluating 'window.__pad.performLoop')", // Only happens on Safari, but spams our servers. Doesn't break anything
], ],
@ -51,6 +55,8 @@ Sentry.init({
], ],
}); });
window.__EXCALIDRAW_SHA__ = REACT_APP_GIT_SHA;
// Block pinch-zooming on iOS outside of the content area // Block pinch-zooming on iOS outside of the content area
document.addEventListener( document.addEventListener(
"touchmove", "touchmove",