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-8329] - Clean up Gravatar analytics events #10661

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": Removed
---

Gravatar analytics events ([#10661](https://github.com/linode/manager/pull/10661))
39 changes: 0 additions & 39 deletions packages/manager/src/components/GravatarByEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@ import Avatar from '@mui/material/Avatar';
import * as React from 'react';

import UserIcon from 'src/assets/icons/account.svg';
import { sendHasGravatarEvent } from 'src/utilities/analytics/customEventAnalytics';
import { waitForAdobeAnalyticsToBeLoaded } from 'src/utilities/analytics/utils';
import { getGravatarUrl } from 'src/utilities/gravatar';

export const DEFAULT_AVATAR_SIZE = 28;

interface Props {
/**
* Captures a "has gravatar" event when when the component is mounted
* @default false
*/
captureAnalytics?: boolean;
className?: string;
email: string;
height?: number;
Expand All @@ -22,7 +15,6 @@ interface Props {

export const GravatarByEmail = (props: Props) => {
const {
captureAnalytics,
className,
email,
height = DEFAULT_AVATAR_SIZE,
Expand All @@ -31,12 +23,6 @@ export const GravatarByEmail = (props: Props) => {

const url = getGravatarUrl(email);

React.useEffect(() => {
if (captureAnalytics) {
checkForGravatarAndSendEvent(url);
}
}, []);

return (
<Avatar
alt={`Avatar for user ${email}`}
Expand All @@ -48,28 +34,3 @@ export const GravatarByEmail = (props: Props) => {
</Avatar>
);
};

/**
* Given a Gravatar URL, this function waits for Adobe Analytics
* to load (if it is not already loaded) and captures an Analytics
* event saying whether or not the user has a Gravatar.
*
* Make sure the URL passed has `?d=404`
*/
async function checkForGravatarAndSendEvent(url: string) {
try {
await waitForAdobeAnalyticsToBeLoaded();

const response = await fetch(url);

if (response.status === 200) {
sendHasGravatarEvent(true);
}
if (response.status === 404) {
sendHasGravatarEvent(false);
}
} catch (error) {
// Analytics didn't load or the fetch to Gravatar
// failed. Event won't be logged.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import { Typography } from 'src/components/Typography';
import { RESTRICTED_FIELD_TOOLTIP } from 'src/features/Account/constants';
import { useNotificationsQuery } from 'src/queries/account/notifications';
import { useMutateProfile, useProfile } from 'src/queries/profile/profile';
import { ApplicationState } from 'src/store';
import { sendManageGravatarEvent } from 'src/utilities/analytics/customEventAnalytics';

import { TimezoneForm } from './TimezoneForm';

import type { ApplicationState } from 'src/store';

export const DisplaySettings = () => {
const theme = useTheme();
const { mutateAsync: updateProfile } = useMutateProfile();
Expand Down Expand Up @@ -111,11 +111,7 @@ export const DisplaySettings = () => {
Create, upload, and manage your globally recognized avatar from
a single place with Gravatar.
</StyledProfileCopy>
<StyledAddImageLink
external
onClick={() => sendManageGravatarEvent()}
to="https://en.gravatar.com/"
>
<StyledAddImageLink external to="https://en.gravatar.com/">
Manage photo
</StyledAddImageLink>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const UserMenu = React.memo(() => {
isProxyUser ? (
<GravatarForProxy />
) : (
<GravatarByEmail captureAnalytics email={profile?.email ?? ''} />
<GravatarByEmail email={profile?.email ?? ''} />
)
}
sx={(theme) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,24 +452,6 @@ export const sendUpdateLinodeLabelEvent = (
});
};

// GravatarByEmail.tsx
export const sendHasGravatarEvent = (hasGravatar: boolean) => {
sendEvent({
action: 'Load',
category: 'Gravatar',
label: hasGravatar ? 'Has Gravatar' : 'Does not have Gravatar',
});
};

// DisplaySettings.tsx
export const sendManageGravatarEvent = () => {
sendEvent({
action: 'Click:link',
category: 'Gravatar',
label: 'Manage photo',
});
};

// SelectLinodePanel.tsx
// LinodeSelectTable.tsx
export const sendLinodePowerOffEvent = (category: string) => {
Expand Down
Loading