diff --git a/airbyte-webapp/package.json b/airbyte-webapp/package.json index 0d1af97a546ad..6363a3ea8bbb2 100644 --- a/airbyte-webapp/package.json +++ b/airbyte-webapp/package.json @@ -55,7 +55,7 @@ "framer-motion": "^6.3.11", "js-yaml": "^4.1.0", "json-schema": "^0.4.0", - "launchdarkly-js-client-sdk": "^2.22.1", + "launchdarkly-js-client-sdk": "^3.1.0", "lodash": "^4.17.21", "monaco-editor": "^0.34.1", "query-string": "^6.13.1", diff --git a/airbyte-webapp/pnpm-lock.yaml b/airbyte-webapp/pnpm-lock.yaml index da9e981fa731a..7b453dc0231a5 100644 --- a/airbyte-webapp/pnpm-lock.yaml +++ b/airbyte-webapp/pnpm-lock.yaml @@ -92,7 +92,7 @@ specifiers: jest-environment-jsdom: ^29.3.1 js-yaml: ^4.1.0 json-schema: ^0.4.0 - launchdarkly-js-client-sdk: ^2.22.1 + launchdarkly-js-client-sdk: ^3.1.0 license-checker: ^25.0.1 lint-staged: ^12.3.7 lodash: ^4.17.21 @@ -181,7 +181,7 @@ dependencies: framer-motion: 6.5.1_sfoxds7t5ydpegc3knd667wn6m js-yaml: 4.1.0 json-schema: 0.4.0 - launchdarkly-js-client-sdk: 2.24.2 + launchdarkly-js-client-sdk: 3.1.0 lodash: 4.17.21 monaco-editor: 0.34.1 query-string: 6.14.1 @@ -10692,19 +10692,19 @@ packages: language-subtag-registry: 0.3.22 dev: true - /launchdarkly-js-client-sdk/2.24.2: - resolution: {integrity: sha512-8jrLOia0vfZ4stqQRv9TjAYfRGK2JyWpLIL6PbTl99LqTtJMuYtryFUQp0b8WH1153YN+gVdoqPVI7uwbbzLLQ==} + /launchdarkly-js-client-sdk/3.1.0: + resolution: {integrity: sha512-8aM3Wp5ZAS/TCIELOYkEs4CFzih/g7sO+YCHNQ5g0k80WDMTmTcGLMLhCKmrzaQnMK21HiBwbkBpAYnyzr5yUQ==} dependencies: escape-string-regexp: 4.0.0 - launchdarkly-js-sdk-common: 3.8.2 + launchdarkly-js-sdk-common: 5.0.1 dev: false - /launchdarkly-js-sdk-common/3.8.2: - resolution: {integrity: sha512-pEqZ3FTKtYrTaPdbPntFJs87svzcezrkoRWY2GEFmyPC33txOqU788x0yby2+haC/saFPNfXpH6bbiJE/GjMSA==} + /launchdarkly-js-sdk-common/5.0.1: + resolution: {integrity: sha512-NPPU/9bT4hUCbglCCMAm9XGDWnRKs3aJ1OMhRF8g6xTUWAjOO2FieoGjwVbUVvOYKIiINVVtAWUiuVYbix1lqw==} dependencies: base64-js: 1.5.1 fast-deep-equal: 2.0.1 - uuid: 3.4.0 + uuid: 8.3.2 dev: false /lazy-universal-dotenv/4.0.0: @@ -15402,9 +15402,8 @@ packages: resolution: {integrity: sha512-dsNgbLaTrd6l3MMxTtouOCFw4CBFc/3a+GgYA2YyrJvyQ1u6q4pcu3ktLoUZ/VN/Aw9WsauazbgsgdfVWgAKQg==} dev: true - /uuid/3.4.0: - resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} - deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. + /uuid/8.3.2: + resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true dev: false diff --git a/airbyte-webapp/src/packages/cloud/cloudRoutePaths.tsx b/airbyte-webapp/src/packages/cloud/cloudRoutePaths.tsx index f2da7cded4f7f..e505b5824e048 100644 --- a/airbyte-webapp/src/packages/cloud/cloudRoutePaths.tsx +++ b/airbyte-webapp/src/packages/cloud/cloudRoutePaths.tsx @@ -3,7 +3,6 @@ export enum CloudRoutes { AuthFlow = "/auth_flow", Metrics = "metrics", - SelectWorkspace = "workspaces", Credits = "credits", // Auth routes diff --git a/airbyte-webapp/src/packages/cloud/cloudRoutes.tsx b/airbyte-webapp/src/packages/cloud/cloudRoutes.tsx index b0345c37a8d10..8546de542ed0a 100644 --- a/airbyte-webapp/src/packages/cloud/cloudRoutes.tsx +++ b/airbyte-webapp/src/packages/cloud/cloudRoutes.tsx @@ -98,7 +98,7 @@ const MainViewRoutes = () => { {[CloudRoutes.Login, CloudRoutes.Signup, CloudRoutes.FirebaseAction].map((r) => ( : } /> ))} - } /> + } /> } /> = { intercomHash: user.intercomHash, locale }; + if (workspaceId) { + custom.workspace = workspaceId; + } + return { + key: user.userId, + email: user.email, + name: user.name, + custom, + anonymous: false, + }; } const LDInitializationWrapper: React.FC> = ({ children, apiKey }) => { @@ -75,6 +86,7 @@ const LDInitializationWrapper: React.FC ldClient.current?.off("change", onFeatureFlagsChanged); }); - // Whenever the user should change (e.g. login/logout) we need to reidentify the changes with the LD client + // Whenever the user, locale or workspaceId changes, we need to re-identify with launchdarkly useEffect(() => { - ldClient.current?.identify(mapUserToLDUser(user, locale)); - }, [locale, user]); + ldClient.current?.identify(mapUserToLDUser(user, locale, workspaceId || null)); + }, [workspaceId, locale, user]); // Show the loading page while we're still waiting for the initial set of feature flags (or them to time out) if (state === "initializing") { diff --git a/airbyte-webapp/src/packages/cloud/views/DefaultView.tsx b/airbyte-webapp/src/packages/cloud/views/DefaultView.tsx index 86a5e63509e5a..e2e5cedd16d94 100644 --- a/airbyte-webapp/src/packages/cloud/views/DefaultView.tsx +++ b/airbyte-webapp/src/packages/cloud/views/DefaultView.tsx @@ -1,7 +1,6 @@ import { Navigate } from "react-router-dom"; import { RoutePaths } from "../../../pages/routePaths"; -import { CloudRoutes } from "../cloudRoutePaths"; import { useListCloudWorkspaces } from "../services/workspaces/CloudWorkspacesService"; export const DefaultView: React.FC = () => { @@ -12,9 +11,7 @@ export const DefaultView: React.FC = () => { return ( diff --git a/airbyte-webapp/src/services/workspaces/WorkspacesService.tsx b/airbyte-webapp/src/services/workspaces/WorkspacesService.tsx index 8a7010a58300b..f77be03b43dac 100644 --- a/airbyte-webapp/src/services/workspaces/WorkspacesService.tsx +++ b/airbyte-webapp/src/services/workspaces/WorkspacesService.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useContext, useMemo } from "react"; import { useMutation, useQueryClient } from "react-query"; -import { useNavigate, useParams } from "react-router-dom"; +import { useNavigate, useMatch } from "react-router-dom"; import { Workspace, WorkspaceService } from "core/domain/workspace"; import { RoutePaths } from "pages/routePaths"; @@ -76,9 +76,8 @@ function useWorkspaceApiService() { } export const useCurrentWorkspaceId = () => { - const params = useParams<{ workspaceId: string }>(); - - return params.workspaceId as string; + const match = useMatch(`/${RoutePaths.Workspaces}/:workspaceId/*`); + return match?.params.workspaceId || ""; }; export const useCurrentWorkspace = () => {