UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

37 lines 1.17 kB
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) { var debouncedHandleAnalyticsEvent = useMemo(function () { return debounce(props.handleAnalyticsEvent, 500); }, [props.handleAnalyticsEvent]); useComponentRenderTracking({ onRender: function onRender(_ref) { var renderCount = _ref.renderCount, propsDifference = _ref.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; }