feat(tracking) Add tracking events to our chrome extension page (#7967)

This commit is contained in:
Chris Collins 2023-05-04 17:52:07 -04:00 committed by GitHub
parent 8019d17aa6
commit abeda11ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 3 deletions

View File

@ -64,6 +64,8 @@ export enum EventType {
SelectAutoCompleteOption,
SelectQuickFilterEvent,
DeselectQuickFilterEvent,
EmbedProfileViewEvent,
EmbedProfileViewInDataHubEvent,
}
/**
@ -495,6 +497,18 @@ export interface DeselectQuickFilterEvent extends BaseEvent {
quickFilterValue: string;
}
export interface EmbedProfileViewEvent extends BaseEvent {
type: EventType.EmbedProfileViewEvent;
entityType: string;
entityUrn: string;
}
export interface EmbedProfileViewInDataHubEvent extends BaseEvent {
type: EventType.EmbedProfileViewInDataHubEvent;
entityType: string;
entityUrn: string;
}
/**
* Event consisting of a union of specific event types.
*/
@ -557,4 +571,6 @@ export type Event =
| DeleteQueryEvent
| SelectAutoCompleteOption
| SelectQuickFilterEvent
| DeselectQuickFilterEvent;
| DeselectQuickFilterEvent
| EmbedProfileViewEvent
| EmbedProfileViewInDataHubEvent;

View File

@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { useParams } from 'react-router';
import styled from 'styled-components/macro';
import { useGetGrantedPrivilegesQuery } from '../../graphql/policy.generated';
@ -9,6 +9,8 @@ import { decodeUrn } from '../entity/shared/utils';
import CompactContext from '../shared/CompactContext';
import { useEntityRegistry } from '../useEntityRegistry';
import { useGetAuthenticatedUserUrn } from '../useGetAuthenticatedUser';
import analytics from '../analytics/analytics';
import { EventType } from '../analytics';
const EmbeddedPageWrapper = styled.div`
max-height: 100%;
@ -29,6 +31,14 @@ export default function EmbeddedPage({ entityType }: Props) {
const { urn: encodedUrn } = useParams<RouteParams>();
const urn = decodeUrn(encodedUrn);
useEffect(() => {
analytics.event({
type: EventType.EmbedProfileViewEvent,
entityType,
entityUrn: urn,
});
}, [entityType, urn]);
const authenticatedUserUrn = useGetAuthenticatedUserUrn();
const { data } = useGetGrantedPrivilegesQuery({
variables: {

View File

@ -10,6 +10,8 @@ import { IconStyleType } from '../../Entity';
import { useEntityData } from '../EntityContext';
import { getDisplayedEntityType } from '../containers/profile/header/PlatformContent/PlatformContentContainer';
import { ANTD_GRAY } from '../constants';
import analytics from '../../../analytics/analytics';
import { EventType } from '../../../analytics';
const HeaderWrapper = styled.div`
display: flex;
@ -61,6 +63,14 @@ export default function EmbeddedHeader() {
const appConfig = useAppConfig();
const themeConfig = useTheme();
function trackClickViewInDataHub() {
analytics.event({
type: EventType.EmbedProfileViewInDataHubEvent,
entityType,
entityUrn: entityData?.urn || '',
});
}
const typeIcon = entityRegistry.getIcon(entityType, 12, IconStyleType.ACCENT, ANTD_GRAY[8]);
const displayedEntityType = getDisplayedEntityType(entityData, entityRegistry, entityType);
const entityName = entityRegistry.getDisplayName(entityType, entityData);
@ -86,6 +96,7 @@ export default function EmbeddedHeader() {
href={`${window.location.origin}/${entityTypePathName}/${entityData?.urn}`}
target="_blank"
rel="noreferrer noopener"
onClick={trackClickViewInDataHub}
>
view in DataHub <ArrowRightOutlined />
</StyledLink>

View File

@ -63,7 +63,9 @@ public enum DataHubUsageEventType {
UPDATE_QUERY_EVENT("UpdateQueryEvent"),
SELECT_AUTO_COMPLETE_OPTION("SelectAutoCompleteOption"),
SELECT_QUICK_FILTER_EVENT("SelectQuickFilterEvent"),
DESELECT_QUICK_FILTER_EVENT("DeselectQuickFilterEvent");
DESELECT_QUICK_FILTER_EVENT("DeselectQuickFilterEvent"),
EMBED_PROFILE_VIEW_EVENT("EmbedProfileViewEvent"),
EMBED_PROFILE_VIEW_IN_DATAHUB_EVENT("EmbedProfileViewInDataHubEvent");
private final String type;