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 workspaceId to intercom custom attributes #9489

Merged
merged 2 commits into from
Jan 13, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./useIntercom";
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
import { useEffect } from "react";
import { useIntercom as useIntercomProvider } from "react-use-intercom";
import {
useIntercom as useIntercomProvider,
IntercomContextValues,
} from "react-use-intercom";

import { useCurrentUser } from "packages/cloud/services/auth/AuthService";
import { useAnalytics } from "hooks/services/Analytics";

export const useIntercom = (): IntercomContextValues => {
const intercomContextValues = useIntercomProvider();

export const useIntercom = (): void => {
const user = useCurrentUser();
const { boot, shutdown } = useIntercomProvider();
const { analyticsContext } = useAnalytics();

useEffect(() => {
boot({
intercomContextValues.boot({
email: user.email,
name: user.name,
userId: user.userId,
userHash: user.intercomHash,

customAttributes: {
workspace_id: analyticsContext.workspaceId,
},
});

return () => shutdown();
return () => intercomContextValues.shutdown();
}, [user]);

useEffect(() => {
intercomContextValues.update({
customAttributes: {
workspace_id: analyticsContext.workspace_id,
},
});
}, [analyticsContext.workspace_id]);

return intercomContextValues;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { FormattedMessage } from "react-intl";
import { useIntercom } from "react-use-intercom";

import { useIntercom } from "packages/cloud/services/thirdParty/intercom";

import PageTitle from "components/PageTitle";
import { Button } from "components/base";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { FormattedMessage, FormattedNumber } from "react-intl";
import { NavLink } from "react-router-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faStar } from "@fortawesome/free-solid-svg-icons";
import { useIntercom } from "react-use-intercom";

import { useIntercom } from "packages/cloud/services/thirdParty/intercom";

import { CloudRoutes } from "packages/cloud/cloudRoutes";

Expand All @@ -26,10 +27,7 @@ import ResourcesPopup, {
Item,
} from "views/layout/SideBar/components/ResourcesPopup";
import { RoutePaths } from "pages/routes";
import {
FeatureItem,
WithFeature,
} from "../../../../../hooks/services/Feature";
import { FeatureItem, WithFeature } from "hooks/services/Feature";

const CreditsIcon = styled(FontAwesomeIcon)`
font-size: 21px;
Expand Down
11 changes: 8 additions & 3 deletions airbyte-webapp/src/services/workspaces/WorkspacesService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ export const useWorkspaceService = (): Context => {
return workspaceService;
};

export const useCurrentWorkspace = (): Workspace => {
export const useCurrentWorkspaceId = (): string => {
const { params } = useRouter<unknown, { workspaceId: string }>();
const { workspaceId } = params;

return params.workspaceId;
};

export const useCurrentWorkspace = (): Workspace => {
const workspaceId = useCurrentWorkspaceId();

return useResource(WorkspaceResource.detailShape(), {
workspaceId: workspaceId,
workspaceId,
});
};

Expand Down