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
 
10
 
11
 interface Window {
11
 interface Window {
12
   ClipboardItem: any;
12
   ClipboardItem: any;
13
+  __EXCALIDRAW_SHA__: string;
13
 }
14
 }
14
 
15
 
15
 interface Clipboard extends EventTarget {
16
 interface Clipboard extends EventTarget {

+ 9
- 3
src/index.tsx View File

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

Loading…
Cancel
Save