MCPcopy Index your code
hub / github.com/winfunc/opcode / useFeatureAdoptionTracking

Function useFeatureAdoptionTracking

src/hooks/useAnalytics.ts:475–507  ·  view source on GitHub ↗
(featureName: string)

Source from the content-addressed store, hash-verified

473
474// Hook for tracking feature adoption
475export function useFeatureAdoptionTracking(featureName: string) {
476 const startTime = useRef<number>(Date.now());
477 const usageCount = useRef<number>(0);
478 const trackEvent = useTrackEvent();
479
480 const trackUsage = useCallback(() => {
481 usageCount.current += 1;
482
483 // Track discovery on first use
484 if (usageCount.current === 1) {
485 trackEvent.featureDiscovered({
486 feature_name: featureName,
487 discovery_method: 'organic',
488 time_to_first_use_ms: Date.now() - startTime.current,
489 initial_success: true,
490 });
491 }
492
493 // Track adoption after 5 uses
494 if (usageCount.current === 5) {
495 const daysSinceFirst = (Date.now() - startTime.current) / (1000 * 60 * 60 * 24);
496 trackEvent.featureAdopted({
497 feature: featureName,
498 adoption_stage: 'adopted',
499 usage_count: usageCount.current,
500 days_since_first_use: daysSinceFirst,
501 usage_trend: 'increasing',
502 });
503 }
504 }, [featureName, trackEvent]);
505
506 return { trackUsage, usageCount: usageCount.current };
507}
508
509// Hook for tracking workflow completion
510export function useWorkflowTracking(workflowType: string) {

Callers 2

AgentExecutionFunction · 0.90
SlashCommandPickerFunction · 0.90

Calls 1

useTrackEventFunction · 0.85

Tested by

no test coverage detected