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: add CR id to plausible events #6035

Merged
merged 5 commits into from
Jan 30, 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 @@ -34,7 +34,6 @@ import {
ChangeRequestRejectScheduledDialogue,
} from './ChangeRequestScheduledDialogs/changeRequestScheduledDialogs';
import { ScheduleChangeRequestDialog } from './ChangeRequestScheduledDialogs/ScheduleChangeRequestDialog';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { PlausibleChangeRequestState } from '../changeRequest.types';

const StyledAsideBox = styled(Box)(({ theme }) => ({
Expand Down Expand Up @@ -105,7 +104,6 @@ export const ChangeRequestOverview: FC = () => {
const { isChangeRequestConfiguredForReview } =
useChangeRequestsEnabled(projectId);
const scheduleChangeRequests = useUiFlag('scheduledConfigurationChanges');
const { trackEvent } = usePlausibleTracker();

if (!changeRequest) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import useAPI from '../useApi/useApi';
import { usePlausibleTracker } from '../../../usePlausibleTracker';
import { PlausibleChangeRequestState } from 'component/changeRequest/changeRequest.types';
import { getUniqueChangeRequestId } from 'utils/unique-change-request-id';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';

export interface IChangeSchema {
feature: string | null;
Expand Down Expand Up @@ -30,6 +32,7 @@ export const useChangeRequestApi = () => {
const { makeRequest, createRequest, errors, loading } = useAPI({
propagateErrors: true,
});
const { uiConfig } = useUiConfig();

const addChange = async (
project: string,
Expand Down Expand Up @@ -72,6 +75,7 @@ export const useChangeRequestApi = () => {
props: {
eventType: payload.state,
previousState,
id: getUniqueChangeRequestId(uiConfig, changeRequestId),
},
});

Expand Down
10 changes: 10 additions & 0 deletions frontend/src/utils/unique-change-request-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IUiConfig } from 'interfaces/uiConfig';

export const getUniqueChangeRequestId = (
uiConfig: Pick<IUiConfig, 'baseUriPath' | 'versionInfo'>,
changeRequestId: number,
) => {
return `${
uiConfig.baseUriPath || uiConfig.versionInfo?.instanceId
}/change-requests/${changeRequestId}?version=${uiConfig.versionInfo}`;
};
Loading