Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟 🔧 Add Datadog support to webapp, cleanup sentry init #17821

Merged
merged 8 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions airbyte-webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion airbyte-webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"validate-links": "ts-node --skip-project ./scripts/validate-links.ts"
},
"dependencies": {
"@datadog/browser-rum": "^4.21.2",
"@floating-ui/react-dom": "^1.0.0",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "^6.1.1",
Expand Down Expand Up @@ -162,7 +163,9 @@
},
"jest": {
"transformIgnorePatterns": [],
"snapshotSerializers": ["./scripts/classname-serializer.js"],
"snapshotSerializers": [
"./scripts/classname-serializer.js"
],
"coveragePathIgnorePatterns": [
".stories.tsx"
]
Expand Down
4 changes: 4 additions & 0 deletions airbyte-webapp/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ declare global {
AIRBYTE_VERSION?: string;
API_URL?: string;
CLOUD?: string;
REACT_APP_DATADOG_APPLICATION_ID: string;
REACT_APP_DATADOG_CLIENT_TOKEN: string;
REACT_APP_DATADOG_SITE: string;
REACT_APP_DATADOG_SERVICE: string;
REACT_APP_SENTRY_DSN?: string;
REACT_APP_WEBAPP_TAG?: string;
REACT_APP_INTERCOM_APP_ID?: string;
Expand Down
14 changes: 5 additions & 9 deletions airbyte-webapp/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import * as Sentry from "@sentry/react";
import { Integrations } from "@sentry/tracing";
import { lazy, Suspense } from "react";
import ReactDOM from "react-dom";

import "react-reflex/styles.css";
import { isCloudApp } from "utils/app";
import { loadDatadog } from "utils/datadog";
import { loadOsano } from "utils/dataPrivacy";
import { loadSentry } from "utils/sentry";

import "./globals";

// We do not follow default config approach since we want to init sentry asap
Sentry.init({
dsn: process.env.REACT_APP_SENTRY_DSN || window.REACT_APP_SENTRY_DSN,
release: process.env.REACT_APP_WEBAPP_TAG || window.REACT_APP_WEBAPP_TAG || "dev",
integrations: [new Integrations.BrowserTracing()],
tracesSampleRate: 1.0, // may need to adjust this in the future
});
// We do not follow default config approach since we want to init sentry/datadog asap
loadSentry();
loadDatadog();

// In Cloud load the Osano script (GDPR consent tool before anything else)
if (isCloudApp()) {
Expand Down
28 changes: 28 additions & 0 deletions airbyte-webapp/src/utils/datadog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { datadogRum } from "@datadog/browser-rum";
export const loadDatadog = (): void => {
const applicationId = window.REACT_APP_DATADOG_APPLICATION_ID ?? process.env.REACT_APP_DATADOG_APPLICATION_ID;
if (!applicationId) {
return;
}

const clientToken = window.REACT_APP_DATADOG_CLIENT_TOKEN ?? process.env.REACT_APP_DATADOG_CLIENT_TOKEN;
const site = window.REACT_APP_DATADOG_SITE ?? process.env.REACT_APP_DATADOG_SITE;
const service = window.REACT_APP_DATADOG_SERVICE ?? process.env.REACT_APP_DATADOG_SERVICE;
const version = window.REACT_APP_WEBAPP_TAG ?? process.env.REACT_APP_WEBAPP_TAG ?? "dev";

datadogRum.init({
applicationId,
clientToken,
site,
service,
version,
sampleRate: 100,
sessionReplaySampleRate: 0,
trackInteractions: false,
trackResources: true,
trackLongTasks: true,
defaultPrivacyLevel: "mask-user-input",
});

datadogRum.startSessionReplayRecording();
};
19 changes: 19 additions & 0 deletions airbyte-webapp/src/utils/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as Sentry from "@sentry/react";
import { Integrations } from "@sentry/tracing";

export const loadSentry = (): void => {
const dsn = window.REACT_APP_SENTRY_DSN ?? process.env.REACT_APP_SENTRY_DSN;
if (!dsn) {
return;
}

const release = window.REACT_APP_WEBAPP_TAG ?? process.env.REACT_APP_WEBAPP_TAG ?? "dev";
const integrations = [new Integrations.BrowserTracing()];

Sentry.init({
dsn,
release,
integrations,
tracesSampleRate: 1.0,
});
};