MCPcopy Create free account
hub / github.com/dailydotdev/apps / useLogEventOnce

Function useLogEventOnce

packages/shared/src/hooks/log/useLogEventOnce.ts:40–58  ·  view source on GitHub ↗
(
  getEvent: () => LogEvent,
  options?: UseLogEventOnceOptions,
)

Source from the content-addressed store, hash-verified

38 * );
39 */
40const useLogEventOnce = (
41 getEvent: () => LogEvent,
42 options?: UseLogEventOnceOptions,
43): void => {
44 const { logEvent } = useLogContext();
45 const hasLoggedRef = useRef(false);
46 const getEventRef = useRef(getEvent);
47
48 getEventRef.current = getEvent;
49
50 const { condition = true } = options ?? {};
51
52 useEffect(() => {
53 if (condition && !hasLoggedRef.current) {
54 hasLoggedRef.current = true;
55 logEvent(getEventRef.current());
56 }
57 }, [condition, logEvent]);
58};
59
60export default useLogEventOnce;

Callers 11

PromotionalBannerFunction · 0.85
LiveRoomInnerFunction · 0.85
LiveStandupsStripFunction · 0.85
ReadingReminderHeroFunction · 0.85
SpotlightHostFunction · 0.85
CompanionDemoWidgetFunction · 0.85
PostOnboardingActivationFunction · 0.85
useUserExperienceFormFunction · 0.85

Calls 2

useLogContextFunction · 0.90
logEventFunction · 0.85

Tested by

no test coverage detected