@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
52 lines • 2.17 kB
JavaScript
import { useMemo } from 'react';
import { FabricChannel } from '@atlaskit/analytics-listeners/types';
import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../analytics';
export var useLinkOverlayAnalyticsEvents = function useLinkOverlayAnalyticsEvents() {
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
return useMemo(function () {
return {
/**
* When a user clicks go to link or configure link buttons.
*
* When a link is "wide" the overlay button is the configure button.
* When a link is "narrow" the configure button is inside the dropdown.
*
* @param linkAction 'goToLink' when somebody clicks on the Go to link button
* in the chevron menu; 'configureLink' when somebody clicks on the Configure button (whether it's the overlay or in the dropdown)
*/
fireActionClickEvent: function fireActionClickEvent(linkAction) {
createAnalyticsEvent({
action: ACTION.CLICKED,
actionSubject: ACTION_SUBJECT.BUTTON,
eventType: EVENT_TYPE.UI,
attributes: {
action: linkAction
}
}).fire(FabricChannel.media);
},
/**
* When a user clicks on the dropdown for a short link, or when a user clicks on the configure button for a wide link.
*/
fireLinkClickEvent: function fireLinkClickEvent() {
createAnalyticsEvent({
action: ACTION.CLICKED,
actionSubject: ACTION_SUBJECT.LINK,
eventType: EVENT_TYPE.UI
}).fire(FabricChannel.media);
},
fireToolbarViewEvent: function fireToolbarViewEvent() {
createAnalyticsEvent({
action: ACTION.VIEWED,
actionSubject: ACTION_SUBJECT.INLINE_DIALOG,
actionSubjectId: ACTION_SUBJECT_ID.SMART_LINK_TOOLBAR,
eventType: EVENT_TYPE.UI,
attributes: {
linkType: 'smallLink'
}
}).fire(FabricChannel.media);
}
};
}, [createAnalyticsEvent]);
};