Skip to content
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
8 changes: 7 additions & 1 deletion src/components/Main/Authentication/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { forwardRef, useState } from "react";
import { forwardRef, useEffect, useState } from "react";
import { SLACK_WORKSPACE_URL } from "../../../constants";
import { openURLInDefaultBrowser } from "../../../utils/actions/openURLInDefaultBrowser";
import { sendTrackingEvent } from "../../../utils/actions/sendTrackingEvent";
import { SlackLogoIcon } from "../../common/icons/16px/SlackLogoIcon";
import { DigmaLoginLogo } from "../../common/icons/DigmaLoginLogo";
import { Toggle } from "../../common/v3/Toggle";
import { trackingEvents } from "../tracking";
import { Login } from "./Login";
import { Registration } from "./Registration";
import * as s from "./styles";
Expand All @@ -30,6 +32,10 @@ const AuthenticationComponent = () => {
setLoginSuccessMessage("");
};

useEffect(() => {
sendTrackingEvent(trackingEvents.LOGIN_SCREEN_VIEWED);
}, []);

return (
<s.Container>
<s.ContentContainer>
Expand Down
17 changes: 15 additions & 2 deletions src/components/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { history } from "../../containers/Main/history";
import { useGlobalStore } from "../../containers/Main/stores/useGlobalStore";
import { dispatcher } from "../../dispatcher";
import { HistoryEntryLocation } from "../../history/History";
import { usePrevious } from "../../hooks/usePrevious";
import { logger } from "../../logging";
import { trackingEvents as globalTrackingEvents } from "../../trackingEvents";
import { sendTrackingEvent } from "../../utils/actions/sendTrackingEvent";
import { Navigation } from "../Navigation";
import { TAB_IDS } from "../Navigation/Tabs/types";
import { Scope } from "../common/App/types";
Expand Down Expand Up @@ -44,6 +47,8 @@ export const Main = () => {
const environment = useGlobalStore.use.environment();
const scope = useGlobalStore.use.scope();
const userInfo = useGlobalStore.use.userInfo();
const userId = userInfo?.id;
const previousUserId = usePrevious(userId);
const backendInfo = useGlobalStore.use.backendInfo();
const { goTo } = useHistory();
const updateBrowserLocation = useBrowserLocationUpdater();
Expand Down Expand Up @@ -159,9 +164,17 @@ export const Main = () => {
window.sendMessageToDigma({
action: actions.INITIALIZE
});
}, [userInfo?.id]);
}, [userId]);

if (!userInfo?.id && backendInfo?.centralize) {
useEffect(() => {
if (previousUserId !== userId) {
sendTrackingEvent(globalTrackingEvents.USER_ID_CHANGED, {
userId
});
}
}, [previousUserId, userId]);

if (!userId && backendInfo?.centralize) {
return <Authentication />;
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/Main/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const trackingEvents = addPrefix(
PROMOTION_REGISTRATION_CLOSED_CLICKED:
"promotion registration close button clicked",
PROMOTION_DISCARDED: "promotion discarded",
PROMOTION_REGISTRATION_OPENED: "promotion registration form opened"
PROMOTION_REGISTRATION_OPENED: "promotion registration form opened",
LOGIN_SCREEN_VIEWED: "login screen viewed"
},
" "
);
3 changes: 2 additions & 1 deletion src/trackingEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export const trackingEvents = {
ERROR_SCREEN_REFRESH_BUTTON_CLICKED: "error screen refresh button clicked",
PAGINATION_BUTTON_CLICKED: "pagination button clicked",
CAROUSEL_NAVIGATION_BUTTON_CLICKED: "carousel navigation button clicked",
CAROUSEL_PAGE_BUTTON_CLICKED: "carousel page button clicked"
CAROUSEL_PAGE_BUTTON_CLICKED: "carousel page button clicked",
USER_ID_CHANGED: "user id changed"
};