Skip to content

Commit

Permalink
Merge pull request #91 from atlassian-labs/app-configured-analytic
Browse files Browse the repository at this point in the history
App Configured Analytic
  • Loading branch information
gtchuinkam authored Jan 17, 2024
2 parents d6312df + 1dc34f9 commit 8e97578
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ui/src/components/AuthPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import { gridSize } from '@atlaskit/theme';
import WatchIcon from '@atlaskit/icon/glyph/watch';
import WatchFilledIcon from '@atlaskit/icon/glyph/watch-filled';

import { getCallBridge } from '@forge/bridge/out/bridge';
import { ApplicationState } from '../../routes';
import { ForgeLink } from '../ForgeLink';
import { connectGroup } from '../../services/invokes';
import { ErrorMessages } from '../../errorMessages';
import { AuthErrorTypes, ErrorTypes } from '../../resolverTypes';
import { useAppContext } from '../../hooks/useAppContext';

const SectionMessageWrapper = styled.div`
margin-bottom: ${gridSize() * 2}px;
Expand Down Expand Up @@ -97,9 +99,19 @@ export const AuthPage = () => {
const [isLoadingSubmit, setLoadingSubmit] = useState<boolean>(false);
const [errorType, setErrorType] = useState<ErrorTypes | null>(null);
const [isTokenVisible, setIsTokenVisible] = useState<boolean>(false);
const { appId } = useAppContext();

const navigate = useNavigate();

const fireAppConfiguredAnalytic = async () => {
const action = 'configured';
const actionSubject = 'compassApp';
await getCallBridge()('fireForgeAnalytic', {
forgeAppId: appId,
analyticEvent: `${actionSubject} ${action}`,
});
};

const handleNavigateToConnectedPage = () => {
navigate(`..${ApplicationState.CONNECTED}`, { replace: true });
};
Expand All @@ -111,6 +123,7 @@ export const AuthPage = () => {
const { success, errors } = await connectGroup(token.trim(), tokenName);

if (success) {
await fireAppConfiguredAnalytic();
handleNavigateToConnectedPage();
} else {
setErrorType((errors && errors[0].errorType) || AuthErrorTypes.UNEXPECTED_ERROR);
Expand Down

0 comments on commit 8e97578

Please sign in to comment.