Skip to content

Commit

Permalink
Add tracking to the ProfileMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Sep 30, 2021
1 parent d130536 commit 8f10bbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-items-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/circuit-ui': minor
---

Added tracking support to the ProfileMenu.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Popover, { PopoverProps } from '../../../Popover';
import { Skeleton } from '../../../Skeleton';
import { TRACKING_ELEMENTS } from '../../constants';
import { UserProps } from '../../types';
import { TrackingProps } from '../../../../hooks/useClickEvent';

const profileWrapperStyles = ({ theme }: StyleProps) => css`
height: 100%;
Expand Down Expand Up @@ -150,6 +151,10 @@ export interface ProfileMenuProps extends ProfileProps {
* a profile action.
*/
trackingLabel?: string;
/**
* Additional data that is dispatched with the tracking event.
*/
tracking?: TrackingProps;
}

export function ProfileMenu({
Expand All @@ -158,6 +163,7 @@ export function ProfileMenu({
actions,
isActive,
trackingLabel,
tracking,
}: ProfileMenuProps): JSX.Element {
const [isOpen, setOpen] = useState(false);
const offsetModifier = { name: 'offset', options: { offset: [-16, 8] } };
Expand All @@ -182,6 +188,9 @@ export function ProfileMenu({
actions={actions}
placement="bottom-end"
modifiers={[offsetModifier]}
tracking={
tracking ? { ...tracking, component: 'profile_menu' } : undefined
}
/>
</TrackingElement>
);
Expand Down

0 comments on commit 8f10bbb

Please sign in to comment.