浏览代码

Disable Sentry inside Docker (#1781)

vanilla_orig
Kostas Bariotis 5 年前
父节点
当前提交
8f65e37dac
没有帐户链接到提交者的电子邮件
共有 3 个文件被更改,包括 8 次插入7 次删除
  1. 1
    3
      Dockerfile
  2. 1
    0
      package.json
  3. 6
    4
      src/index.tsx

+ 1
- 3
Dockerfile 查看文件

@@ -17,12 +17,10 @@ COPY . .
17 17
 FROM node:14-alpine AS build
18 18
 
19 19
 ARG NODE_ENV=production
20
-ARG REACT_APP_INCLUDE_GTAG=false
21 20
 
22 21
 WORKDIR /opt/node_app
23 22
 COPY --from=deps /opt/node_app .
24
-RUN ls
25
-RUN npm run build:app
23
+RUN npm run build:app:docker
26 24
 
27 25
 FROM nginx:1.17-alpine
28 26
 

+ 1
- 0
package.json 查看文件

@@ -75,6 +75,7 @@
75 75
     "build": "npm run build:app && npm run build:zip",
76 76
     "build-node": "node ./scripts/build-node.js",
77 77
     "build:app": "REACT_APP_INCLUDE_GTAG=true REACT_APP_GIT_SHA=$NOW_GITHUB_COMMIT_SHA react-scripts build",
78
+    "build:app:docker": "REACT_APP_INCLUDE_GTAG=false REACT_APP_DISABLE_SENTRY=true react-scripts build",
78 79
     "build:zip": "node ./scripts/build-version.js",
79 80
     "eject": "react-scripts eject",
80 81
     "fix": "npm run fix:other && npm run fix:code",

+ 6
- 4
src/index.tsx 查看文件

@@ -27,12 +27,14 @@ const SentryEnvHostnameMap: { [key: string]: string } = {
27 27
   "now.sh": "staging",
28 28
 };
29 29
 
30
-const onlineEnv = Object.keys(SentryEnvHostnameMap).find(
31
-  (item) => window.location.hostname.indexOf(item) >= 0,
32
-);
30
+// Disable Sentry locally or inside the Docker to avoid noise/respect privacy
31
+const onlineEnv =
32
+  process.env.REACT_APP_DISABLE_SENTRY !== "true" &&
33
+  Object.keys(SentryEnvHostnameMap).find(
34
+    (item) => window.location.hostname.indexOf(item) >= 0,
35
+  );
33 36
 
34 37
 Sentry.init({
35
-  // Disable Sentry locally to avoid noise
36 38
   dsn: onlineEnv
37 39
     ? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260"
38 40
     : undefined,

正在加载...
取消
保存