From 72dca9ecaeb938ee1d7337b84b2b0f49761de0f7 Mon Sep 17 00:00:00 2001
From: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Date: Thu, 21 Jan 2021 00:15:20 +0300
Subject: Adds Sentry Release Tags

Adds tags for sentry release, either containing the PR number or branch
name.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
---
 src/index.tsx | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index 871eb40..9eea4ce 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -14,6 +14,11 @@ if (process.env.NODE_ENV === "production") {
         release: `forms-frontend@${process.env.REACT_APP_SHA}`,
         environment: process.env.CONTEXT
     });
+
+    // Set tag as PR number, "main", or if unavailable, "unknown"
+    const branch = process.env.REACT_APP_BRANCH ?? "unknown";
+    const branch_name = branch.replace(RegExp("pull/|/head", "g"), "");
+    Sentry.setTag(branch_name === "main" ? "branch" : "pull_request", branch_name);
 }
 
 console.log("%c  Python Discord Forms  ", `font-size: 6em; font-family: "Hind", "Arial"; font-weight: 900; background-color: ${colors.blurple}; border-radius: 10px;`);
-- 
cgit v1.2.3

