Skip to content

Commit

Permalink
feat(telemetry): add telemetry events to the glossary, domains, and m…
Browse files Browse the repository at this point in the history
…anaged ingestion pages (#6216)

Co-authored-by: John Joyce <[email protected]>
  • Loading branch information
aditya-radhakrishnan and jjoyce0510 authored Oct 18, 2022
1 parent a3db265 commit 2a501de
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
48 changes: 47 additions & 1 deletion datahub-web-react/src/app/analytics/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export enum EventType {
ActivatePolicyEvent,
ShowSimplifiedHomepageEvent,
ShowStandardHomepageEvent,
CreateGlossaryEntityEvent,
CreateDomainEvent,
CreateIngestionSourceEvent,
UpdateIngestionSourceEvent,
DeleteIngestionSourceEvent,
ExecuteIngestionSourceEvent,
}

/**
Expand Down Expand Up @@ -302,6 +308,8 @@ export interface BatchSelectUserRoleEvent extends BaseEvent {
userUrns: string[];
}

// Policy events

export interface CreatePolicyEvent extends BaseEvent {
type: EventType.CreatePolicyEvent;
}
Expand Down Expand Up @@ -329,6 +337,38 @@ export interface ShowStandardHomepageEvent extends BaseEvent {
type: EventType.ShowStandardHomepageEvent;
}

// Business glossary events

export interface CreateGlossaryEntityEvent extends BaseEvent {
type: EventType.CreateGlossaryEntityEvent;
entityType: EntityType;
parentNodeUrn?: string;
}

export interface CreateDomainEvent extends BaseEvent {
type: EventType.CreateDomainEvent;
}

export interface CreateIngestionSourceEvent extends BaseEvent {
type: EventType.CreateIngestionSourceEvent;
sourceType: string;
interval?: string;
}

export interface UpdateIngestionSourceEvent extends BaseEvent {
type: EventType.UpdateIngestionSourceEvent;
sourceType: string;
interval?: string;
}

export interface DeleteIngestionSourceEvent extends BaseEvent {
type: EventType.DeleteIngestionSourceEvent;
}

export interface ExecuteIngestionSourceEvent extends BaseEvent {
type: EventType.ExecuteIngestionSourceEvent;
}

/**
* Event consisting of a union of specific event types.
*/
Expand Down Expand Up @@ -368,4 +408,10 @@ export type Event =
| DeactivatePolicyEvent
| ActivatePolicyEvent
| ShowSimplifiedHomepageEvent
| ShowStandardHomepageEvent;
| ShowStandardHomepageEvent
| CreateGlossaryEntityEvent
| CreateDomainEvent
| CreateIngestionSourceEvent
| UpdateIngestionSourceEvent
| DeleteIngestionSourceEvent
| ExecuteIngestionSourceEvent;
8 changes: 8 additions & 0 deletions datahub-web-react/src/app/domain/CreateDomainModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { message, Button, Input, Modal, Typography, Form, Collapse, Tag } from '
import { useCreateDomainMutation } from '../../graphql/domain.generated';
import { useEnterKeyListener } from '../shared/useEnterKeyListener';
import { groupIdTextValidation } from '../shared/textUtil';
import analytics, { EventType } from '../analytics';

const SuggestedNamesGroup = styled.div`
margin-top: 12px;
Expand Down Expand Up @@ -40,6 +41,13 @@ export default function CreateDomainModal({ onClose, onCreate }: Props) {
},
},
})
.then(({ errors }) => {
if (!errors) {
analytics.event({
type: EventType.CreateDomainEvent,
});
}
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to create Domain!: \n ${e.message || ''}`, duration: 3 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EntityType } from '../../../../types.generated';
import { useEntityRegistry } from '../../../useEntityRegistry';
import NodeParentSelect from './NodeParentSelect';
import { useEntityData, useRefetch } from '../EntityContext';
import analytics, { EventType } from '../../../analytics';

