@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
36 lines • 1.09 kB
JavaScript
import { useMemo } from 'react';
import debounce from 'lodash/debounce';
import { EVENT_TYPE } from '@atlaskit/editor-common/analytics';
import { useComponentRenderTracking } from '@atlaskit/editor-common/use-component-render-tracking';
export function RenderTracking(props) {
const debouncedHandleAnalyticsEvent = useMemo(() => debounce(props.handleAnalyticsEvent, 500), [props.handleAnalyticsEvent]);
useComponentRenderTracking({
onRender: ({
renderCount,
propsDifference
}) => {
if (!renderCount) {
return;
}
debouncedHandleAnalyticsEvent({
payload: {
action: props.action,
actionSubject: props.actionSubject,
attributes: {
count: renderCount,
propsDifference: propsDifference
},
eventType: EVENT_TYPE.OPERATIONAL
}
});
},
propsDiffingOptions: {
enabled: true,
props: props.componentProps,
propsToIgnore: props.propsToIgnore,
useShallow: props.useShallow
},
zeroBasedCount: true
});
return null;
}