Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: order environment plausible events #8427

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import FormTemplate from 'component/common/FormTemplate/FormTemplate';
import { OrderEnvironmentsDialogPricing } from './OrderEnvironmentsDialogPricing/OrderEnvironmentsDialogPricing';
import GeneralSelect from 'component/common/GeneralSelect/GeneralSelect';
import Input from 'component/common/Input/Input';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';

type OrderEnvironmentsDialogProps = {
open: boolean;
Expand Down Expand Up @@ -75,10 +76,19 @@ export const OrderEnvironmentsDialog: FC<OrderEnvironmentsDialogProps> = ({
onClose,
onSubmit,
}) => {
const { trackEvent } = usePlausibleTracker();
const [selectedOption, setSelectedOption] = useState(OPTIONS[0]);
const [costCheckboxChecked, setCostCheckboxChecked] = useState(false);
const [environmentNames, setEnvironmentNames] = useState<string[]>([]);

const trackEnvironmentSelect = () => {
trackEvent('order-environments', {
props: {
eventType: 'selected environment count',
},
});
};

return (
<StyledDialog open={open} title=''>
<FormTemplate
Expand Down Expand Up @@ -135,6 +145,7 @@ export const OrderEnvironmentsDialog: FC<OrderEnvironmentsDialogProps> = ({
setEnvironmentNames((names) =>
names.slice(0, value),
);
trackEnvironmentSelect();
}}
/>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Box, Button, styled, Typography } from '@mui/material';
import { ThemeMode } from 'component/common/ThemeMode/ThemeMode';
import { ReactComponent as ProPlanIcon } from 'assets/icons/pro-enterprise-feature-badge.svg';
import { ReactComponent as ProPlanIconLight } from 'assets/icons/pro-enterprise-feature-badge-light.svg';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';

type PurchasableFeatureProps = {
title: ReactNode;
Expand Down Expand Up @@ -50,6 +51,17 @@ export const PurchasableFeature: FC<PurchasableFeatureProps> = ({
description,
onClick,
}) => {
const { trackEvent } = usePlausibleTracker();

const onViewPricingClick = () => {
onClick();
trackEvent('order-environments', {
props: {
eventType: 'view pricing clicked',
},
});
};

return (
<StyledContainer>
<StyledMessage>
Expand All @@ -62,7 +74,7 @@ export const PurchasableFeature: FC<PurchasableFeatureProps> = ({
</Box>
</StyledMessage>
<StyledButtonContainer>
<Button variant='contained' onClick={onClick}>
<Button variant='contained' onClick={onViewPricingClick}>
View pricing
</Button>
</StyledButtonContainer>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/hooks/usePlausibleTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export type CustomEvents =
| 'events-exported'
| 'event-timeline'
| 'onboarding'
| 'personal-dashboard';
| 'personal-dashboard'
| 'order-environments';

export const usePlausibleTracker = () => {
const plausible = useContext(PlausibleContext);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/services/email-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,9 @@ export class EmailService {
const email = {
from: this.sender,
to: userEmail,
bcc: process.env.ORDER_ENVIRONMENTS_BCC || '[email protected]',
bcc:
process.env.ORDER_ENVIRONMENTS_BCC ||
'[email protected]',
subject: ORDER_ENVIRONMENTS_SUBJECT,
html: bodyHtml,
text: bodyText,
Expand Down
Loading