Browse Source

Expose Git SHA to window (#1847)

* expose git sha

* move to global.d.ts

* fix vercel domain
vanilla_orig
Kostas Bariotis 4 years ago
parent
commit
2a25480272
No account linked to committer's email address
2 changed files with 10 additions and 3 deletions
  1. 1
    0
      src/global.d.ts
  2. 9
    3
      src/index.tsx

+ 1
- 0
src/global.d.ts View File

@@ -10,6 +10,7 @@ interface Document {
10 10
 
11 11
 interface Window {
12 12
   ClipboardItem: any;
13
+  __EXCALIDRAW_SHA__: string;
13 14
 }
14 15
 
15 16
 interface Clipboard extends EventTarget {

+ 9
- 3
src/index.tsx View File

@@ -25,12 +25,16 @@ if (
25 25
 
26 26
 const SentryEnvHostnameMap: { [key: string]: string } = {
27 27
   "excalidraw.com": "production",
28
-  "now.sh": "staging",
28
+  "vercel.app": "staging",
29 29
 };
30 30
 
31
+const REACT_APP_DISABLE_SENTRY =
32
+  process.env.REACT_APP_DISABLE_SENTRY === "true";
33
+const REACT_APP_GIT_SHA = process.env.REACT_APP_GIT_SHA as string;
34
+
31 35
 // Disable Sentry locally or inside the Docker to avoid noise/respect privacy
32 36
 const onlineEnv =
33
-  process.env.REACT_APP_DISABLE_SENTRY !== "true" &&
37
+  !REACT_APP_DISABLE_SENTRY &&
34 38
   Object.keys(SentryEnvHostnameMap).find(
35 39
     (item) => window.location.hostname.indexOf(item) >= 0,
36 40
   );
@@ -40,7 +44,7 @@ Sentry.init({
40 44
     ? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260"
41 45
     : undefined,
42 46
   environment: onlineEnv ? SentryEnvHostnameMap[onlineEnv] : undefined,
43
-  release: process.env.REACT_APP_GIT_SHA,
47
+  release: REACT_APP_GIT_SHA,
44 48
   ignoreErrors: [
45 49
     "undefined is not an object (evaluating 'window.__pad.performLoop')", // Only happens on Safari, but spams our servers. Doesn't break anything
46 50
   ],
@@ -51,6 +55,8 @@ Sentry.init({
51 55
   ],
52 56
 });
53 57
 
58
+window.__EXCALIDRAW_SHA__ = REACT_APP_GIT_SHA;
59
+
54 60
 // Block pinch-zooming on iOS outside of the content area
55 61
 document.addEventListener(
56 62
   "touchmove",

Loading…
Cancel
Save