1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-08 01:15:49 +02:00

feat: add plausible to integrations (#4647)

This commit is contained in:
Jaanus Sellin 2023-09-08 15:01:12 +03:00 committed by GitHub
parent 61174a1d9c
commit 0b5a7b7d36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 12 deletions

View File

@ -50,7 +50,6 @@ export const ConfiguredIntegrations: VFC<ConfiguredIntegrationsProps> = ({
title={providerConfig?.displayName || provider} title={providerConfig?.displayName || provider}
isEnabled={enabled} isEnabled={enabled}
description={description || ''} description={description || ''}
isConfigured
link={`/integrations/edit/${id}`} link={`/integrations/edit/${id}`}
/> />
); );

View File

@ -8,13 +8,13 @@ import { Badge } from 'component/common/Badge/Badge';
import { IntegrationCardMenu } from './IntegrationCardMenu/IntegrationCardMenu'; import { IntegrationCardMenu } from './IntegrationCardMenu/IntegrationCardMenu';
import type { AddonSchema } from 'openapi'; import type { AddonSchema } from 'openapi';
import OpenInNewIcon from '@mui/icons-material/OpenInNew'; import OpenInNewIcon from '@mui/icons-material/OpenInNew';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
interface IIntegrationCardProps { interface IIntegrationCardProps {
id?: string | number; id?: string | number;
icon?: string; icon?: string;
title: string; title: string;
description?: string; description?: string;
isConfigured?: boolean;
isEnabled?: boolean; isEnabled?: boolean;
configureActionText?: string; configureActionText?: string;
link: string; link: string;
@ -87,8 +87,18 @@ export const IntegrationCard: VFC<IIntegrationCardProps> = ({
deprecated, deprecated,
isExternal = false, isExternal = false,
}) => { }) => {
const { trackEvent } = usePlausibleTracker();
const isConfigured = addon !== undefined; const isConfigured = addon !== undefined;
const handleClick = () => {
trackEvent('open-integration', {
props: {
integrationName: title,
isConfigured: isConfigured,
},
});
};
const content = ( const content = (
<> <>
<StyledHeader> <StyledHeader>
@ -136,11 +146,20 @@ export const IntegrationCard: VFC<IIntegrationCardProps> = ({
if (isExternal) { if (isExternal) {
return ( return (
<StyledAnchor href={link} target="_blank" rel="noreferrer"> <StyledAnchor
href={link}
target="_blank"
rel="noreferrer"
onClick={handleClick}
>
{content} {content}
</StyledAnchor> </StyledAnchor>
); );
} else { } else {
return <StyledLink to={link}>{content}</StyledLink>; return (
<StyledLink to={link} onClick={handleClick}>
{content}
</StyledLink>
);
} }
}; };

View File

@ -44,7 +44,8 @@ export type CustomEvents =
| 'playground' | 'playground'
| 'feature-type-edit' | 'feature-type-edit'
| 'strategy-variants' | 'strategy-variants'
| 'search-filter-suggestions'; | 'search-filter-suggestions'
| 'open-integration';
export const usePlausibleTracker = () => { export const usePlausibleTracker = () => {
const plausible = useContext(PlausibleContext); const plausible = useContext(PlausibleContext);