mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-01 13:47:27 +02:00
feat: add configurable event for banner goto action (#6603)
We added banner to get attention of customer, but we are not tracking its usage. Added a way to track the **goto action** button.
This commit is contained in:
parent
52363f176a
commit
ec7bb2dae3
@ -72,11 +72,17 @@ export const Banner = ({ banner, inline, maxHeight }: IBannerProps) => {
|
|||||||
icon,
|
icon,
|
||||||
link,
|
link,
|
||||||
linkText = 'More info',
|
linkText = 'More info',
|
||||||
|
linkClicked,
|
||||||
plausibleEvent,
|
plausibleEvent,
|
||||||
dialogTitle,
|
dialogTitle,
|
||||||
dialog,
|
dialog,
|
||||||
} = banner;
|
} = banner;
|
||||||
|
|
||||||
|
const openDialog = () => {
|
||||||
|
setOpen(true);
|
||||||
|
linkClicked?.();
|
||||||
|
};
|
||||||
|
|
||||||
const bannerBar = (
|
const bannerBar = (
|
||||||
<StyledBar variant={variant} inline={inline} maxHeight={maxHeight}>
|
<StyledBar variant={variant} inline={inline} maxHeight={maxHeight}>
|
||||||
<StyledIcon variant={variant}>
|
<StyledIcon variant={variant}>
|
||||||
@ -86,7 +92,7 @@ export const Banner = ({ banner, inline, maxHeight }: IBannerProps) => {
|
|||||||
<BannerButton
|
<BannerButton
|
||||||
link={link}
|
link={link}
|
||||||
plausibleEvent={plausibleEvent}
|
plausibleEvent={plausibleEvent}
|
||||||
openDialog={() => setOpen(true)}
|
openDialog={openDialog}
|
||||||
>
|
>
|
||||||
{linkText}
|
{linkText}
|
||||||
</BannerButton>
|
</BannerButton>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import { Banner } from '../Banner/Banner';
|
import { Banner } from '../Banner/Banner';
|
||||||
import type { IBanner } from 'interfaces/banner';
|
import type { IBanner } from 'interfaces/banner';
|
||||||
import { useOutdatedSdks } from 'hooks/api/getters/useOutdatedSdks/useOutdatedSdks';
|
import { useOutdatedSdks } from 'hooks/api/getters/useOutdatedSdks/useOutdatedSdks';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { styled } from '@mui/material';
|
import { styled } from '@mui/material';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
const StyledList = styled('ul')({ margin: 0 });
|
const StyledList = styled('ul')({ margin: 0 });
|
||||||
|
|
||||||
@ -13,12 +14,31 @@ export const OutdatedSdksBanner = () => {
|
|||||||
data: { sdks },
|
data: { sdks },
|
||||||
} = useOutdatedSdks();
|
} = useOutdatedSdks();
|
||||||
const flagEnabled = useUiFlag('outdatedSdksBanner');
|
const flagEnabled = useUiFlag('outdatedSdksBanner');
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
|
const applicationClickedWithVersion = (sdkVersion: string) => {
|
||||||
|
trackEvent('sdk-banner', {
|
||||||
|
props: {
|
||||||
|
eventType: `banner application clicked`,
|
||||||
|
sdkVersion: sdkVersion,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const bannerClicked = () => {
|
||||||
|
trackEvent('sdk-banner', {
|
||||||
|
props: {
|
||||||
|
eventType: 'banner clicked',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const outdatedSdksBanner: IBanner = {
|
const outdatedSdksBanner: IBanner = {
|
||||||
message: `We noticed that you're using outdated SDKs. `,
|
message: `We noticed that you're using outdated SDKs. `,
|
||||||
variant: 'warning',
|
variant: 'warning',
|
||||||
link: 'dialog',
|
link: 'dialog',
|
||||||
linkText: 'Please update those versions',
|
linkText: 'Please update those versions',
|
||||||
|
linkClicked: bannerClicked,
|
||||||
dialogTitle: 'Outdated SDKs',
|
dialogTitle: 'Outdated SDKs',
|
||||||
dialog: (
|
dialog: (
|
||||||
<>
|
<>
|
||||||
@ -27,7 +47,19 @@ export const OutdatedSdksBanner = () => {
|
|||||||
<span>{item.sdkVersion}</span>
|
<span>{item.sdkVersion}</span>
|
||||||
<StyledList>
|
<StyledList>
|
||||||
{item.applications.map((application) => (
|
{item.applications.map((application) => (
|
||||||
<li key={application}>
|
<li
|
||||||
|
key={application}
|
||||||
|
onClick={() => {
|
||||||
|
applicationClickedWithVersion(
|
||||||
|
item.sdkVersion,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
onKeyDown={() => {
|
||||||
|
applicationClickedWithVersion(
|
||||||
|
item.sdkVersion,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Link to={`/applications/${application}`}>
|
<Link to={`/applications/${application}`}>
|
||||||
{application}
|
{application}
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -58,7 +58,8 @@ export type CustomEvents =
|
|||||||
| 'feature-metrics'
|
| 'feature-metrics'
|
||||||
| 'search-bar'
|
| 'search-bar'
|
||||||
| 'sdk-reporting'
|
| 'sdk-reporting'
|
||||||
| 'insights-share';
|
| 'insights-share'
|
||||||
|
| 'sdk-banner';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
@ -8,6 +8,7 @@ export interface IBanner {
|
|||||||
sticky?: boolean;
|
sticky?: boolean;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
link?: string;
|
link?: string;
|
||||||
|
linkClicked?: () => void;
|
||||||
linkText?: string;
|
linkText?: string;
|
||||||
plausibleEvent?: string;
|
plausibleEvent?: string;
|
||||||
dialogTitle?: string;
|
dialogTitle?: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user