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}
isEnabled={enabled}
description={description || ''}
isConfigured
link={`/integrations/edit/${id}`}
/>
);

View File

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