()
| 11 | } |
| 12 | |
| 13 | export 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 | }; |
no test coverage detected