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

change: [M3-7731] - Tag breadcrumb label edit icon on Linode Details page for analytics #10183

Merged
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
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Add analytics event for breadcrumb label edit icon on Linode details page ([#10183](https://github.com/linode/manager/pull/10183))
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const FinalCrumb = React.memo((props: Props) => {
<StyledEditableText
data-qa-editable-text
errorText={onEditHandlers.errorText}
handleAnalyticsEvent={onEditHandlers.handleAnalyticsEvent}
labelLink={labelOptions && labelOptions.linkTo}
onCancel={onEditHandlers.onCancel}
onEdit={onEditHandlers.onEdit}
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/components/Breadcrumb/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface EditableProps {
editableTextTitle: string;
editableTextTitleSuffix?: string;
errorText?: string;
handleAnalyticsEvent?: () => void;
onCancel: () => void;
onEdit: (value: string) => Promise<any>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ const useStyles = makeStyles<void, 'editIcon' | 'icon'>()(
interface Props {
className?: string;
errorText?: string;
/**
* Send event analytics
*/
handleAnalyticsEvent?: () => void;
/**
* Optional link for the text when it is not in editing mode
*/
Expand Down Expand Up @@ -136,6 +140,7 @@ export const EditableText = (props: PassThroughProps) => {
const {
className,
errorText,
handleAnalyticsEvent,
labelLink,
onCancel,
onEdit,
Expand All @@ -158,6 +163,10 @@ export const EditableText = (props: PassThroughProps) => {
};

const openEdit = () => {
// Send analytics when pencil icon is clicked.
if (handleAnalyticsEvent) {
handleAnalyticsEvent();
}
setIsEditing(true);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
useLinodeQuery,
useLinodeUpdateMutation,
} from 'src/queries/linodes/linodes';
import { sendUpdateLinodeLabelEvent } from 'src/utilities/analytics';
import { getErrorMap } from 'src/utilities/errorUtils';

interface Props {
Expand Down Expand Up @@ -40,6 +41,7 @@ export const LinodeSettingsLabelPanel = (props: Props) => {
enqueueSnackbar(`Successfully updated Linode label to ${label}`, {
variant: 'success',
});
sendUpdateLinodeLabelEvent('Settings');
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import {
useLinodeUpdateMutation,
} from 'src/queries/linodes/linodes';
import { isFeatureEnabled } from 'src/utilities/accountCapabilities';
import { sendLinodeCreateFlowDocsClickEvent } from 'src/utilities/analytics';
import {
sendEditBreadcrumbEvent,
sendLinodeCreateFlowDocsClickEvent,
sendUpdateLinodeLabelEvent,
} from 'src/utilities/analytics';
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
import { getQueryParamsFromQueryString } from 'src/utilities/queryParams';
import { scrollErrorIntoView } from 'src/utilities/scrollErrorIntoView';
Expand Down Expand Up @@ -160,6 +164,7 @@ const LinodeDetailHeader = () => {
return updateLinodeLabel(label)
.then(() => {
resetEditableLabel();
sendUpdateLinodeLabelEvent('Breadcrumb');
})
.catch((updateError) => {
const errorReasons: string[] = [updateError.message];
Expand Down Expand Up @@ -226,6 +231,7 @@ const LinodeDetailHeader = () => {
onEditHandlers: {
editableTextTitle: linode?.label ?? '',
errorText: editableLabelError,
handleAnalyticsEvent: () => sendEditBreadcrumbEvent(),
onCancel: resetEditableLabel,
onEdit: handleLinodeLabelUpdate,
},
Expand Down
21 changes: 21 additions & 0 deletions packages/manager/src/utilities/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,24 @@ export const sendLinodeConfigurationDocsEvent = (label: string) => {
label,
});
};

// LinodeDetailHeader.tsx
export const sendEditBreadcrumbEvent = () => {
sendEvent({
action: 'Click:pencil icon',
category: 'Breadcrumb',
label: 'Edit Breadcrumb',
});
};

// LinodeDetailHeader.tsx
// LinodeSettingsLabelPanel.tsx
export const sendUpdateLinodeLabelEvent = (
label: 'Breadcrumb' | 'Settings'
) => {
sendEvent({
action: 'Click:button',
category: 'Linode Label',
label: `Update linode label from ${label}`,
});
};
Loading