From 9c3b6ab5927cb34fc0ba696ff60f06fdd7ee6cef Mon Sep 17 00:00:00 2001 From: Artem Astapenko Date: Fri, 9 Jul 2021 18:39:50 +0300 Subject: [PATCH 1/3] Add openreplay --- airbyte-webapp/package-lock.json | 8 ++++++++ airbyte-webapp/package.json | 1 + .../src/components/hooks/useOpenReplay.tsx | 16 ++++++++++++++++ airbyte-webapp/src/config/index.ts | 6 ++++++ airbyte-webapp/src/pages/routes.tsx | 5 ++++- 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 airbyte-webapp/src/components/hooks/useOpenReplay.tsx diff --git a/airbyte-webapp/package-lock.json b/airbyte-webapp/package-lock.json index 9106e7bc84ff..511bb0d68c54 100644 --- a/airbyte-webapp/package-lock.json +++ b/airbyte-webapp/package-lock.json @@ -3804,6 +3804,14 @@ } } }, + "@openreplay/tracker": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@openreplay/tracker/-/tracker-3.0.5.tgz", + "integrity": "sha512-hIY7DnQmm7bCe6v+e257WD7OdNuBOWUZ15Q3yUEdyxu7xDNG7brbak9pS97qCt3VY9xGK0RvW/j3ANlRPk8aVg==", + "requires": { + "error-stack-parser": "^2.0.6" + } + }, "@papercups-io/chat-widget": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/@papercups-io/chat-widget/-/chat-widget-1.1.5.tgz", diff --git a/airbyte-webapp/package.json b/airbyte-webapp/package.json index a66bd59c9866..21f89d5ad9aa 100644 --- a/airbyte-webapp/package.json +++ b/airbyte-webapp/package.json @@ -16,6 +16,7 @@ "@fortawesome/free-solid-svg-icons": "^5.12.1", "@fortawesome/react-fontawesome": "^0.1.8", "@fullstory/browser": "^1.4.9", + "@openreplay/tracker": "^3.0.5", "@papercups-io/chat-widget": "^1.1.5", "@papercups-io/storytime": "^1.0.6", "@rest-hooks/legacy": "^2.0.5", diff --git a/airbyte-webapp/src/components/hooks/useOpenReplay.tsx b/airbyte-webapp/src/components/hooks/useOpenReplay.tsx new file mode 100644 index 000000000000..7172b308097c --- /dev/null +++ b/airbyte-webapp/src/components/hooks/useOpenReplay.tsx @@ -0,0 +1,16 @@ +import { useMemo } from "react"; +import OpenReplay from "@openreplay/tracker"; + +const useOpenReplay = (projectKey: string): OpenReplay => { + return useMemo(() => { + const tracker = new OpenReplay({ + projectKey: projectKey, + }); + + tracker.start(); + + return tracker; + }, [projectKey]); +}; + +export default useOpenReplay; diff --git a/airbyte-webapp/src/config/index.ts b/airbyte-webapp/src/config/index.ts index d2bd1f2e05d6..583004de3d5f 100644 --- a/airbyte-webapp/src/config/index.ts +++ b/airbyte-webapp/src/config/index.ts @@ -31,6 +31,9 @@ type Config = { baseUrl: string; enableStorytime: boolean; }; + openreplay: { + projectKey: string; + }; fullstory: Fullstory.SnippetOptions; apiUrl: string; healthCheckInterval: number; @@ -65,6 +68,9 @@ const config: Config = { baseUrl: "https://app.papercups.io", enableStorytime: window.PAPERCUPS_STORYTIME !== "disabled", }, + openreplay: { + projectKey: "6611843272536134", + }, fullstory: { orgId: "13AXQ4", devMode: window.FULLSTORY === "disabled", diff --git a/airbyte-webapp/src/pages/routes.tsx b/airbyte-webapp/src/pages/routes.tsx index 8e814e140410..6e92b6572561 100644 --- a/airbyte-webapp/src/pages/routes.tsx +++ b/airbyte-webapp/src/pages/routes.tsx @@ -27,6 +27,7 @@ import useWorkspace from "components/hooks/services/useWorkspaceHook"; import { AnalyticsService } from "core/analytics/AnalyticsService"; import { useNotificationService } from "components/hooks/services/Notification/NotificationService"; import { useApiHealthPoll } from "components/hooks/services/Health"; +import useOpenReplay from "../components/hooks/useOpenReplay"; export enum Routes { Preferences = "/preferences", @@ -152,15 +153,17 @@ const OnboardingsRoutes = () => { }; export const Routing: React.FC = () => { + useApiHealthPoll(config.healthCheckInterval); useSegment(config.segment.token); useFullStory(config.fullstory); - useApiHealthPoll(config.healthCheckInterval); + const tracker = useOpenReplay(config.openreplay.projectKey); const { workspace } = useWorkspace(); useEffect(() => { if (workspace) { AnalyticsService.identify(workspace.customerId); + tracker.setUserID(workspace.customerId); } }, [workspace]); From e00943d0e262fa7f71c328bb2ef39f2544d3d895 Mon Sep 17 00:00:00 2001 From: Artem Astapenko Date: Mon, 19 Jul 2021 01:52:01 +0300 Subject: [PATCH 2/3] Add env variables for openreplay --- airbyte-webapp/nginx/default.conf.template | 1 + airbyte-webapp/src/config/index.ts | 3 ++- kube/overlays/dev/.env | 1 + kube/overlays/stable/.env | 1 + kube/resources/webapp.yaml | 5 +++++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/airbyte-webapp/nginx/default.conf.template b/airbyte-webapp/nginx/default.conf.template index abac94fe7f27..604ae0058b25 100644 --- a/airbyte-webapp/nginx/default.conf.template +++ b/airbyte-webapp/nginx/default.conf.template @@ -19,6 +19,7 @@ server { window.TRACKING_STRATEGY = "$TRACKING_STRATEGY"; window.PAPERCUPS_STORYTIME = "$PAPERCUPS_STORYTIME"; window.FULLSTORY = "$FULLSTORY"; + window.OPENREPLAY = "$OPENREPLAY"; window.AIRBYTE_VERSION = "$AIRBYTE_VERSION"; window.API_URL = "$API_URL"; window.IS_DEMO = "$IS_DEMO"; diff --git a/airbyte-webapp/src/config/index.ts b/airbyte-webapp/src/config/index.ts index 583004de3d5f..10d79885f315 100644 --- a/airbyte-webapp/src/config/index.ts +++ b/airbyte-webapp/src/config/index.ts @@ -6,6 +6,7 @@ declare global { TRACKING_STRATEGY?: string; PAPERCUPS_STORYTIME?: string; FULLSTORY?: string; + OPENREPLAY?: string; AIRBYTE_VERSION?: string; API_URL?: string; IS_DEMO?: string; @@ -69,7 +70,7 @@ const config: Config = { enableStorytime: window.PAPERCUPS_STORYTIME !== "disabled", }, openreplay: { - projectKey: "6611843272536134", + projectKey: window.OPENREPLAY !== "disabled" ? "6611843272536134" : "", }, fullstory: { orgId: "13AXQ4", diff --git a/kube/overlays/dev/.env b/kube/overlays/dev/.env index a6d1de033b94..3006b1fa14f8 100644 --- a/kube/overlays/dev/.env +++ b/kube/overlays/dev/.env @@ -33,6 +33,7 @@ INTERNAL_API_HOST=airbyte-server-svc:8001 WORKER_ENVIRONMENT=kubernetes PAPERCUPS_STORYTIME=disabled FULLSTORY=disabled +OPENREPLAY=disabled IS_DEMO=false LOG_LEVEL=INFO diff --git a/kube/overlays/stable/.env b/kube/overlays/stable/.env index 82ccd06223fc..16ef9651a0ad 100644 --- a/kube/overlays/stable/.env +++ b/kube/overlays/stable/.env @@ -33,6 +33,7 @@ INTERNAL_API_HOST=airbyte-server-svc:8001 WORKER_ENVIRONMENT=kubernetes PAPERCUPS_STORYTIME=enabled FULLSTORY=enabled +OPENREPLAY=enabled IS_DEMO=false LOG_LEVEL=INFO diff --git a/kube/resources/webapp.yaml b/kube/resources/webapp.yaml index 9f973ea5f5e4..ca4487b6e1fe 100644 --- a/kube/resources/webapp.yaml +++ b/kube/resources/webapp.yaml @@ -53,6 +53,11 @@ spec: configMapKeyRef: name: airbyte-env key: FULLSTORY + - name: OPENREPLAY + valueFrom: + configMapKeyRef: + name: airbyte-env + key: OPENREPLAY - name: IS_DEMO valueFrom: configMapKeyRef: From 00398b477640b62ec4437447f381069f082ca8f8 Mon Sep 17 00:00:00 2001 From: Artem Astapenko Date: Mon, 19 Jul 2021 12:27:48 +0300 Subject: [PATCH 3/3] Add openreplay env for k8s --- kube/overlays/stable-with-resource-limits/.env | 1 + 1 file changed, 1 insertion(+) diff --git a/kube/overlays/stable-with-resource-limits/.env b/kube/overlays/stable-with-resource-limits/.env index b410fa8fbdce..41fe0deabe64 100644 --- a/kube/overlays/stable-with-resource-limits/.env +++ b/kube/overlays/stable-with-resource-limits/.env @@ -33,6 +33,7 @@ INTERNAL_API_HOST=airbyte-server-svc:8001 WORKER_ENVIRONMENT=kubernetes PAPERCUPS_STORYTIME=enabled FULLSTORY=enabled +OPENREPLAY=enabled IS_DEMO=false LOG_LEVEL=INFO