Skip to content

Commit

Permalink
Merging in the latest
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoyce0510 committed Aug 3, 2022
1 parent 6c55151 commit f19c050
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
12 changes: 10 additions & 2 deletions datahub-web-react/src/app/analytics/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum EventType {
EntityViewEvent,
EntitySectionViewEvent,
EntityActionEvent,
BatchEntityActionEvent,
RecommendationImpressionEvent,
RecommendationClickEvent,
SearchAcrossLineageEvent,
Expand Down Expand Up @@ -156,10 +157,16 @@ export const EntityActionType = {
export interface EntityActionEvent extends BaseEvent {
type: EventType.EntityActionEvent;
actionType: string;
entityType: EntityType;
entityType?: EntityType;
entityUrn: string;
}

export interface BatchEntityActionEvent extends BaseEvent {
type: EventType.BatchEntityActionEvent;
actionType: string;
entityUrns: string[];
}

export interface RecommendationImpressionEvent extends BaseEvent {
type: EventType.RecommendationImpressionEvent;
renderId: string; // TODO : Determine whether we need a render id to join with click event.
Expand Down Expand Up @@ -221,4 +228,5 @@ export type Event =
| SearchAcrossLineageEvent
| SearchAcrossLineageResultsViewEvent
| DownloadAsCsvEvent
| RecommendationClickEvent;
| RecommendationClickEvent
| BatchEntityActionEvent;
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function GroupOwnerSideBarSection({ urn, ownership, refetch }: Pr
<EditOwnersModal
urns={[urn]}
hideOwnerType
type={EntityType.CorpGroup}
entityType={EntityType.CorpGroup}
refetch={refetch}
onCloseModal={() => {
setShowAddModal(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { SelectActionGroups } from './types';
*
* Currently, only the change tags action is implemented.
*/
const DEFAULT_ACTION_GROUPS = [SelectActionGroups.CHANGE_TAGS, SelectActionGroups.CHANGE_GLOSSARY_TERMS, SelectActionGroups.CHANGE_OWNERS];
const DEFAULT_ACTION_GROUPS = [
SelectActionGroups.CHANGE_TAGS,
SelectActionGroups.CHANGE_GLOSSARY_TERMS,
SelectActionGroups.CHANGE_OWNERS,
];

type Props = {
selectedEntities: EntityAndType[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState } from 'react';
import { EntityType } from '../../../../../../../types.generated';
import { EditOwnersModal, OperationType } from '../../../../containers/profile/sidebar/Ownership/EditOwnersModal';
import ActionDropdown from './ActionDropdown';

Expand Down Expand Up @@ -39,7 +38,6 @@ export default function OwnersDropdown({ urns, disabled = false, refetch }: Prop
{isEditModalVisible && (
<EditOwnersModal
urns={urns}
type={EntityType.Dataset} // TODO: Remove
operationType={operationType}
onCloseModal={() => {
setIsEditModalVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export enum OperationType {

type Props = {
urns: string[];
type: EntityType;
defaultOwnerType?: OwnershipType;
hideOwnerType?: boolean | undefined;
operationType?: OperationType;
onCloseModal: () => void;
refetch?: () => Promise<any>;
entityType?: EntityType; // Only used for tracking events
};

// value: {ownerUrn: string, ownerEntityType: EntityType}
Expand All @@ -51,12 +51,12 @@ type SelectedOwner = {

export const EditOwnersModal = ({
urns,
type,
hideOwnerType,
defaultOwnerType,
operationType = OperationType.ADD,
onCloseModal,
refetch,
entityType,
}: Props) => {
const entityRegistry = useEntityRegistry();
const [inputValue, setInputValue] = useState('');
Expand All @@ -82,12 +82,12 @@ export const EditOwnersModal = ({
}, [ownershipTypes]);

// Invokes the search API as the owner types
const handleSearch = (entityType: EntityType, text: string, searchQuery: any) => {
const handleSearch = (type: EntityType, text: string, searchQuery: any) => {
if (text.length > 2) {
searchQuery({
variables: {
input: {
type: entityType,
type,
query: text,
start: 0,
count: 5,
Expand Down Expand Up @@ -185,6 +185,23 @@ export const EditOwnersModal = ({
);
};

const emitAnalytics = async () => {
if (urns.length > 1) {
analytics.event({
type: EventType.BatchEntityActionEvent,
actionType: EntityActionType.UpdateOwnership,
entityUrns: urns,
});
} else {
analytics.event({
type: EventType.EntityActionEvent,
actionType: EntityActionType.UpdateOwnership,
entityType,
entityUrn: urns[0],
});
}
};

const batchAddOwners = async (inputs) => {
try {
await batchAddOwnersMutation({
Expand All @@ -196,12 +213,7 @@ export const EditOwnersModal = ({
},
});
message.success({ content: 'Owners Added', duration: 2 });
analytics.event({
type: EventType.EntityActionEvent,
actionType: EntityActionType.UpdateOwnership,
entityType: type,
entityUrn: urns[0],
});
emitAnalytics();
} catch (e: unknown) {
message.destroy();
if (e instanceof Error) {
Expand All @@ -224,12 +236,7 @@ export const EditOwnersModal = ({
},
});
message.success({ content: 'Owners Removed', duration: 2 });
analytics.event({
type: EventType.EntityActionEvent,
actionType: EntityActionType.UpdateOwnership,
entityType: type,
entityUrn: urns[0],
});
emitAnalytics();
} catch (e: unknown) {
message.destroy();
if (e instanceof Error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const SidebarOwnerSection = ({ properties }: { properties?: any }) => {
urns={[mutationUrn]}
defaultOwnerType={properties?.defaultOwnerType}
hideOwnerType={properties?.hideOwnerType || false}
type={entityType}
entityType={entityType}
refetch={refetch}
onCloseModal={() => {
setShowAddModal(false);
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/shared/TagStyleEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export default function TagStyleEntity({ urn, useGetSearchResults = useWrappedSe
setShowAddModal(false);
}}
urns={[urn]}
type={EntityType.Tag}
entityType={EntityType.Tag}
/>
)}
</div>
Expand Down

0 comments on commit f19c050

Please sign in to comment.