const StyledItem = styled(Form.Item)`
margin-bottom: 0;
Expand Down Expand Up @@ -52,6 +53,11 @@ function CreateGlossaryEntityModal(props: Props) {
.then(() => {
message.loading({ content: 'Updating...', duration: 2 });
setTimeout(() => {
analytics.event({
type: EventType.CreateGlossaryEntityEvent,
entityType,
parentNodeUrn: selectedParentUrn || undefined,
});
message.success({
content: `Created ${entityRegistry.getEntityName(entityType)}!`,
duration: 2,
Expand Down
17 changes: 17 additions & 0 deletions datahub-web-react/src/app/ingest/source/IngestionSourceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import IngestionSourceTable from './IngestionSourceTable';
import { scrollToTop } from '../../shared/searchUtils';
import useRefreshIngestionData from './executions/useRefreshIngestionData';
import { isExecutionRequestActive } from './executions/IngestionSourceExecutionList';
import analytics, { EventType } from '../../analytics';

const SourceContainer = styled.div``;

Expand Down Expand Up @@ -141,6 +142,9 @@ export const IngestionSourceList = () => {
},
})
.then(() => {
analytics.event({
type: EventType.ExecuteIngestionSourceEvent,
});
message.success({
content: `Successfully submitted ingestion execution request!`,
duration: 3,
Expand Down Expand Up @@ -171,6 +175,11 @@ export const IngestionSourceList = () => {
// Update:
updateIngestionSource({ variables: { urn: focusSourceUrn as string, input } })
.then(() => {
analytics.event({
type: EventType.UpdateIngestionSourceEvent,
sourceType: input.type,
interval: input.schedule?.interval,
});
message.success({
content: `Successfully updated ingestion source!`,
duration: 3,
Expand All @@ -193,6 +202,11 @@ export const IngestionSourceList = () => {
message.loading({ content: 'Loading...', duration: 2 });
setTimeout(() => {
refetch();
analytics.event({
type: EventType.CreateIngestionSourceEvent,
sourceType: input.type,
interval: input.schedule?.interval,
});
message.success({
content: `Successfully created ingestion source!`,
duration: 3,
Expand Down Expand Up @@ -226,6 +240,9 @@ export const IngestionSourceList = () => {
variables: { urn },
})
.then(() => {
analytics.event({
type: EventType.DeleteIngestionSourceEvent,
});
message.success({ content: 'Removed ingestion source.', duration: 2 });
const newRemovedUrns = [...removedUrns, urn];
setRemovedUrns(newRemovedUrns);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ public class TrackingService {
private static final String DURATION_FIELD = "duration";
private static final String ROLE_URN_FIELD = "roleUrn";
private static final String POLICY_URN_FIELD = "policyUrn";
private static final String SOURCE_TYPE_FIELD = "sourceType";
private static final String INTERVAL_FIELD = "interval";

private static final Set<String> ALLOWED_EVENT_FIELDS = new HashSet<>(
ImmutableList.of(EVENT_TYPE_FIELD, SIGN_UP_TITLE_FIELD, ENTITY_TYPE_FIELD, ENTITY_TYPE_FILTER_FIELD,
PAGE_NUMBER_FIELD, PAGE_FIELD, TOTAL_FIELD, INDEX_FIELD, RESULT_TYPE_FIELD, RENDER_ID_FIELD, MODULE_ID_FIELD,
RENDER_TYPE_FIELD, SCENARIO_TYPE_FIELD, SECTION_FIELD, ACCESS_TOKEN_TYPE_FIELD, DURATION_FIELD,
ROLE_URN_FIELD, POLICY_URN_FIELD));
ROLE_URN_FIELD, POLICY_URN_FIELD, SOURCE_TYPE_FIELD, INTERVAL_FIELD));

private static final String ACTOR_URN_FIELD = "actorUrn";
private static final String ORIGIN_FIELD = "origin";
Expand All @@ -69,9 +71,10 @@ public class TrackingService {
private static final String PATH_FIELD = "path";
private static final String USER_URN_FIELD = "userUrn";
private static final String USER_URNS_FIELD = "userUrns";
private static final String PARENT_NODE_URN_FIELD = "parentNodeUrn";
private static final Set<String> ALLOWED_OBFUSCATED_EVENT_FIELDS = new HashSet<>(
ImmutableList.of(ACTOR_URN_FIELD, ORIGIN_FIELD, ENTITY_URN_FIELD, ENTITY_URNS_FIELD, GROUP_NAME_FIELD,
SECTION_FIELD, ENTITY_PAGE_FILTER_FIELD, PATH_FIELD, USER_URN_FIELD, USER_URNS_FIELD));
SECTION_FIELD, ENTITY_PAGE_FILTER_FIELD, PATH_FIELD, USER_URN_FIELD, USER_URNS_FIELD, PARENT_NODE_URN_FIELD));

private final MixpanelAPI _mixpanelAPI;
private final MessageBuilder _mixpanelMessageBuilder;
Expand Down

0 comments on commit 2a501de

Please sign in to comment.