Skip to content

Commit

Permalink
feat: add posthog events for ticket activation, consume and refund
Browse files Browse the repository at this point in the history
  • Loading branch information
rosvik committed Feb 20, 2025
1 parent 89fa682 commit 3e5b1f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useAnalyticsContext} from '@atb/analytics';
import {getAxiosErrorMetadata} from '@atb/api/utils';
import {Confirm} from '@atb/assets/svg/mono-icons/actions';
import {
Expand Down Expand Up @@ -26,11 +27,13 @@ export const ActivateNowBottomSheet = ({fareContractId}: Props) => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<boolean>(false);
const {close} = useBottomSheetContext();
const analytics = useAnalyticsContext();

const onActivate = async () => {
setIsLoading(true);
try {
await activateFareContractNow(fareContractId);
analytics.logEvent('Ticketing', 'Ticket activated');
close();
} catch (e: any) {
const errorData = getAxiosErrorMetadata(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useAnalyticsContext} from '@atb/analytics';
import {getAxiosErrorMetadata} from '@atb/api/utils';
import {Confirm} from '@atb/assets/svg/mono-icons/actions';
import {
Expand Down Expand Up @@ -26,11 +27,13 @@ export const ConsumeCarnetBottomSheet = ({fareContractId}: Props) => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<boolean>(false);
const {close} = useBottomSheetContext();
const analytics = useAnalyticsContext();

const onConsume = async () => {
setIsLoading(true);
try {
await consumeCarnet(fareContractId);
analytics.logEvent('Ticketing', 'Carnet consumed');
close();
} catch (e: any) {
const errorData = getAxiosErrorMetadata(e);
Expand Down
3 changes: 3 additions & 0 deletions src/modules/fare-contracts/components/RefundBottomSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useAnalyticsContext} from '@atb/analytics';
import {getAxiosErrorMetadata} from '@atb/api/utils';
import {Confirm} from '@atb/assets/svg/mono-icons/actions';
import {
Expand Down Expand Up @@ -26,11 +27,13 @@ export const RefundBottomSheet = ({fareContractId}: Props) => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<boolean>(false);
const {close} = useBottomSheetContext();
const analytics = useAnalyticsContext();

const onRefund = async () => {
setIsLoading(true);
try {
await refundFareContract(fareContractId);
analytics.logEvent('Ticketing', 'Ticket refunded');
close();
} catch (e: any) {
const errorData = getAxiosErrorMetadata(e);
Expand Down

0 comments on commit 3e5b1f3

Please sign in to comment.