Skip to content

Commit

Permalink
feat: add CR id to plausible events (#6035)
Browse files Browse the repository at this point in the history
Added conflict count to CR metrics and CR id.

Something to think about:
There was idea that we can aggregate this data based on CR id, but CR id
is just a number from 0 to x. So it will not be unique across instances.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.io>
  • Loading branch information
sjaanus and thomasheartman committed Jan 30, 2024
1 parent 46fb40c commit 2643ac1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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
@@ -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
@@ -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}`;
};

0 comments on commit 2643ac1

Please sign in to comment.