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

Function useBoostLogging

packages/shared/src/features/boost/useBoostLogging.ts:38–86  ·  view source on GitHub ↗
({
  type,
  referenceId,
  origin,
}: UseBoostLoggingProps)

Source from the content-addressed store, hash-verified

36};
37
38export const useBoostLogging = ({
39 type,
40 referenceId,
41 origin,
42}: UseBoostLoggingProps): UseBoostLogging => {
43 const { logEvent } = useLogContext();
44 const isPost = type === CampaignType.Post;
45 const targetType = isPost ? TargetType.Post : TargetType.Source;
46
47 useLogEventOnce(() => ({
48 event_name: LogEvent.OpenBoost,
49 target_type: targetType,
50 target_id: referenceId,
51 extra: JSON.stringify({ origin }),
52 }));
53
54 const logBoostEvent = useCallback<UseBoostLogging['logBoostEvent']>(
55 (eventName, { budget, duration }, extra) =>
56 logEvent({
57 event_name: eventName,
58 target_type: targetType,
59 target_id: referenceId,
60 extra: JSON.stringify({
61 origin,
62 budget,
63 duration,
64 total_cores: budget * duration,
65 ...extra,
66 }),
67 }),
68 [logEvent, origin, referenceId, targetType],
69 );
70
71 const logBuyCores = useCallback(
72 () =>
73 logEvent({
74 event_name: LogEvent.StartBuyingCredits,
75 target_type: targetType,
76 target_id: referenceId,
77 extra: JSON.stringify({
78 origin: isPost ? Origin.BoostPost : Origin.SquadBoost,
79 boost_origin: origin,
80 }),
81 }),
82 [isPost, logEvent, origin, referenceId, targetType],
83 );
84
85 return { logBoostEvent, logBuyCores };
86};

Callers 2

BoostPostModalFunction · 0.90
BoostSquadModalFunction · 0.90

Calls 3

useLogContextFunction · 0.90
useLogEventOnceFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected