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

Function useLogPostCreated

packages/shared/src/hooks/post/useLogPostCreated.ts:13–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11}
12
13export const useLogPostCreated = (): ((
14 params?: LogPostCreatedParams,
15) => void) => {
16 const { logEvent } = useLogContext();
17
18 return useCallback(
19 ({
20 moderationCount,
21 postId,
22 postType,
23 sourceCount,
24 targetType,
25 }: LogPostCreatedParams = {}) => {
26 const extra = {
27 ...(postType ? { post_type: postType } : {}),
28 ...(sourceCount != null ? { source_count: sourceCount } : {}),
29 ...(moderationCount != null
30 ? { moderation_count: moderationCount }
31 : {}),
32 };
33
34 logEvent({
35 event_name: LogEvent.CreatePost,
36 target_id: postId,
37 target_type: targetType,
38 extra: Object.keys(extra).length ? JSON.stringify(extra) : undefined,
39 });
40 },
41 [logEvent],
42 );
43};

Callers 3

useMultipleSourcePostFunction · 0.90
usePostToSquadFunction · 0.90
CreatePostFunction · 0.90

Calls 2

useLogContextFunction · 0.90
logEventFunction · 0.85

Tested by

no test coverage detected