featuredrop 2.7.2 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +32 -1
  2. package/dist/astro.cjs +333 -0
  3. package/dist/astro.cjs.map +1 -0
  4. package/dist/astro.d.cts +242 -0
  5. package/dist/astro.d.ts +242 -0
  6. package/dist/astro.js +329 -0
  7. package/dist/astro.js.map +1 -0
  8. package/dist/engine.cjs +552 -0
  9. package/dist/engine.cjs.map +1 -0
  10. package/dist/engine.d.cts +422 -0
  11. package/dist/engine.d.ts +422 -0
  12. package/dist/engine.js +545 -0
  13. package/dist/engine.js.map +1 -0
  14. package/dist/featuredrop.cjs +208 -1
  15. package/dist/featuredrop.cjs.map +1 -1
  16. package/dist/next.cjs +336 -0
  17. package/dist/next.cjs.map +1 -0
  18. package/dist/next.d.cts +243 -0
  19. package/dist/next.d.ts +243 -0
  20. package/dist/next.js +332 -0
  21. package/dist/next.js.map +1 -0
  22. package/dist/nuxt.cjs +352 -0
  23. package/dist/nuxt.cjs.map +1 -0
  24. package/dist/nuxt.d.cts +282 -0
  25. package/dist/nuxt.d.ts +282 -0
  26. package/dist/nuxt.js +347 -0
  27. package/dist/nuxt.js.map +1 -0
  28. package/dist/preact.cjs +354 -0
  29. package/dist/preact.cjs.map +1 -1
  30. package/dist/preact.d.cts +170 -1
  31. package/dist/preact.d.ts +170 -1
  32. package/dist/preact.js +350 -1
  33. package/dist/preact.js.map +1 -1
  34. package/dist/react-hooks.cjs +82 -0
  35. package/dist/react-hooks.cjs.map +1 -1
  36. package/dist/react-hooks.d.cts +117 -1
  37. package/dist/react-hooks.d.ts +117 -1
  38. package/dist/react-hooks.js +80 -1
  39. package/dist/react-hooks.js.map +1 -1
  40. package/dist/react.cjs +354 -0
  41. package/dist/react.cjs.map +1 -1
  42. package/dist/react.d.cts +170 -1
  43. package/dist/react.d.ts +170 -1
  44. package/dist/react.js +350 -1
  45. package/dist/react.js.map +1 -1
  46. package/dist/remix.cjs +331 -0
  47. package/dist/remix.cjs.map +1 -0
  48. package/dist/remix.d.cts +305 -0
  49. package/dist/remix.d.ts +305 -0
  50. package/dist/remix.js +327 -0
  51. package/dist/remix.js.map +1 -0
  52. package/package.json +70 -2
@@ -457,13 +457,95 @@ function useChangelog() {
457
457
  [ctx.manifest, ctx.newFeatures, ctx.newCount, ctx.newFeaturesSorted, ctx.dismiss, ctx.dismissAll, ctx.isNew, markAllSeen, getByCategory]
458
458
  );
459
459
  }
460
+ function useSmartFeature(featureId) {
461
+ const { engine, manifest, dismiss: providerDismiss } = useFeatureDrop();
462
+ const sessionStartRef = react.useRef(Date.now());
463
+ const feature = manifest.find((f) => f.id === featureId);
464
+ const dismiss = react.useCallback(() => {
465
+ engine?.trackInteraction(featureId, "dismissed");
466
+ providerDismiss(featureId);
467
+ }, [engine, featureId, providerDismiss]);
468
+ if (!engine) {
469
+ return {
470
+ show: !!feature,
471
+ format: "badge",
472
+ fallbackFormat: "inline",
473
+ feature,
474
+ dismiss,
475
+ confidence: 1,
476
+ reason: "no_engine"
477
+ };
478
+ }
479
+ const currentPath = typeof window !== "undefined" ? window.location.pathname : "/";
480
+ const sessionAge = (Date.now() - sessionStartRef.current) / 1e3;
481
+ const timing = engine.shouldShow(featureId, {
482
+ currentPath,
483
+ sessionAge,
484
+ recentDismissals: 0,
485
+ featurePriority: feature?.priority ?? "normal"
486
+ });
487
+ const formatRec = engine.recommendFormat(featureId);
488
+ return {
489
+ show: timing.show,
490
+ format: formatRec.primary,
491
+ fallbackFormat: formatRec.fallback,
492
+ feature,
493
+ dismiss,
494
+ confidence: timing.confidence,
495
+ reason: timing.reason
496
+ };
497
+ }
498
+ var DEFAULT_SCORE = {
499
+ score: 100,
500
+ grade: "A",
501
+ breakdown: {
502
+ featuresExplored: 0,
503
+ dismissRate: 0,
504
+ completionRate: 0,
505
+ engagementTrend: "stable"
506
+ },
507
+ recommendations: []
508
+ };
509
+ function useAdoptionScore() {
510
+ const { engine } = useFeatureDrop();
511
+ return react.useMemo(() => {
512
+ if (!engine) return DEFAULT_SCORE;
513
+ return engine.getAdoptionScore();
514
+ }, [engine]);
515
+ }
516
+ var DEFAULT_PROFILE = {
517
+ sessionCount: 0,
518
+ dismissRate: 0,
519
+ engagementRate: 0,
520
+ preferredFormat: "badge",
521
+ hasEngine: false
522
+ };
523
+ function useBehaviorProfile() {
524
+ const { engine } = useFeatureDrop();
525
+ return react.useMemo(() => {
526
+ if (!engine) return DEFAULT_PROFILE;
527
+ const score = engine.getAdoptionScore();
528
+ return {
529
+ sessionCount: 0,
530
+ // Not directly exposed by FeatureDropEngine interface
531
+ dismissRate: score.breakdown.dismissRate,
532
+ engagementRate: 1 - score.breakdown.dismissRate,
533
+ preferredFormat: "badge",
534
+ // Default — full profile requires AdoptionEngine
535
+ hasEngine: true
536
+ };
537
+ }, [engine]);
538
+ }
460
539
 
461
540
  exports.useAdoptionAnalytics = useAdoptionAnalytics;
541
+ exports.useAdoptionScore = useAdoptionScore;
542
+ exports.useBehaviorProfile = useBehaviorProfile;
462
543
  exports.useChangelog = useChangelog;
463
544
  exports.useChecklist = useChecklist;
464
545
  exports.useFeatureDrop = useFeatureDrop;
465
546
  exports.useNewCount = useNewCount;
466
547
  exports.useNewFeature = useNewFeature;
548
+ exports.useSmartFeature = useSmartFeature;
467
549
  exports.useSurvey = useSurvey;
468
550
  exports.useTabNotification = useTabNotification;
469
551
  exports.useTour = useTour;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/react/context.ts","../src/react/hooks/use-feature-drop.ts","../src/react/hooks/use-new-feature.ts","../src/react/hooks/use-new-count.ts","../src/react/hooks/use-tab-notification.ts","../src/analytics.ts","../src/react/hooks/use-adoption-analytics.ts","../src/react/tour-registry.ts","../src/react/hooks/use-tour.ts","../src/react/hooks/use-tour-sequencer.ts","../src/react/checklist-registry.ts","../src/react/hooks/use-checklist.ts","../src/react/survey-registry.ts","../src/react/hooks/use-survey.ts","../src/react/hooks/use-changelog.ts"],"names":["createContext","useContext","useRef","useEffect","useMemo","useState","useCallback","controllers","registryListeners","EMPTY_SNAPSHOT","readSnapshot"],"mappings":";;;;;AA8EO,IAAM,kBAAA,GAAqBA,mBAAA;AAAA,EAChC;AACF,CAAA;;;ACrEO,SAAS,cAAA,GAA0C;AACxD,EAAA,MAAM,OAAA,GAAUC,iBAAW,kBAAkB,CAAA;AAC7C,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;ACDO,SAAS,cAAc,UAAA,EAAyC;AACrE,EAAA,MAAM,EAAE,KAAA,EAAO,UAAA,EAAY,OAAA,KAAY,cAAA,EAAe;AAEtD,EAAA,MAAM,OAAA,GAAU,WAAW,UAAU,CAAA;AACrC,EAAA,MAAM,UAAA,GAAa,MAAM,UAAU,CAAA;AAEnC,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,UAAA;AAAA,IACP,OAAA;AAAA,IACA,SAAS,MAAM;AACb,MAAA,IAAI,OAAA,EAAS;AACX,QAAA,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAAA,MACpB;AAAA,IACF;AAAA,GACF;AACF;;;ACxBO,SAAS,WAAA,GAAsB;AACpC,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,cAAA,EAAe;AACpC,EAAA,OAAO,QAAA;AACT;ACqBO,SAAS,kBAAA,CAAmB,OAAA,GAAqC,EAAC,EAAS;AAChF,EAAA,MAAM;AAAA,IACJ,OAAA,GAAU,IAAA;AAAA,IACV,QAAA,GAAW,mBAAA;AAAA,IACX,KAAA,GAAQ,KAAA;AAAA,IACR,aAAA,GAAgB;AAAA,GAClB,GAAI,OAAA;AAEJ,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,cAAA,EAAe;AACpC,EAAA,MAAM,gBAAA,GAAmBC,aAAe,EAAE,CAAA;AAC1C,EAAA,MAAM,WAAA,G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UAAA,EAAW;AAAA,EACtB,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AAER,EAAA,MAAM,aAAA,GAAgBA,iBAAAA;AAAA,IACpB,CAAC,QAAA,KAA8C;AAC7C,MAAA,OAAO,IAAI,WAAA,CAAY,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,QAAQ,CAAA;AAAA,IAC9D,CAAA;AAAA,IACA,CAAC,IAAI,WAAW;AAAA,GAClB;AAEA,EAAA,OAAOF,aAAAA;AAAA,IACL,OAAO;AAAA,MACL,UAAU,GAAA,CAAI,QAAA;AAAA,MACd,aAAa,GAAA,CAAI,WAAA;AAAA,MACjB,UAAU,GAAA,CAAI,QAAA;AAAA,MACd,mBAAmB,GAAA,CAAI,iBAAA;AAAA,MACvB,SAAS,GAAA,CAAI,OAAA;AAAA,MACb,UAAA,EAAY,MAAM,KAAK,GAAA,CAAI,UAAA,EAAW;AAAA,MACtC,OAAO,GAAA,CAAI,KAAA;AAAA,MACX,WAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,GAAA,CAAI,QAAA,EAAU,GAAA,CAAI,WAAA,EAAa,IAAI,QAAA,EAAU,GAAA,CAAI,iBAAA,EAAmB,GAAA,CAAI,SAAS,GAAA,CAAI,UAAA,EAAY,GAAA,CAAI,KAAA,EAAO,aAAa,aAAa;AAAA,GACzI;AACF","file":"react-hooks.cjs","sourcesContent":["import { createContext } from \"react\";\nimport type { FeatureDropAnimationPreset, FeatureDropEngine, FeatureEntry, FeaturePriority } from \"../types\";\nimport type { AdoptionEventInput } from \"../analytics\";\nimport type { FeatureDropTranslations } from \"../i18n\";\n\nexport interface FeatureDropContextValue {\n /** Full manifest provided to the provider */\n manifest: FeatureEntry[] | readonly FeatureEntry[];\n /** All currently \"new\" features */\n newFeatures: FeatureEntry[];\n /** New features currently queued by throttling rules */\n queuedFeatures: FeatureEntry[];\n /** Count of new features */\n newCount: number;\n /** Count before throttling (all pending new features) */\n totalNewCount: number;\n /** All new features sorted by priority then release date */\n newFeaturesSorted: FeatureEntry[];\n /** Check if a sidebar key has any new features */\n isNew: (sidebarKey: string) => boolean;\n /** Dismiss a single feature by ID */\n dismiss: (id: string) => void;\n /** Dismiss all features (marks all as seen) */\n dismissAll: () => Promise<void>;\n /** Get the feature entry for a sidebar key (if it's new) */\n getFeature: (sidebarKey: string) => FeatureEntry | undefined;\n /** Whether quiet mode (Do Not Disturb) is enabled */\n quietMode: boolean;\n /** Enable/disable quiet mode */\n setQuietMode: (enabled: boolean) => void;\n /** Mark a feature as seen for dependency-chain resolution */\n markFeatureSeen: (featureId: string) => void;\n /** Mark a feature as clicked for dependency-chain resolution */\n markFeatureClicked: (featureId: string) => void;\n /** Remaining toasts allowed in this session under throttle rules */\n getRemainingToastSlots: () => number;\n /** Mark toasts as shown in this session */\n markToastsShown: (featureIds: string[]) => void;\n /** Whether a modal can open right now under throttle rules */\n canShowModal: (priority?: FeaturePriority) => boolean;\n /** Record a modal display timestamp */\n markModalShown: () => void;\n /** Whether a tour can start right now under throttle rules */\n canShowTour: () => boolean;\n /** Record a tour start timestamp */\n markTourShown: () => void;\n /** Acquire/release spotlight slots under maxSimultaneousSpotlights */\n acquireSpotlightSlot: (id: string, priority?: FeaturePriority) => boolean;\n releaseSpotlightSlot: (id: string) => void;\n /** Number of currently active spotlight slots */\n activeSpotlightCount: number;\n /** Emit an adoption analytics event (collector-backed when configured) */\n trackAdoptionEvent: (event: AdoptionEventInput) => void;\n /** Report a component/runtime error to provider-level monitoring hooks */\n reportError: (\n error: unknown,\n context?: { component?: string; componentStack?: string },\n ) => void;\n /** Active locale code used by built-in UI strings */\n locale: string;\n /** Text direction derived from locale */\n direction: \"ltr\" | \"rtl\";\n /** Active motion preset for built-in component transitions */\n animation: FeatureDropAnimationPreset;\n /** Resolved translation strings for built-in React components */\n translations: FeatureDropTranslations;\n /** Track a named usage event for trigger rules */\n trackUsageEvent: (event: string, delta?: number) => void;\n /** Track a named trigger event for trigger rules */\n trackTriggerEvent: (event: string) => void;\n /** Mark a milestone for trigger rules */\n trackMilestone: (event: string) => void;\n /** Manually override current path for page trigger rules */\n setTriggerPath: (path: string) => void;\n /** Optional engine instance for AI-powered delivery intelligence */\n engine: FeatureDropEngine | null;\n}\n\nexport const FeatureDropContext = createContext<FeatureDropContextValue | null>(\n null,\n);\n","import { useContext } from \"react\";\nimport { FeatureDropContext } from \"../context\";\nimport type { FeatureDropContextValue } from \"../context\";\n\n/**\n * Access the full feature discovery context.\n *\n * Returns: `{ newFeatures, newCount, isNew, dismiss, dismissAll, getFeature }`\n *\n * @throws Error if used outside of `<FeatureDropProvider>`\n */\nexport function useFeatureDrop(): FeatureDropContextValue {\n const context = useContext(FeatureDropContext);\n if (!context) {\n throw new Error(\n \"useFeatureDrop must be used within a <FeatureDropProvider>\",\n );\n }\n return context;\n}\n","import { useFeatureDrop } from \"./use-feature-drop\";\nimport type { FeatureEntry } from \"../../types\";\n\nexport interface UseNewFeatureResult {\n /** Whether this sidebar key has a new feature */\n isNew: boolean;\n /** The feature entry, if new */\n feature: FeatureEntry | undefined;\n /** Dismiss the feature for this sidebar key */\n dismiss: () => void;\n}\n\n/**\n * Check if a single navigation item has a new feature.\n *\n * @param sidebarKey - The key to check (e.g. \"/journal\", \"settings\")\n * @returns `{ isNew, feature, dismiss }`\n */\nexport function useNewFeature(sidebarKey: string): UseNewFeatureResult {\n const { isNew, getFeature, dismiss } = useFeatureDrop();\n\n const feature = getFeature(sidebarKey);\n const isNewValue = isNew(sidebarKey);\n\n return {\n isNew: isNewValue,\n feature,\n dismiss: () => {\n if (feature) {\n dismiss(feature.id);\n }\n },\n };\n}\n","import { useFeatureDrop } from \"./use-feature-drop\";\n\n/**\n * Get the count of currently new features.\n *\n * Useful for rendering a badge count on a \"What's New\" button.\n *\n * @returns The number of new features\n */\nexport function useNewCount(): number {\n const { newCount } = useFeatureDrop();\n return newCount;\n}\n","import { useEffect, useRef } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\n\nexport interface UseTabNotificationOptions {\n /** Whether tab notifications are enabled. Default: true */\n enabled?: boolean;\n /** Template string. `{count}` is replaced with the number. Default: \"({count}) {title}\" */\n template?: string;\n /** Enable flashing/blinking pattern for attention. Default: false */\n flash?: boolean;\n /** Flash interval in ms. Default: 1500 */\n flashInterval?: number;\n}\n\n/**\n * Updates the browser tab title with the unread feature count.\n *\n * Shows \"(3) My App\" when there are new features, restores the original\n * title when all features are read. Optional flash/blink pattern for attention.\n *\n * @example\n * ```tsx\n * function App() {\n * useTabNotification();\n * return <div>...</div>;\n * }\n * ```\n *\n * @example With flash\n * ```tsx\n * useTabNotification({ flash: true, template: \"[{count} new] {title}\" });\n * ```\n */\nexport function useTabNotification(options: UseTabNotificationOptions = {}): void {\n const {\n enabled = true,\n template = \"({count}) {title}\",\n flash = false,\n flashInterval = 1500,\n } = options;\n\n const { newCount } = useFeatureDrop();\n const originalTitleRef = useRef<string>(\"\");\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n // Capture original title once\n if (!originalTitleRef.current) {\n originalTitleRef.current = document.title;\n }\n const originalTitle = originalTitleRef.current;\n\n if (!enabled || newCount === 0) {\n // Restore original title\n document.title = originalTitle;\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n return;\n }\n\n const notificationTitle = template\n .replace(\"{count}\", String(newCount))\n .replace(\"{title}\", originalTitle);\n\n if (flash) {\n // Alternate between notification and original title\n let showNotification = true;\n document.title = notificationTitle;\n intervalRef.current = setInterval(() => {\n showNotification = !showNotification;\n document.title = showNotification ? notificationTitle : originalTitle;\n }, flashInterval);\n } else {\n document.title = notificationTitle;\n }\n\n return () => {\n document.title = originalTitle;\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n };\n }, [enabled, newCount, template, flash, flashInterval]);\n}\n","export type AdoptionEventType =\n | \"feature_seen\"\n | \"feature_clicked\"\n | \"feature_dismissed\"\n | \"tour_started\"\n | \"tour_completed\"\n | \"tour_skipped\"\n | \"checklist_task_completed\"\n | \"checklist_completed\"\n | \"survey_submitted\"\n | \"feedback_submitted\"\n | \"announcement_shown\"\n | \"cta_clicked\";\n\nexport interface AdoptionEvent {\n type: AdoptionEventType;\n featureId?: string;\n tourId?: string;\n variant?: string;\n timestamp: string;\n sessionId?: string;\n userId?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport type AdoptionEventInput = Omit<AdoptionEvent, \"timestamp\"> & {\n timestamp?: string;\n};\n\nexport interface AnalyticsAdapter {\n track: (event: AdoptionEvent) => void | Promise<void>;\n trackBatch?: (events: AdoptionEvent[]) => void | Promise<void>;\n}\n\nexport interface AnalyticsCollectorOptions {\n adapter: AnalyticsAdapter;\n batchSize?: number;\n flushInterval?: number;\n sampleRate?: number;\n enabled?: boolean;\n sessionId?: string;\n userId?: string;\n now?: () => Date;\n random?: () => number;\n}\n\nexport class AnalyticsCollector {\n private adapter: AnalyticsAdapter;\n private queue: AdoptionEvent[] = [];\n private batchSize: number;\n private flushInterval: number;\n private sampleRate: number;\n private enabled: boolean;\n private now: () => Date;\n private random: () => number;\n private sessionId?: string;\n private userId?: string;\n private timer: ReturnType<typeof setInterval> | null = null;\n private flushing = false;\n\n constructor(options: AnalyticsCollectorOptions) {\n this.adapter = options.adapter;\n this.batchSize = options.batchSize ?? 20;\n this.flushInterval = options.flushInterval ?? 10_000;\n this.sampleRate = options.sampleRate ?? 1;\n this.enabled = options.enabled ?? true;\n this.sessionId = options.sessionId;\n this.userId = options.userId;\n this.now = options.now ?? (() => new Date());\n this.random = options.random ?? Math.random;\n this.startTimer();\n }\n\n setEnabled(enabled: boolean): void {\n this.enabled = enabled;\n }\n\n setContext(context: { sessionId?: string; userId?: string }): void {\n if (context.sessionId !== undefined) this.sessionId = context.sessionId;\n if (context.userId !== undefined) this.userId = context.userId;\n }\n\n getQueueSize(): number {\n return this.queue.length;\n }\n\n track(event: AdoptionEventInput): void {\n if (!this.enabled) return;\n if (this.sampleRate < 1 && this.random() > this.sampleRate) return;\n const normalized: AdoptionEvent = {\n ...event,\n timestamp: event.timestamp ?? this.now().toISOString(),\n sessionId: event.sessionId ?? this.sessionId,\n userId: event.userId ?? this.userId,\n };\n this.queue.push(normalized);\n if (this.queue.length >= this.batchSize) {\n void this.flush();\n }\n }\n\n async flush(): Promise<void> {\n if (this.flushing) return;\n if (this.queue.length === 0) return;\n this.flushing = true;\n const batch = this.queue.splice(0, this.queue.length);\n try {\n if (this.adapter.trackBatch) {\n await this.adapter.trackBatch(batch);\n } else {\n for (const event of batch) {\n await this.adapter.track(event);\n }\n }\n } catch {\n // Requeue on transient failures.\n this.queue = [...batch, ...this.queue];\n } finally {\n this.flushing = false;\n }\n }\n\n async destroy(): Promise<void> {\n if (this.timer) {\n clearInterval(this.timer);\n this.timer = null;\n }\n await this.flush();\n }\n\n private startTimer(): void {\n if (this.flushInterval <= 0) return;\n this.timer = setInterval(() => {\n void this.flush();\n }, this.flushInterval);\n }\n}\n\nexport class PostHogAdapter implements AnalyticsAdapter {\n constructor(\n private readonly client: {\n capture: (event: string, properties?: Record<string, unknown>) => void;\n },\n ) {}\n\n track(event: AdoptionEvent): void {\n this.client.capture(event.type, {\n featureId: event.featureId,\n tourId: event.tourId,\n variant: event.variant,\n timestamp: event.timestamp,\n sessionId: event.sessionId,\n userId: event.userId,\n ...event.metadata,\n });\n }\n}\n\nexport class AmplitudeAdapter implements AnalyticsAdapter {\n constructor(\n private readonly client: {\n track: (event: string, properties?: Record<string, unknown>) => void;\n },\n ) {}\n\n track(event: AdoptionEvent): void {\n this.client.track(event.type, {\n featureId: event.featureId,\n tourId: event.tourId,\n variant: event.variant,\n timestamp: event.timestamp,\n sessionId: event.sessionId,\n userId: event.userId,\n ...event.metadata,\n });\n }\n}\n\nexport class MixpanelAdapter implements AnalyticsAdapter {\n constructor(\n private readonly client: {\n track: (event: string, properties?: Record<string, unknown>) => void;\n },\n ) {}\n\n track(event: AdoptionEvent): void {\n this.client.track(event.type, {\n featureId: event.featureId,\n tourId: event.tourId,\n variant: event.variant,\n timestamp: event.timestamp,\n sessionId: event.sessionId,\n userId: event.userId,\n ...event.metadata,\n });\n }\n}\n\nexport class SegmentAdapter implements AnalyticsAdapter {\n constructor(\n private readonly client: {\n track: (event: string, properties?: Record<string, unknown>) => void;\n },\n ) {}\n\n track(event: AdoptionEvent): void {\n this.client.track(event.type, {\n featureId: event.featureId,\n tourId: event.tourId,\n variant: event.variant,\n timestamp: event.timestamp,\n sessionId: event.sessionId,\n userId: event.userId,\n ...event.metadata,\n });\n }\n}\n\nexport class CustomAdapter implements AnalyticsAdapter {\n constructor(private readonly handler: (event: AdoptionEvent) => void | Promise<void>) {}\n\n track(event: AdoptionEvent): void | Promise<void> {\n return this.handler(event);\n }\n}\n\nexport interface FeatureEngagementMetrics {\n seen: number;\n clicked: number;\n dismissed: number;\n}\n\nexport interface AdoptionMetrics {\n getAdoptionRate: (featureId: string) => number;\n getTourCompletionRate: (tourId: string) => number;\n getChecklistCompletionRate: (checklistId: string) => number;\n getFeatureEngagement: (featureId: string) => FeatureEngagementMetrics;\n getVariantPerformance: (featureId: string) => Record<string, number>;\n}\n\nexport function createAdoptionMetrics(events: AdoptionEvent[]): AdoptionMetrics {\n const getAdoptionRate = (featureId: string): number => {\n const seen = events.filter((event) => event.type === \"feature_seen\" && event.featureId === featureId).length;\n if (seen === 0) return 0;\n const clicked = events.filter((event) => event.type === \"feature_clicked\" && event.featureId === featureId).length;\n return clicked / seen;\n };\n\n const getTourCompletionRate = (tourId: string): number => {\n const started = events.filter((event) => event.type === \"tour_started\" && event.tourId === tourId).length;\n if (started === 0) return 0;\n const completed = events.filter((event) => event.type === \"tour_completed\" && event.tourId === tourId).length;\n return completed / started;\n };\n\n const getChecklistCompletionRate = (checklistId: string): number => {\n const taskCompleted = events.filter((event) =>\n event.type === \"checklist_task_completed\" &&\n event.metadata?.checklistId === checklistId\n ).length;\n if (taskCompleted === 0) return 0;\n const completed = events.filter((event) =>\n event.type === \"checklist_completed\" &&\n event.metadata?.checklistId === checklistId\n ).length;\n return completed / taskCompleted;\n };\n\n const getFeatureEngagement = (featureId: string): FeatureEngagementMetrics => ({\n seen: events.filter((event) => event.type === \"feature_seen\" && event.featureId === featureId).length,\n clicked: events.filter((event) => event.type === \"feature_clicked\" && event.featureId === featureId).length,\n dismissed: events.filter((event) => event.type === \"feature_dismissed\" && event.featureId === featureId).length,\n });\n\n const getVariantPerformance = (featureId: string): Record<string, number> => {\n const byVariant = new Map<string, { seen: number; clicked: number }>();\n for (const event of events) {\n if (event.featureId !== featureId) continue;\n const variant = event.variant ?? \"control\";\n const bucket = byVariant.get(variant) ?? { seen: 0, clicked: 0 };\n if (event.type === \"feature_seen\") bucket.seen += 1;\n if (event.type === \"feature_clicked\") bucket.clicked += 1;\n byVariant.set(variant, bucket);\n }\n const output: Record<string, number> = {};\n for (const [variant, bucket] of byVariant.entries()) {\n output[variant] = bucket.seen === 0 ? 0 : bucket.clicked / bucket.seen;\n }\n return output;\n };\n\n return {\n getAdoptionRate,\n getTourCompletionRate,\n getChecklistCompletionRate,\n getFeatureEngagement,\n getVariantPerformance,\n };\n}\n","import { useMemo } from \"react\";\nimport type { AdoptionEvent } from \"../../analytics\";\nimport { createAdoptionMetrics, type AdoptionMetrics } from \"../../analytics\";\n\nexport function useAdoptionAnalytics(events: AdoptionEvent[]): AdoptionMetrics {\n return useMemo(() => createAdoptionMetrics(events), [events]);\n}\n","import type { TourStep } from \"./components/tour\";\n\nexport interface TourSnapshot {\n isActive: boolean;\n currentStepIndex: number;\n currentStep: TourStep | null;\n totalSteps: number;\n}\n\nexport interface TourController {\n startTour: () => void;\n nextStep: () => void;\n prevStep: () => void;\n skipTour: () => void;\n closeTour: () => void;\n getSnapshot: () => TourSnapshot;\n subscribe: (listener: () => void) => () => void;\n}\n\nconst controllers = new Map<string, TourController>();\nconst registryListeners = new Map<string, Set<() => void>>();\n\nfunction emitRegistry(id: string): void {\n const listeners = registryListeners.get(id);\n if (!listeners) return;\n for (const listener of listeners) listener();\n}\n\nexport function registerTourController(id: string, controller: TourController): () => void {\n controllers.set(id, controller);\n emitRegistry(id);\n return () => {\n if (controllers.get(id) === controller) {\n controllers.delete(id);\n emitRegistry(id);\n }\n };\n}\n\nexport function getTourController(id: string): TourController | undefined {\n return controllers.get(id);\n}\n\nexport function subscribeTourRegistry(id: string, listener: () => void): () => void {\n const listeners = registryListeners.get(id) ?? new Set<() => void>();\n listeners.add(listener);\n registryListeners.set(id, listeners);\n return () => {\n const current = registryListeners.get(id);\n if (!current) return;\n current.delete(listener);\n if (current.size === 0) {\n registryListeners.delete(id);\n }\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { getTourController, subscribeTourRegistry, type TourSnapshot } from \"../tour-registry\";\n\nconst EMPTY_SNAPSHOT: TourSnapshot = {\n isActive: false,\n currentStepIndex: -1,\n currentStep: null,\n totalSteps: 0,\n};\n\nexport interface UseTourResult {\n startTour: () => void;\n nextStep: () => void;\n prevStep: () => void;\n skipTour: () => void;\n closeTour: () => void;\n currentStep: TourSnapshot[\"currentStep\"];\n currentStepIndex: number;\n totalSteps: number;\n isActive: boolean;\n}\n\nfunction readSnapshot(id: string): TourSnapshot {\n const controller = getTourController(id);\n if (!controller) return EMPTY_SNAPSHOT;\n return controller.getSnapshot();\n}\n\nexport function useTour(id: string): UseTourResult {\n const [snapshot, setSnapshot] = useState<TourSnapshot>(() => readSnapshot(id));\n\n useEffect(() => {\n let unsubscribeController: (() => void) | null = null;\n\n const bindController = (): void => {\n if (unsubscribeController) {\n unsubscribeController();\n unsubscribeController = null;\n }\n const controller = getTourController(id);\n if (!controller) {\n setSnapshot(EMPTY_SNAPSHOT);\n return;\n }\n setSnapshot(controller.getSnapshot());\n unsubscribeController = controller.subscribe(() => {\n setSnapshot(controller.getSnapshot());\n });\n };\n\n bindController();\n const unsubscribeRegistry = subscribeTourRegistry(id, bindController);\n return () => {\n unsubscribeRegistry();\n if (unsubscribeController) unsubscribeController();\n };\n }, [id]);\n\n const call = useCallback((method: keyof Omit<UseTourResult, \"currentStep\" | \"currentStepIndex\" | \"totalSteps\" | \"isActive\">) => {\n const controller = getTourController(id);\n if (!controller) return;\n controller[method]();\n }, [id]);\n\n return useMemo(\n () => ({\n startTour: () => call(\"startTour\"),\n nextStep: () => call(\"nextStep\"),\n prevStep: () => call(\"prevStep\"),\n skipTour: () => call(\"skipTour\"),\n closeTour: () => call(\"closeTour\"),\n currentStep: snapshot.currentStep,\n currentStepIndex: snapshot.currentStepIndex,\n totalSteps: snapshot.totalSteps,\n isActive: snapshot.isActive,\n }),\n [call, snapshot],\n );\n}\n","import { useCallback, useMemo, useState } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\nimport { getTourController } from \"../tour-registry\";\n\nexport interface TourSequenceItem {\n featureId: string;\n tourId: string;\n}\n\nexport interface UseTourSequencerResult {\n nextTourId: string | null;\n nextFeatureId: string | null;\n remainingTours: number;\n startNextTour: () => boolean;\n}\n\nexport function useTourSequencer(sequence: TourSequenceItem[]): UseTourSequencerResult {\n const {\n newFeatures,\n canShowTour,\n markTourShown,\n markFeatureSeen,\n } = useFeatureDrop();\n const [startedFeatureIds, setStartedFeatureIds] = useState<Set<string>>(new Set());\n\n const visibleFeatureIds = useMemo(\n () => new Set(newFeatures.map((feature) => feature.id)),\n [newFeatures],\n );\n\n const remaining = useMemo(\n () =>\n sequence.filter(\n (item) =>\n visibleFeatureIds.has(item.featureId) &&\n !startedFeatureIds.has(item.featureId),\n ),\n [sequence, startedFeatureIds, visibleFeatureIds],\n );\n\n const next = remaining[0] ?? null;\n\n const startNextTour = useCallback((): boolean => {\n if (!next) return false;\n if (!canShowTour()) return false;\n const controller = getTourController(next.tourId);\n if (!controller) return false;\n setStartedFeatureIds((previous) => {\n if (previous.has(next.featureId)) return previous;\n const updated = new Set(previous);\n updated.add(next.featureId);\n return updated;\n });\n markFeatureSeen(next.featureId);\n markTourShown();\n controller.startTour();\n return true;\n }, [canShowTour, markFeatureSeen, markTourShown, next]);\n\n return {\n nextTourId: next?.tourId ?? null,\n nextFeatureId: next?.featureId ?? null,\n remainingTours: remaining.length,\n startNextTour,\n };\n}\n","export interface ChecklistSnapshot {\n exists: boolean;\n tasks: Array<{ id: string; completed: boolean }>;\n progress: { completed: number; total: number; percent: number };\n isComplete: boolean;\n dismissed: boolean;\n collapsed: boolean;\n}\n\nexport interface ChecklistController {\n completeTask: (taskId: string) => void;\n resetChecklist: () => void;\n dismissChecklist: () => void;\n toggleCollapsed: () => void;\n getSnapshot: () => ChecklistSnapshot;\n subscribe: (listener: () => void) => () => void;\n}\n\nconst controllers = new Map<string, ChecklistController>();\nconst registryListeners = new Map<string, Set<() => void>>();\n\nfunction emitRegistry(id: string): void {\n const listeners = registryListeners.get(id);\n if (!listeners) return;\n for (const listener of listeners) listener();\n}\n\nexport function registerChecklistController(id: string, controller: ChecklistController): () => void {\n controllers.set(id, controller);\n emitRegistry(id);\n return () => {\n if (controllers.get(id) === controller) {\n controllers.delete(id);\n emitRegistry(id);\n }\n };\n}\n\nexport function getChecklistController(id: string): ChecklistController | undefined {\n return controllers.get(id);\n}\n\nexport function subscribeChecklistRegistry(id: string, listener: () => void): () => void {\n const listeners = registryListeners.get(id) ?? new Set<() => void>();\n listeners.add(listener);\n registryListeners.set(id, listeners);\n return () => {\n const current = registryListeners.get(id);\n if (!current) return;\n current.delete(listener);\n if (current.size === 0) registryListeners.delete(id);\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport {\n getChecklistController,\n subscribeChecklistRegistry,\n type ChecklistSnapshot,\n} from \"../checklist-registry\";\n\nconst EMPTY_SNAPSHOT: ChecklistSnapshot = {\n exists: false,\n tasks: [],\n progress: { completed: 0, total: 0, percent: 0 },\n isComplete: false,\n dismissed: false,\n collapsed: false,\n};\n\nexport interface UseChecklistResult {\n completeTask: (taskId: string) => void;\n resetChecklist: () => void;\n dismissChecklist: () => void;\n toggleCollapsed: () => void;\n isComplete: boolean;\n progress: { completed: number; total: number; percent: number };\n tasks: Array<{ id: string; completed: boolean }>;\n dismissed: boolean;\n collapsed: boolean;\n}\n\nfunction readSnapshot(id: string): ChecklistSnapshot {\n const controller = getChecklistController(id);\n if (!controller) return EMPTY_SNAPSHOT;\n return controller.getSnapshot();\n}\n\nexport function useChecklist(id: string): UseChecklistResult {\n const [snapshot, setSnapshot] = useState<ChecklistSnapshot>(() => readSnapshot(id));\n\n useEffect(() => {\n let unsubscribeController: (() => void) | null = null;\n\n const bind = (): void => {\n if (unsubscribeController) {\n unsubscribeController();\n unsubscribeController = null;\n }\n const controller = getChecklistController(id);\n if (!controller) {\n setSnapshot(EMPTY_SNAPSHOT);\n return;\n }\n setSnapshot(controller.getSnapshot());\n unsubscribeController = controller.subscribe(() => {\n setSnapshot(controller.getSnapshot());\n });\n };\n\n bind();\n const unsubscribeRegistry = subscribeChecklistRegistry(id, bind);\n return () => {\n unsubscribeRegistry();\n if (unsubscribeController) unsubscribeController();\n };\n }, [id]);\n\n const invoke = useCallback((method: \"completeTask\" | \"resetChecklist\" | \"dismissChecklist\" | \"toggleCollapsed\", arg?: string) => {\n const controller = getChecklistController(id);\n if (!controller) return;\n if (method === \"completeTask\") {\n controller.completeTask(arg ?? \"\");\n return;\n }\n controller[method]();\n }, [id]);\n\n return useMemo(\n () => ({\n completeTask: (taskId: string) => invoke(\"completeTask\", taskId),\n resetChecklist: () => invoke(\"resetChecklist\"),\n dismissChecklist: () => invoke(\"dismissChecklist\"),\n toggleCollapsed: () => invoke(\"toggleCollapsed\"),\n isComplete: snapshot.isComplete,\n progress: snapshot.progress,\n tasks: snapshot.tasks,\n dismissed: snapshot.dismissed,\n collapsed: snapshot.collapsed,\n }),\n [invoke, snapshot],\n );\n}\n","import type { SurveyType } from \"./components/survey\";\n\nexport interface SurveySnapshot {\n exists: boolean;\n isOpen: boolean;\n submitted: boolean;\n canShow: boolean;\n type: SurveyType;\n}\n\nexport interface SurveyController {\n show: (options?: { force?: boolean }) => boolean;\n hide: () => void;\n askLater: () => void;\n getSnapshot: () => SurveySnapshot;\n subscribe: (listener: () => void) => () => void;\n}\n\nconst controllers = new Map<string, SurveyController>();\nconst registryListeners = new Map<string, Set<() => void>>();\n\nfunction emitRegistry(id: string): void {\n const listeners = registryListeners.get(id);\n if (!listeners) return;\n for (const listener of listeners) listener();\n}\n\nexport function registerSurveyController(id: string, controller: SurveyController): () => void {\n controllers.set(id, controller);\n emitRegistry(id);\n return () => {\n if (controllers.get(id) === controller) {\n controllers.delete(id);\n emitRegistry(id);\n }\n };\n}\n\nexport function getSurveyController(id: string): SurveyController | undefined {\n return controllers.get(id);\n}\n\nexport function subscribeSurveyRegistry(id: string, listener: () => void): () => void {\n const listeners = registryListeners.get(id) ?? new Set<() => void>();\n listeners.add(listener);\n registryListeners.set(id, listeners);\n return () => {\n const current = registryListeners.get(id);\n if (!current) return;\n current.delete(listener);\n if (current.size === 0) {\n registryListeners.delete(id);\n }\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport {\n getSurveyController,\n subscribeSurveyRegistry,\n type SurveySnapshot,\n} from \"../survey-registry\";\nimport type { SurveyType } from \"../components/survey\";\n\nconst EMPTY_SNAPSHOT: SurveySnapshot = {\n exists: false,\n isOpen: false,\n submitted: false,\n canShow: false,\n type: \"custom\",\n};\n\nexport interface UseSurveyResult {\n show: (options?: { force?: boolean }) => boolean;\n hide: () => void;\n askLater: () => void;\n isOpen: boolean;\n submitted: boolean;\n canShow: boolean;\n type: SurveyType;\n}\n\nfunction readSnapshot(id: string): SurveySnapshot {\n const controller = getSurveyController(id);\n if (!controller) return EMPTY_SNAPSHOT;\n return controller.getSnapshot();\n}\n\nexport function useSurvey(id: string): UseSurveyResult {\n const [snapshot, setSnapshot] = useState<SurveySnapshot>(() => readSnapshot(id));\n\n useEffect(() => {\n let unsubscribeController: (() => void) | null = null;\n\n const bind = (): void => {\n if (unsubscribeController) {\n unsubscribeController();\n unsubscribeController = null;\n }\n const controller = getSurveyController(id);\n if (!controller) {\n setSnapshot(EMPTY_SNAPSHOT);\n return;\n }\n setSnapshot(controller.getSnapshot());\n unsubscribeController = controller.subscribe(() => {\n setSnapshot(controller.getSnapshot());\n });\n };\n\n bind();\n const unsubscribeRegistry = subscribeSurveyRegistry(id, bind);\n return () => {\n unsubscribeRegistry();\n if (unsubscribeController) unsubscribeController();\n };\n }, [id]);\n\n const show = useCallback((options?: { force?: boolean }): boolean => {\n const controller = getSurveyController(id);\n if (!controller) return false;\n return controller.show(options);\n }, [id]);\n\n const hide = useCallback(() => {\n getSurveyController(id)?.hide();\n }, [id]);\n\n const askLater = useCallback(() => {\n getSurveyController(id)?.askLater();\n }, [id]);\n\n return useMemo(\n () => ({\n show,\n hide,\n askLater,\n isOpen: snapshot.isOpen,\n submitted: snapshot.submitted,\n canShow: snapshot.canShow,\n type: snapshot.type,\n }),\n [askLater, hide, show, snapshot],\n );\n}\n","import { useCallback, useMemo } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\nimport type { FeatureEntry } from \"../../types\";\n\nexport interface UseChangelogResult {\n /** All features from the manifest (including non-new) */\n features: readonly FeatureEntry[];\n /** Only features that are currently \"new\" (unread) */\n newFeatures: readonly FeatureEntry[];\n /** Count of new/unread features */\n newCount: number;\n /** Sorted new features (critical first, then by date) */\n newFeaturesSorted: readonly FeatureEntry[];\n /** Dismiss a single feature by ID */\n dismiss: (id: string) => void;\n /** Dismiss all features at once */\n dismissAll: () => void;\n /** Check if a specific feature is new */\n isNew: (sidebarKey: string) => boolean;\n /** Mark all currently visible features as seen (advances watermark) */\n markAllSeen: () => void;\n /** Get features filtered by category */\n getByCategory: (category: string) => readonly FeatureEntry[];\n}\n\nexport function useChangelog(): UseChangelogResult {\n const ctx = useFeatureDrop();\n\n const markAllSeen = useCallback(() => {\n void ctx.dismissAll();\n }, [ctx]);\n\n const getByCategory = useCallback(\n (category: string): readonly FeatureEntry[] => {\n return ctx.newFeatures.filter((f) => f.category === category);\n },\n [ctx.newFeatures],\n );\n\n return useMemo(\n () => ({\n features: ctx.manifest,\n newFeatures: ctx.newFeatures,\n newCount: ctx.newCount,\n newFeaturesSorted: ctx.newFeaturesSorted,\n dismiss: ctx.dismiss,\n dismissAll: () => void ctx.dismissAll(),\n isNew: ctx.isNew,\n markAllSeen,\n getByCategory,\n }),\n [ctx.manifest, ctx.newFeatures, ctx.newCount, ctx.newFeaturesSorted, ctx.dismiss, ctx.dismissAll, ctx.isNew, markAllSeen, getByCategory],\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/react/context.ts","../src/react/hooks/use-feature-drop.ts","../src/react/hooks/use-new-feature.ts","../src/react/hooks/use-new-count.ts","../src/react/hooks/use-tab-notification.ts","../src/analytics.ts","../src/react/hooks/use-adoption-analytics.ts","../src/react/tour-registry.ts","../src/react/hooks/use-tour.ts","../src/react/hooks/use-tour-sequencer.ts","../src/react/checklist-registry.ts","../src/react/hooks/use-checklist.ts","../src/react/survey-registry.ts","../src/react/hooks/use-survey.ts","../src/react/hooks/use-changelog.ts","../src/react/hooks/use-smart-feature.ts","../src/react/hooks/use-adoption-score.ts","../src/react/hooks/use-behavior-profile.ts"],"names":["createContext","useContext","useRef","useEffect","useMemo","useState","useCallback","controllers","registryListeners","EMPTY_SNAPSHOT","readSnapshot"],"mappings":";;;;;AA8EO,IAAM,kBAAA,GAAqBA,mBAAA;AAAA,EAChC;AACF,CAAA;;;ACrEO,SAAS,cAAA,GAA0C;AACxD,EAAA,MAAM,OAAA,GAAUC,iBAAW,kBAAkB,CAAA;AAC7C,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;ACDO,SAAS,cAAc,UAAA,EAAyC;AACrE,EAAA,MAAM,EAAE,KAAA,EAAO,UAAA,EAAY,OAAA,KAAY,cAAA,EAAe;AAEtD,EAAA,MAAM,OAAA,G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B,eAAA,EAAiB,OAAA;AAAA,EACjB,SAAA,EAAW;AACb,CAAA;AA4BO,SAAS,kBAAA,GAA+C;AAC7D,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,cAAA,EAAe;AAElC,EAAA,OAAOA,cAAQ,MAAM;AACnB,IAAA,IAAI,CAAC,QAAQ,OAAO,eAAA;AAKpB,IAAA,MAAM,KAAA,GAAQ,OAAO,gBAAA,EAAiB;AAEtC,IAAA,OAAO;AAAA,MACL,YAAA,EAAc,CAAA;AAAA;AAAA,MACd,WAAA,EAAa,MAAM,SAAA,CAAU,WAAA;AAAA,MAC7B,cAAA,EAAgB,CAAA,GAAI,KAAA,CAAM,SAAA,CAAU,WAAA;AAAA,MACpC,eAAA,EAAiB,OAAA;AAAA;AAAA,MACjB,SAAA,EAAW;AAAA,KACb;AAAA,EACF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AACb","file":"react-hooks.cjs","sourcesContent":["import { createContext } from \"react\";\nimport type { FeatureDropAnimationPreset, FeatureDropEngine, FeatureEntry, FeaturePriority } from \"../types\";\nimport type { AdoptionEventInput } from \"../analytics\";\nimport type { FeatureDropTranslations } from \"../i18n\";\n\nexport interface FeatureDropContextValue {\n /** Full manifest provided to the provider */\n manifest: FeatureEntry[] | readonly FeatureEntry[];\n /** All currently \"new\" features */\n newFeatures: FeatureEntry[];\n /** New features currently queued by throttling rules */\n queuedFeatures: FeatureEntry[];\n /** Count of new features */\n newCount: number;\n /** Count before throttling (all pending new features) */\n totalNewCount: number;\n /** All new features sorted by priority then release date */\n newFeaturesSorted: FeatureEntry[];\n /** Check if a sidebar key has any new features */\n isNew: (sidebarKey: string) => boolean;\n /** Dismiss a single feature by ID */\n dismiss: (id: string) => void;\n /** Dismiss all features (marks all as seen) */\n dismissAll: () => Promise<void>;\n /** Get the feature entry for a sidebar key (if it's new) */\n getFeature: (sidebarKey: string) => FeatureEntry | undefined;\n /** Whether quiet mode (Do Not Disturb) is enabled */\n quietMode: boolean;\n /** Enable/disable quiet mode */\n setQuietMode: (enabled: boolean) => void;\n /** Mark a feature as seen for dependency-chain resolution */\n markFeatureSeen: (featureId: string) => void;\n /** Mark a feature as clicked for dependency-chain resolution */\n markFeatureClicked: (featureId: string) => void;\n /** Remaining toasts allowed in this session under throttle rules */\n getRemainingToastSlots: () => number;\n /** Mark toasts as shown in this session */\n markToastsShown: (featureIds: string[]) => void;\n /** Whether a modal can open right now under throttle rules */\n canShowModal: (priority?: FeaturePriority) => boolean;\n /** Record a modal display timestamp */\n markModalShown: () => void;\n /** Whether a tour can start right now under throttle rules */\n canShowTour: () => boolean;\n /** Record a tour start timestamp */\n markTourShown: () => void;\n /** Acquire/release spotlight slots under maxSimultaneousSpotlights */\n acquireSpotlightSlot: (id: string, priority?: FeaturePriority) => boolean;\n releaseSpotlightSlot: (id: string) => void;\n /** Number of currently active spotlight slots */\n activeSpotlightCount: number;\n /** Emit an adoption analytics event (collector-backed when configured) */\n trackAdoptionEvent: (event: AdoptionEventInput) => void;\n /** Report a component/runtime error to provider-level monitoring hooks */\n reportError: (\n error: unknown,\n context?: { component?: string; componentStack?: string },\n ) => void;\n /** Active locale code used by built-in UI strings */\n locale: string;\n /** Text direction derived from locale */\n direction: \"ltr\" | \"rtl\";\n /** Active motion preset for built-in component transitions */\n animation: FeatureDropAnimationPreset;\n /** Resolved translation strings for built-in React components */\n translations: FeatureDropTranslations;\n /** Track a named usage event for trigger rules */\n trackUsageEvent: (event: string, delta?: number) => void;\n /** Track a named trigger event for trigger rules */\n trackTriggerEvent: (event: string) => void;\n /** Mark a milestone for trigger rules */\n trackMilestone: (event: string) => void;\n /** Manually override current path for page trigger rules */\n setTriggerPath: (path: string) => void;\n /** Optional engine instance for AI-powered delivery intelligence */\n engine: FeatureDropEngine | null;\n}\n\nexport const FeatureDropContext = createContext<FeatureDropContextValue | null>(\n null,\n);\n","import { useContext } from \"react\";\nimport { FeatureDropContext } from \"../context\";\nimport type { FeatureDropContextValue } from \"../context\";\n\n/**\n * Access the full feature discovery context.\n *\n * Returns: `{ newFeatures, newCount, isNew, dismiss, dismissAll, getFeature }`\n *\n * @throws Error if used outside of `<FeatureDropProvider>`\n */\nexport function useFeatureDrop(): FeatureDropContextValue {\n const context = useContext(FeatureDropContext);\n if (!context) {\n throw new Error(\n \"useFeatureDrop must be used within a <FeatureDropProvider>\",\n );\n }\n return context;\n}\n","import { useFeatureDrop } from \"./use-feature-drop\";\nimport type { FeatureEntry } from \"../../types\";\n\nexport interface UseNewFeatureResult {\n /** Whether this sidebar key has a new feature */\n isNew: boolean;\n /** The feature entry, if new */\n feature: FeatureEntry | undefined;\n /** Dismiss the feature for this sidebar key */\n dismiss: () => void;\n}\n\n/**\n * Check if a single navigation item has a new feature.\n *\n * @param sidebarKey - The key to check (e.g. \"/journal\", \"settings\")\n * @returns `{ isNew, feature, dismiss }`\n */\nexport function useNewFeature(sidebarKey: string): UseNewFeatureResult {\n const { isNew, getFeature, dismiss } = useFeatureDrop();\n\n const feature = getFeature(sidebarKey);\n const isNewValue = isNew(sidebarKey);\n\n return {\n isNew: isNewValue,\n feature,\n dismiss: () => {\n if (feature) {\n dismiss(feature.id);\n }\n },\n };\n}\n","import { useFeatureDrop } from \"./use-feature-drop\";\n\n/**\n * Get the count of currently new features.\n *\n * Useful for rendering a badge count on a \"What's New\" button.\n *\n * @returns The number of new features\n */\nexport function useNewCount(): number {\n const { newCount } = useFeatureDrop();\n return newCount;\n}\n","import { useEffect, useRef } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\n\nexport interface UseTabNotificationOptions {\n /** Whether tab notifications are enabled. Default: true */\n enabled?: boolean;\n /** Template string. `{count}` is replaced with the number. Default: \"({count}) {title}\" */\n template?: string;\n /** Enable flashing/blinking pattern for attention. Default: false */\n flash?: boolean;\n /** Flash interval in ms. Default: 1500 */\n flashInterval?: number;\n}\n\n/**\n * Updates the browser tab title with the unread feature count.\n *\n * Shows \"(3) My App\" when there are new features, restores the original\n * title when all features are read. Optional flash/blink pattern for attention.\n *\n * @example\n * ```tsx\n * function App() {\n * useTabNotification();\n * return <div>...</div>;\n * }\n * ```\n *\n * @example With flash\n * ```tsx\n * useTabNotification({ flash: true, template: \"[{count} new] {title}\" });\n * ```\n */\nexport function useTabNotification(options: UseTabNotificationOptions = {}): void {\n const {\n enabled = true,\n template = \"({count}) {title}\",\n flash = false,\n flashInterval = 1500,\n } = options;\n\n const { newCount } = useFeatureDrop();\n const originalTitleRef = useRef<string>(\"\");\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n // Capture original title once\n if (!originalTitleRef.current) {\n originalTitleRef.current = document.title;\n }\n const originalTitle = originalTitleRef.current;\n\n if (!enabled || newCount === 0) {\n // Restore original title\n document.title = originalTitle;\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n return;\n }\n\n const notificationTitle = template\n .replace(\"{count}\", String(newCount))\n .replace(\"{title}\", originalTitle);\n\n if (flash) {\n // Alternate between notification and original title\n let showNotification = true;\n document.title = notificationTitle;\n intervalRef.current = setInterval(() => {\n showNotification = !showNotification;\n document.title = showNotification ? notificationTitle : originalTitle;\n }, flashInterval);\n } else {\n document.title = notificationTitle;\n }\n\n return () => {\n document.title = originalTitle;\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n };\n }, [enabled, newCount, template, flash, flashInterval]);\n}\n","export type AdoptionEventType =\n | \"feature_seen\"\n | \"feature_clicked\"\n | \"feature_dismissed\"\n | \"tour_started\"\n | \"tour_completed\"\n | \"tour_skipped\"\n | \"checklist_task_completed\"\n | \"checklist_completed\"\n | \"survey_submitted\"\n | \"feedback_submitted\"\n | \"announcement_shown\"\n | \"cta_clicked\";\n\nexport interface AdoptionEvent {\n type: AdoptionEventType;\n featureId?: string;\n tourId?: string;\n variant?: string;\n timestamp: string;\n sessionId?: string;\n userId?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport type AdoptionEventInput = Omit<AdoptionEvent, \"timestamp\"> & {\n timestamp?: string;\n};\n\nexport interface AnalyticsAdapter {\n track: (event: AdoptionEvent) => void | Promise<void>;\n trackBatch?: (events: AdoptionEvent[]) => void | Promise<void>;\n}\n\nexport interface AnalyticsCollectorOptions {\n adapter: AnalyticsAdapter;\n batchSize?: number;\n flushInterval?: number;\n sampleRate?: number;\n enabled?: boolean;\n sessionId?: string;\n userId?: string;\n now?: () => Date;\n random?: () => number;\n}\n\nexport class AnalyticsCollector {\n private adapter: AnalyticsAdapter;\n private queue: AdoptionEvent[] = [];\n private batchSize: number;\n private flushInterval: number;\n private sampleRate: number;\n private enabled: boolean;\n private now: () => Date;\n private random: () => number;\n private sessionId?: string;\n private userId?: string;\n private timer: ReturnType<typeof setInterval> | null = null;\n private flushing = false;\n\n constructor(options: AnalyticsCollectorOptions) {\n this.adapter = options.adapter;\n this.batchSize = options.batchSize ?? 20;\n this.flushInterval = options.flushInterval ?? 10_000;\n this.sampleRate = options.sampleRate ?? 1;\n this.enabled = options.enabled ?? true;\n this.sessionId = options.sessionId;\n this.userId = options.userId;\n this.now = options.now ?? (() => new Date());\n this.random = options.random ?? Math.random;\n this.startTimer();\n }\n\n setEnabled(enabled: boolean): void {\n this.enabled = enabled;\n }\n\n setContext(context: { sessionId?: string; userId?: string }): void {\n if (context.sessionId !== undefined) this.sessionId = context.sessionId;\n if (context.userId !== undefined) this.userId = context.userId;\n }\n\n getQueueSize(): number {\n return this.queue.length;\n }\n\n track(event: AdoptionEventInput): void {\n if (!this.enabled) return;\n if (this.sampleRate < 1 && this.random() > this.sampleRate) return;\n const normalized: AdoptionEvent = {\n ...event,\n timestamp: event.timestamp ?? this.now().toISOString(),\n sessionId: event.sessionId ?? this.sessionId,\n userId: event.userId ?? this.userId,\n };\n this.queue.push(normalized);\n if (this.queue.length >= this.batchSize) {\n void this.flush();\n }\n }\n\n async flush(): Promise<void> {\n if (this.flushing) return;\n if (this.queue.length === 0) return;\n this.flushing = true;\n const batch = this.queue.splice(0, this.queue.length);\n try {\n if (this.adapter.trackBatch) {\n await this.adapter.trackBatch(batch);\n } else {\n for (const event of batch) {\n await this.adapter.track(event);\n }\n }\n } catch {\n // Requeue on transient failures.\n this.queue = [...batch, ...this.queue];\n } finally {\n this.flushing = false;\n }\n }\n\n async destroy(): Promise<void> {\n if (this.timer) {\n clearInterval(this.timer);\n this.timer = null;\n }\n await this.flush();\n }\n\n private startTimer(): void {\n if (this.flushInterval <= 0) return;\n this.timer = setInterval(() => {\n void this.flush();\n }, this.flushInterval);\n }\n}\n\nexport class PostHogAdapter implements AnalyticsAdapter {\n constructor(\n private readonly client: {\n capture: (event: string, properties?: Record<string, unknown>) => void;\n },\n ) {}\n\n track(event: AdoptionEvent): void {\n this.client.capture(event.type, {\n featureId: event.featureId,\n tourId: event.tourId,\n variant: event.variant,\n timestamp: event.timestamp,\n sessionId: event.sessionId,\n userId: event.userId,\n ...event.metadata,\n });\n }\n}\n\nexport class AmplitudeAdapter implements AnalyticsAdapter {\n constructor(\n private readonly client: {\n track: (event: string, properties?: Record<string, unknown>) => void;\n },\n ) {}\n\n track(event: AdoptionEvent): void {\n this.client.track(event.type, {\n featureId: event.featureId,\n tourId: event.tourId,\n variant: event.variant,\n timestamp: event.timestamp,\n sessionId: event.sessionId,\n userId: event.userId,\n ...event.metadata,\n });\n }\n}\n\nexport class MixpanelAdapter implements AnalyticsAdapter {\n constructor(\n private readonly client: {\n track: (event: string, properties?: Record<string, unknown>) => void;\n },\n ) {}\n\n track(event: AdoptionEvent): void {\n this.client.track(event.type, {\n featureId: event.featureId,\n tourId: event.tourId,\n variant: event.variant,\n timestamp: event.timestamp,\n sessionId: event.sessionId,\n userId: event.userId,\n ...event.metadata,\n });\n }\n}\n\nexport class SegmentAdapter implements AnalyticsAdapter {\n constructor(\n private readonly client: {\n track: (event: string, properties?: Record<string, unknown>) => void;\n },\n ) {}\n\n track(event: AdoptionEvent): void {\n this.client.track(event.type, {\n featureId: event.featureId,\n tourId: event.tourId,\n variant: event.variant,\n timestamp: event.timestamp,\n sessionId: event.sessionId,\n userId: event.userId,\n ...event.metadata,\n });\n }\n}\n\nexport class CustomAdapter implements AnalyticsAdapter {\n constructor(private readonly handler: (event: AdoptionEvent) => void | Promise<void>) {}\n\n track(event: AdoptionEvent): void | Promise<void> {\n return this.handler(event);\n }\n}\n\nexport interface FeatureEngagementMetrics {\n seen: number;\n clicked: number;\n dismissed: number;\n}\n\nexport interface AdoptionMetrics {\n getAdoptionRate: (featureId: string) => number;\n getTourCompletionRate: (tourId: string) => number;\n getChecklistCompletionRate: (checklistId: string) => number;\n getFeatureEngagement: (featureId: string) => FeatureEngagementMetrics;\n getVariantPerformance: (featureId: string) => Record<string, number>;\n}\n\nexport function createAdoptionMetrics(events: AdoptionEvent[]): AdoptionMetrics {\n const getAdoptionRate = (featureId: string): number => {\n const seen = events.filter((event) => event.type === \"feature_seen\" && event.featureId === featureId).length;\n if (seen === 0) return 0;\n const clicked = events.filter((event) => event.type === \"feature_clicked\" && event.featureId === featureId).length;\n return clicked / seen;\n };\n\n const getTourCompletionRate = (tourId: string): number => {\n const started = events.filter((event) => event.type === \"tour_started\" && event.tourId === tourId).length;\n if (started === 0) return 0;\n const completed = events.filter((event) => event.type === \"tour_completed\" && event.tourId === tourId).length;\n return completed / started;\n };\n\n const getChecklistCompletionRate = (checklistId: string): number => {\n const taskCompleted = events.filter((event) =>\n event.type === \"checklist_task_completed\" &&\n event.metadata?.checklistId === checklistId\n ).length;\n if (taskCompleted === 0) return 0;\n const completed = events.filter((event) =>\n event.type === \"checklist_completed\" &&\n event.metadata?.checklistId === checklistId\n ).length;\n return completed / taskCompleted;\n };\n\n const getFeatureEngagement = (featureId: string): FeatureEngagementMetrics => ({\n seen: events.filter((event) => event.type === \"feature_seen\" && event.featureId === featureId).length,\n clicked: events.filter((event) => event.type === \"feature_clicked\" && event.featureId === featureId).length,\n dismissed: events.filter((event) => event.type === \"feature_dismissed\" && event.featureId === featureId).length,\n });\n\n const getVariantPerformance = (featureId: string): Record<string, number> => {\n const byVariant = new Map<string, { seen: number; clicked: number }>();\n for (const event of events) {\n if (event.featureId !== featureId) continue;\n const variant = event.variant ?? \"control\";\n const bucket = byVariant.get(variant) ?? { seen: 0, clicked: 0 };\n if (event.type === \"feature_seen\") bucket.seen += 1;\n if (event.type === \"feature_clicked\") bucket.clicked += 1;\n byVariant.set(variant, bucket);\n }\n const output: Record<string, number> = {};\n for (const [variant, bucket] of byVariant.entries()) {\n output[variant] = bucket.seen === 0 ? 0 : bucket.clicked / bucket.seen;\n }\n return output;\n };\n\n return {\n getAdoptionRate,\n getTourCompletionRate,\n getChecklistCompletionRate,\n getFeatureEngagement,\n getVariantPerformance,\n };\n}\n","import { useMemo } from \"react\";\nimport type { AdoptionEvent } from \"../../analytics\";\nimport { createAdoptionMetrics, type AdoptionMetrics } from \"../../analytics\";\n\nexport function useAdoptionAnalytics(events: AdoptionEvent[]): AdoptionMetrics {\n return useMemo(() => createAdoptionMetrics(events), [events]);\n}\n","import type { TourStep } from \"./components/tour\";\n\nexport interface TourSnapshot {\n isActive: boolean;\n currentStepIndex: number;\n currentStep: TourStep | null;\n totalSteps: number;\n}\n\nexport interface TourController {\n startTour: () => void;\n nextStep: () => void;\n prevStep: () => void;\n skipTour: () => void;\n closeTour: () => void;\n getSnapshot: () => TourSnapshot;\n subscribe: (listener: () => void) => () => void;\n}\n\nconst controllers = new Map<string, TourController>();\nconst registryListeners = new Map<string, Set<() => void>>();\n\nfunction emitRegistry(id: string): void {\n const listeners = registryListeners.get(id);\n if (!listeners) return;\n for (const listener of listeners) listener();\n}\n\nexport function registerTourController(id: string, controller: TourController): () => void {\n controllers.set(id, controller);\n emitRegistry(id);\n return () => {\n if (controllers.get(id) === controller) {\n controllers.delete(id);\n emitRegistry(id);\n }\n };\n}\n\nexport function getTourController(id: string): TourController | undefined {\n return controllers.get(id);\n}\n\nexport function subscribeTourRegistry(id: string, listener: () => void): () => void {\n const listeners = registryListeners.get(id) ?? new Set<() => void>();\n listeners.add(listener);\n registryListeners.set(id, listeners);\n return () => {\n const current = registryListeners.get(id);\n if (!current) return;\n current.delete(listener);\n if (current.size === 0) {\n registryListeners.delete(id);\n }\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { getTourController, subscribeTourRegistry, type TourSnapshot } from \"../tour-registry\";\n\nconst EMPTY_SNAPSHOT: TourSnapshot = {\n isActive: false,\n currentStepIndex: -1,\n currentStep: null,\n totalSteps: 0,\n};\n\nexport interface UseTourResult {\n startTour: () => void;\n nextStep: () => void;\n prevStep: () => void;\n skipTour: () => void;\n closeTour: () => void;\n currentStep: TourSnapshot[\"currentStep\"];\n currentStepIndex: number;\n totalSteps: number;\n isActive: boolean;\n}\n\nfunction readSnapshot(id: string): TourSnapshot {\n const controller = getTourController(id);\n if (!controller) return EMPTY_SNAPSHOT;\n return controller.getSnapshot();\n}\n\nexport function useTour(id: string): UseTourResult {\n const [snapshot, setSnapshot] = useState<TourSnapshot>(() => readSnapshot(id));\n\n useEffect(() => {\n let unsubscribeController: (() => void) | null = null;\n\n const bindController = (): void => {\n if (unsubscribeController) {\n unsubscribeController();\n unsubscribeController = null;\n }\n const controller = getTourController(id);\n if (!controller) {\n setSnapshot(EMPTY_SNAPSHOT);\n return;\n }\n setSnapshot(controller.getSnapshot());\n unsubscribeController = controller.subscribe(() => {\n setSnapshot(controller.getSnapshot());\n });\n };\n\n bindController();\n const unsubscribeRegistry = subscribeTourRegistry(id, bindController);\n return () => {\n unsubscribeRegistry();\n if (unsubscribeController) unsubscribeController();\n };\n }, [id]);\n\n const call = useCallback((method: keyof Omit<UseTourResult, \"currentStep\" | \"currentStepIndex\" | \"totalSteps\" | \"isActive\">) => {\n const controller = getTourController(id);\n if (!controller) return;\n controller[method]();\n }, [id]);\n\n return useMemo(\n () => ({\n startTour: () => call(\"startTour\"),\n nextStep: () => call(\"nextStep\"),\n prevStep: () => call(\"prevStep\"),\n skipTour: () => call(\"skipTour\"),\n closeTour: () => call(\"closeTour\"),\n currentStep: snapshot.currentStep,\n currentStepIndex: snapshot.currentStepIndex,\n totalSteps: snapshot.totalSteps,\n isActive: snapshot.isActive,\n }),\n [call, snapshot],\n );\n}\n","import { useCallback, useMemo, useState } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\nimport { getTourController } from \"../tour-registry\";\n\nexport interface TourSequenceItem {\n featureId: string;\n tourId: string;\n}\n\nexport interface UseTourSequencerResult {\n nextTourId: string | null;\n nextFeatureId: string | null;\n remainingTours: number;\n startNextTour: () => boolean;\n}\n\nexport function useTourSequencer(sequence: TourSequenceItem[]): UseTourSequencerResult {\n const {\n newFeatures,\n canShowTour,\n markTourShown,\n markFeatureSeen,\n } = useFeatureDrop();\n const [startedFeatureIds, setStartedFeatureIds] = useState<Set<string>>(new Set());\n\n const visibleFeatureIds = useMemo(\n () => new Set(newFeatures.map((feature) => feature.id)),\n [newFeatures],\n );\n\n const remaining = useMemo(\n () =>\n sequence.filter(\n (item) =>\n visibleFeatureIds.has(item.featureId) &&\n !startedFeatureIds.has(item.featureId),\n ),\n [sequence, startedFeatureIds, visibleFeatureIds],\n );\n\n const next = remaining[0] ?? null;\n\n const startNextTour = useCallback((): boolean => {\n if (!next) return false;\n if (!canShowTour()) return false;\n const controller = getTourController(next.tourId);\n if (!controller) return false;\n setStartedFeatureIds((previous) => {\n if (previous.has(next.featureId)) return previous;\n const updated = new Set(previous);\n updated.add(next.featureId);\n return updated;\n });\n markFeatureSeen(next.featureId);\n markTourShown();\n controller.startTour();\n return true;\n }, [canShowTour, markFeatureSeen, markTourShown, next]);\n\n return {\n nextTourId: next?.tourId ?? null,\n nextFeatureId: next?.featureId ?? null,\n remainingTours: remaining.length,\n startNextTour,\n };\n}\n","export interface ChecklistSnapshot {\n exists: boolean;\n tasks: Array<{ id: string; completed: boolean }>;\n progress: { completed: number; total: number; percent: number };\n isComplete: boolean;\n dismissed: boolean;\n collapsed: boolean;\n}\n\nexport interface ChecklistController {\n completeTask: (taskId: string) => void;\n resetChecklist: () => void;\n dismissChecklist: () => void;\n toggleCollapsed: () => void;\n getSnapshot: () => ChecklistSnapshot;\n subscribe: (listener: () => void) => () => void;\n}\n\nconst controllers = new Map<string, ChecklistController>();\nconst registryListeners = new Map<string, Set<() => void>>();\n\nfunction emitRegistry(id: string): void {\n const listeners = registryListeners.get(id);\n if (!listeners) return;\n for (const listener of listeners) listener();\n}\n\nexport function registerChecklistController(id: string, controller: ChecklistController): () => void {\n controllers.set(id, controller);\n emitRegistry(id);\n return () => {\n if (controllers.get(id) === controller) {\n controllers.delete(id);\n emitRegistry(id);\n }\n };\n}\n\nexport function getChecklistController(id: string): ChecklistController | undefined {\n return controllers.get(id);\n}\n\nexport function subscribeChecklistRegistry(id: string, listener: () => void): () => void {\n const listeners = registryListeners.get(id) ?? new Set<() => void>();\n listeners.add(listener);\n registryListeners.set(id, listeners);\n return () => {\n const current = registryListeners.get(id);\n if (!current) return;\n current.delete(listener);\n if (current.size === 0) registryListeners.delete(id);\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport {\n getChecklistController,\n subscribeChecklistRegistry,\n type ChecklistSnapshot,\n} from \"../checklist-registry\";\n\nconst EMPTY_SNAPSHOT: ChecklistSnapshot = {\n exists: false,\n tasks: [],\n progress: { completed: 0, total: 0, percent: 0 },\n isComplete: false,\n dismissed: false,\n collapsed: false,\n};\n\nexport interface UseChecklistResult {\n completeTask: (taskId: string) => void;\n resetChecklist: () => void;\n dismissChecklist: () => void;\n toggleCollapsed: () => void;\n isComplete: boolean;\n progress: { completed: number; total: number; percent: number };\n tasks: Array<{ id: string; completed: boolean }>;\n dismissed: boolean;\n collapsed: boolean;\n}\n\nfunction readSnapshot(id: string): ChecklistSnapshot {\n const controller = getChecklistController(id);\n if (!controller) return EMPTY_SNAPSHOT;\n return controller.getSnapshot();\n}\n\nexport function useChecklist(id: string): UseChecklistResult {\n const [snapshot, setSnapshot] = useState<ChecklistSnapshot>(() => readSnapshot(id));\n\n useEffect(() => {\n let unsubscribeController: (() => void) | null = null;\n\n const bind = (): void => {\n if (unsubscribeController) {\n unsubscribeController();\n unsubscribeController = null;\n }\n const controller = getChecklistController(id);\n if (!controller) {\n setSnapshot(EMPTY_SNAPSHOT);\n return;\n }\n setSnapshot(controller.getSnapshot());\n unsubscribeController = controller.subscribe(() => {\n setSnapshot(controller.getSnapshot());\n });\n };\n\n bind();\n const unsubscribeRegistry = subscribeChecklistRegistry(id, bind);\n return () => {\n unsubscribeRegistry();\n if (unsubscribeController) unsubscribeController();\n };\n }, [id]);\n\n const invoke = useCallback((method: \"completeTask\" | \"resetChecklist\" | \"dismissChecklist\" | \"toggleCollapsed\", arg?: string) => {\n const controller = getChecklistController(id);\n if (!controller) return;\n if (method === \"completeTask\") {\n controller.completeTask(arg ?? \"\");\n return;\n }\n controller[method]();\n }, [id]);\n\n return useMemo(\n () => ({\n completeTask: (taskId: string) => invoke(\"completeTask\", taskId),\n resetChecklist: () => invoke(\"resetChecklist\"),\n dismissChecklist: () => invoke(\"dismissChecklist\"),\n toggleCollapsed: () => invoke(\"toggleCollapsed\"),\n isComplete: snapshot.isComplete,\n progress: snapshot.progress,\n tasks: snapshot.tasks,\n dismissed: snapshot.dismissed,\n collapsed: snapshot.collapsed,\n }),\n [invoke, snapshot],\n );\n}\n","import type { SurveyType } from \"./components/survey\";\n\nexport interface SurveySnapshot {\n exists: boolean;\n isOpen: boolean;\n submitted: boolean;\n canShow: boolean;\n type: SurveyType;\n}\n\nexport interface SurveyController {\n show: (options?: { force?: boolean }) => boolean;\n hide: () => void;\n askLater: () => void;\n getSnapshot: () => SurveySnapshot;\n subscribe: (listener: () => void) => () => void;\n}\n\nconst controllers = new Map<string, SurveyController>();\nconst registryListeners = new Map<string, Set<() => void>>();\n\nfunction emitRegistry(id: string): void {\n const listeners = registryListeners.get(id);\n if (!listeners) return;\n for (const listener of listeners) listener();\n}\n\nexport function registerSurveyController(id: string, controller: SurveyController): () => void {\n controllers.set(id, controller);\n emitRegistry(id);\n return () => {\n if (controllers.get(id) === controller) {\n controllers.delete(id);\n emitRegistry(id);\n }\n };\n}\n\nexport function getSurveyController(id: string): SurveyController | undefined {\n return controllers.get(id);\n}\n\nexport function subscribeSurveyRegistry(id: string, listener: () => void): () => void {\n const listeners = registryListeners.get(id) ?? new Set<() => void>();\n listeners.add(listener);\n registryListeners.set(id, listeners);\n return () => {\n const current = registryListeners.get(id);\n if (!current) return;\n current.delete(listener);\n if (current.size === 0) {\n registryListeners.delete(id);\n }\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport {\n getSurveyController,\n subscribeSurveyRegistry,\n type SurveySnapshot,\n} from \"../survey-registry\";\nimport type { SurveyType } from \"../components/survey\";\n\nconst EMPTY_SNAPSHOT: SurveySnapshot = {\n exists: false,\n isOpen: false,\n submitted: false,\n canShow: false,\n type: \"custom\",\n};\n\nexport interface UseSurveyResult {\n show: (options?: { force?: boolean }) => boolean;\n hide: () => void;\n askLater: () => void;\n isOpen: boolean;\n submitted: boolean;\n canShow: boolean;\n type: SurveyType;\n}\n\nfunction readSnapshot(id: string): SurveySnapshot {\n const controller = getSurveyController(id);\n if (!controller) return EMPTY_SNAPSHOT;\n return controller.getSnapshot();\n}\n\nexport function useSurvey(id: string): UseSurveyResult {\n const [snapshot, setSnapshot] = useState<SurveySnapshot>(() => readSnapshot(id));\n\n useEffect(() => {\n let unsubscribeController: (() => void) | null = null;\n\n const bind = (): void => {\n if (unsubscribeController) {\n unsubscribeController();\n unsubscribeController = null;\n }\n const controller = getSurveyController(id);\n if (!controller) {\n setSnapshot(EMPTY_SNAPSHOT);\n return;\n }\n setSnapshot(controller.getSnapshot());\n unsubscribeController = controller.subscribe(() => {\n setSnapshot(controller.getSnapshot());\n });\n };\n\n bind();\n const unsubscribeRegistry = subscribeSurveyRegistry(id, bind);\n return () => {\n unsubscribeRegistry();\n if (unsubscribeController) unsubscribeController();\n };\n }, [id]);\n\n const show = useCallback((options?: { force?: boolean }): boolean => {\n const controller = getSurveyController(id);\n if (!controller) return false;\n return controller.show(options);\n }, [id]);\n\n const hide = useCallback(() => {\n getSurveyController(id)?.hide();\n }, [id]);\n\n const askLater = useCallback(() => {\n getSurveyController(id)?.askLater();\n }, [id]);\n\n return useMemo(\n () => ({\n show,\n hide,\n askLater,\n isOpen: snapshot.isOpen,\n submitted: snapshot.submitted,\n canShow: snapshot.canShow,\n type: snapshot.type,\n }),\n [askLater, hide, show, snapshot],\n );\n}\n","import { useCallback, useMemo } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\nimport type { FeatureEntry } from \"../../types\";\n\nexport interface UseChangelogResult {\n /** All features from the manifest (including non-new) */\n features: readonly FeatureEntry[];\n /** Only features that are currently \"new\" (unread) */\n newFeatures: readonly FeatureEntry[];\n /** Count of new/unread features */\n newCount: number;\n /** Sorted new features (critical first, then by date) */\n newFeaturesSorted: readonly FeatureEntry[];\n /** Dismiss a single feature by ID */\n dismiss: (id: string) => void;\n /** Dismiss all features at once */\n dismissAll: () => void;\n /** Check if a specific feature is new */\n isNew: (sidebarKey: string) => boolean;\n /** Mark all currently visible features as seen (advances watermark) */\n markAllSeen: () => void;\n /** Get features filtered by category */\n getByCategory: (category: string) => readonly FeatureEntry[];\n}\n\nexport function useChangelog(): UseChangelogResult {\n const ctx = useFeatureDrop();\n\n const markAllSeen = useCallback(() => {\n void ctx.dismissAll();\n }, [ctx]);\n\n const getByCategory = useCallback(\n (category: string): readonly FeatureEntry[] => {\n return ctx.newFeatures.filter((f) => f.category === category);\n },\n [ctx.newFeatures],\n );\n\n return useMemo(\n () => ({\n features: ctx.manifest,\n newFeatures: ctx.newFeatures,\n newCount: ctx.newCount,\n newFeaturesSorted: ctx.newFeaturesSorted,\n dismiss: ctx.dismiss,\n dismissAll: () => void ctx.dismissAll(),\n isNew: ctx.isNew,\n markAllSeen,\n getByCategory,\n }),\n [ctx.manifest, ctx.newFeatures, ctx.newCount, ctx.newFeaturesSorted, ctx.dismiss, ctx.dismissAll, ctx.isNew, markAllSeen, getByCategory],\n );\n}\n","import { useRef, useCallback } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\nimport type { DisplayFormat, FeatureEntry } from \"../../types\";\n\nexport interface UseSmartFeatureResult {\n /** Whether the engine recommends showing this feature now */\n show: boolean;\n /** Recommended display format */\n format: DisplayFormat;\n /** Fallback format if primary component isn't available */\n fallbackFormat: DisplayFormat;\n /** The feature entry from the manifest */\n feature: FeatureEntry | undefined;\n /** Dismiss the feature (also tracks dismissal in engine) */\n dismiss: () => void;\n /** Engine's confidence in this timing decision (0-1) */\n confidence: number;\n /** Reason for the timing decision */\n reason: string;\n}\n\n/**\n * Engine-powered smart feature display hook.\n *\n * Combines the TimingOptimizer and FormatSelector to decide\n * whether to show a feature and what format to use.\n *\n * Without an engine, gracefully degrades to always-show with badge format.\n *\n * @param featureId - The feature ID to check\n * @returns `{ show, format, fallbackFormat, feature, dismiss, confidence, reason }`\n *\n * @example\n * ```tsx\n * function MyFeature() {\n * const { show, format, feature, dismiss } = useSmartFeature('dark-mode')\n *\n * if (!show) return null\n *\n * switch (format) {\n * case 'badge': return <NewBadge id=\"dark-mode\" />\n * case 'toast': return <Toast feature={feature} onDismiss={dismiss} />\n * case 'modal': return <AnnouncementModal feature={feature} onDismiss={dismiss} />\n * default: return <NewBadge id=\"dark-mode\" />\n * }\n * }\n * ```\n */\nexport function useSmartFeature(featureId: string): UseSmartFeatureResult {\n const { engine, manifest, dismiss: providerDismiss } = useFeatureDrop();\n const sessionStartRef = useRef(Date.now());\n\n const feature = (manifest as FeatureEntry[]).find((f) => f.id === featureId);\n\n const dismiss = useCallback(() => {\n engine?.trackInteraction(featureId, \"dismissed\");\n providerDismiss(featureId);\n }, [engine, featureId, providerDismiss]);\n\n // No engine → always show with badge format (graceful degradation)\n if (!engine) {\n return {\n show: !!feature,\n format: \"badge\",\n fallbackFormat: \"inline\",\n feature,\n dismiss,\n confidence: 1.0,\n reason: \"no_engine\",\n };\n }\n\n const currentPath =\n typeof window !== \"undefined\" ? window.location.pathname : \"/\";\n const sessionAge = (Date.now() - sessionStartRef.current) / 1000;\n\n const timing = engine.shouldShow(featureId, {\n currentPath,\n sessionAge,\n recentDismissals: 0,\n featurePriority: feature?.priority ?? \"normal\",\n });\n\n const formatRec = engine.recommendFormat(featureId);\n\n return {\n show: timing.show,\n format: formatRec.primary,\n fallbackFormat: formatRec.fallback,\n feature,\n dismiss,\n confidence: timing.confidence,\n reason: timing.reason,\n };\n}\n","import { useMemo } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\nimport type { AdoptionScore } from \"../../types\";\n\nexport type UseAdoptionScoreResult = AdoptionScore;\n\nconst DEFAULT_SCORE: AdoptionScore = {\n score: 100,\n grade: \"A\",\n breakdown: {\n featuresExplored: 0,\n dismissRate: 0,\n completionRate: 0,\n engagementTrend: \"stable\",\n },\n recommendations: [],\n};\n\n/**\n * Get the user's overall feature adoption score.\n *\n * Returns a 0-100 score with letter grade, breakdown, and recommendations.\n * Useful for admin dashboards, debug panels, or gamification.\n *\n * Without an engine, returns a perfect score with no recommendations.\n *\n * @returns `{ score, grade, breakdown, recommendations }`\n *\n * @example\n * ```tsx\n * function AdoptionDashboard() {\n * const { score, grade, breakdown, recommendations } = useAdoptionScore()\n *\n * return (\n * <div>\n * <h2>Adoption Score: {score}/100 ({grade})</h2>\n * <p>Features explored: {Math.round(breakdown.featuresExplored * 100)}%</p>\n * <p>Completion rate: {Math.round(breakdown.completionRate * 100)}%</p>\n * <ul>\n * {recommendations.map((r, i) => <li key={i}>{r}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useAdoptionScore(): UseAdoptionScoreResult {\n const { engine } = useFeatureDrop();\n\n return useMemo(() => {\n if (!engine) return DEFAULT_SCORE;\n return engine.getAdoptionScore();\n }, [engine]);\n}\n","import { useMemo } from \"react\";\nimport { useFeatureDrop } from \"./use-feature-drop\";\nimport type { DisplayFormat } from \"../../types\";\n\nexport interface UseBehaviorProfileResult {\n /** Total sessions tracked */\n sessionCount: number;\n /** Dismiss rate (0-1) — fraction of announcements dismissed */\n dismissRate: number;\n /** Engagement rate (0-1) — fraction of announcements clicked/completed */\n engagementRate: number;\n /** User's preferred display format based on past behavior */\n preferredFormat: DisplayFormat;\n /** Whether an engine is available */\n hasEngine: boolean;\n}\n\nconst DEFAULT_PROFILE: UseBehaviorProfileResult = {\n sessionCount: 0,\n dismissRate: 0,\n engagementRate: 0,\n preferredFormat: \"badge\",\n hasEngine: false,\n};\n\n/**\n * Access the user's behavior profile for debug or admin views.\n *\n * Exposes aggregated behavior data from the AdoptionEngine's BehaviorTracker.\n * Without an engine, returns default values.\n *\n * @returns `{ sessionCount, dismissRate, engagementRate, preferredFormat, hasEngine }`\n *\n * @example\n * ```tsx\n * function DebugPanel() {\n * const { sessionCount, dismissRate, engagementRate, preferredFormat, hasEngine } = useBehaviorProfile()\n *\n * if (!hasEngine) return <p>No engine configured</p>\n *\n * return (\n * <div>\n * <p>Sessions: {sessionCount}</p>\n * <p>Dismiss rate: {(dismissRate * 100).toFixed(0)}%</p>\n * <p>Engagement rate: {(engagementRate * 100).toFixed(0)}%</p>\n * <p>Preferred format: {preferredFormat}</p>\n * </div>\n * )\n * }\n * ```\n */\nexport function useBehaviorProfile(): UseBehaviorProfileResult {\n const { engine } = useFeatureDrop();\n\n return useMemo(() => {\n if (!engine) return DEFAULT_PROFILE;\n\n // Access BehaviorTracker via the engine's public methods\n // The engine tracks interactions internally, so we derive profile data\n // from the engine's adoption scoring methods\n const score = engine.getAdoptionScore();\n\n return {\n sessionCount: 0, // Not directly exposed by FeatureDropEngine interface\n dismissRate: score.breakdown.dismissRate,\n engagementRate: 1 - score.breakdown.dismissRate,\n preferredFormat: \"badge\" as DisplayFormat, // Default — full profile requires AdoptionEngine\n hasEngine: true,\n };\n }, [engine]);\n}\n"]}
@@ -537,4 +537,120 @@ interface UseChangelogResult {
537
537
  }
538
538
  declare function useChangelog(): UseChangelogResult;
539
539
 
540
- export { type TourSequenceItem, type UseChangelogResult, type UseChecklistResult, type UseNewFeatureResult, type UseSurveyResult, type UseTabNotificationOptions, type UseTourResult, type UseTourSequencerResult, useAdoptionAnalytics, useChangelog, useChecklist, useFeatureDrop, useNewCount, useNewFeature, useSurvey, useTabNotification, useTour, useTourSequencer };
540
+ interface UseSmartFeatureResult {
541
+ /** Whether the engine recommends showing this feature now */
542
+ show: boolean;
543
+ /** Recommended display format */
544
+ format: DisplayFormat;
545
+ /** Fallback format if primary component isn't available */
546
+ fallbackFormat: DisplayFormat;
547
+ /** The feature entry from the manifest */
548
+ feature: FeatureEntry | undefined;
549
+ /** Dismiss the feature (also tracks dismissal in engine) */
550
+ dismiss: () => void;
551
+ /** Engine's confidence in this timing decision (0-1) */
552
+ confidence: number;
553
+ /** Reason for the timing decision */
554
+ reason: string;
555
+ }
556
+ /**
557
+ * Engine-powered smart feature display hook.
558
+ *
559
+ * Combines the TimingOptimizer and FormatSelector to decide
560
+ * whether to show a feature and what format to use.
561
+ *
562
+ * Without an engine, gracefully degrades to always-show with badge format.
563
+ *
564
+ * @param featureId - The feature ID to check
565
+ * @returns `{ show, format, fallbackFormat, feature, dismiss, confidence, reason }`
566
+ *
567
+ * @example
568
+ * ```tsx
569
+ * function MyFeature() {
570
+ * const { show, format, feature, dismiss } = useSmartFeature('dark-mode')
571
+ *
572
+ * if (!show) return null
573
+ *
574
+ * switch (format) {
575
+ * case 'badge': return <NewBadge id="dark-mode" />
576
+ * case 'toast': return <Toast feature={feature} onDismiss={dismiss} />
577
+ * case 'modal': return <AnnouncementModal feature={feature} onDismiss={dismiss} />
578
+ * default: return <NewBadge id="dark-mode" />
579
+ * }
580
+ * }
581
+ * ```
582
+ */
583
+ declare function useSmartFeature(featureId: string): UseSmartFeatureResult;
584
+
585
+ type UseAdoptionScoreResult = AdoptionScore;
586
+ /**
587
+ * Get the user's overall feature adoption score.
588
+ *
589
+ * Returns a 0-100 score with letter grade, breakdown, and recommendations.
590
+ * Useful for admin dashboards, debug panels, or gamification.
591
+ *
592
+ * Without an engine, returns a perfect score with no recommendations.
593
+ *
594
+ * @returns `{ score, grade, breakdown, recommendations }`
595
+ *
596
+ * @example
597
+ * ```tsx
598
+ * function AdoptionDashboard() {
599
+ * const { score, grade, breakdown, recommendations } = useAdoptionScore()
600
+ *
601
+ * return (
602
+ * <div>
603
+ * <h2>Adoption Score: {score}/100 ({grade})</h2>
604
+ * <p>Features explored: {Math.round(breakdown.featuresExplored * 100)}%</p>
605
+ * <p>Completion rate: {Math.round(breakdown.completionRate * 100)}%</p>
606
+ * <ul>
607
+ * {recommendations.map((r, i) => <li key={i}>{r}</li>)}
608
+ * </ul>
609
+ * </div>
610
+ * )
611
+ * }
612
+ * ```
613
+ */
614
+ declare function useAdoptionScore(): UseAdoptionScoreResult;
615
+
616
+ interface UseBehaviorProfileResult {
617
+ /** Total sessions tracked */
618
+ sessionCount: number;
619
+ /** Dismiss rate (0-1) — fraction of announcements dismissed */
620
+ dismissRate: number;
621
+ /** Engagement rate (0-1) — fraction of announcements clicked/completed */
622
+ engagementRate: number;
623
+ /** User's preferred display format based on past behavior */
624
+ preferredFormat: DisplayFormat;
625
+ /** Whether an engine is available */
626
+ hasEngine: boolean;
627
+ }
628
+ /**
629
+ * Access the user's behavior profile for debug or admin views.
630
+ *
631
+ * Exposes aggregated behavior data from the AdoptionEngine's BehaviorTracker.
632
+ * Without an engine, returns default values.
633
+ *
634
+ * @returns `{ sessionCount, dismissRate, engagementRate, preferredFormat, hasEngine }`
635
+ *
636
+ * @example
637
+ * ```tsx
638
+ * function DebugPanel() {
639
+ * const { sessionCount, dismissRate, engagementRate, preferredFormat, hasEngine } = useBehaviorProfile()
640
+ *
641
+ * if (!hasEngine) return <p>No engine configured</p>
642
+ *
643
+ * return (
644
+ * <div>
645
+ * <p>Sessions: {sessionCount}</p>
646
+ * <p>Dismiss rate: {(dismissRate * 100).toFixed(0)}%</p>
647
+ * <p>Engagement rate: {(engagementRate * 100).toFixed(0)}%</p>
648
+ * <p>Preferred format: {preferredFormat}</p>
649
+ * </div>
650
+ * )
651
+ * }
652
+ * ```
653
+ */
654
+ declare function useBehaviorProfile(): UseBehaviorProfileResult;
655
+
656
+ export { type TourSequenceItem, type UseAdoptionScoreResult, type UseBehaviorProfileResult, type UseChangelogResult, type UseChecklistResult, type UseNewFeatureResult, type UseSmartFeatureResult, type UseSurveyResult, type UseTabNotificationOptions, type UseTourResult, type UseTourSequencerResult, useAdoptionAnalytics, useAdoptionScore, useBehaviorProfile, useChangelog, useChecklist, useFeatureDrop, useNewCount, useNewFeature, useSmartFeature, useSurvey, useTabNotification, useTour, useTourSequencer };
@@ -537,4 +537,120 @@ interface UseChangelogResult {
537
537
  }
538
538
  declare function useChangelog(): UseChangelogResult;
539
539
 
540
- export { type TourSequenceItem, type UseChangelogResult, type UseChecklistResult, type UseNewFeatureResult, type UseSurveyResult, type UseTabNotificationOptions, type UseTourResult, type UseTourSequencerResult, useAdoptionAnalytics, useChangelog, useChecklist, useFeatureDrop, useNewCount, useNewFeature, useSurvey, useTabNotification, useTour, useTourSequencer };
540
+ interface UseSmartFeatureResult {
541
+ /** Whether the engine recommends showing this feature now */
542
+ show: boolean;
543
+ /** Recommended display format */
544
+ format: DisplayFormat;
545
+ /** Fallback format if primary component isn't available */
546
+ fallbackFormat: DisplayFormat;
547
+ /** The feature entry from the manifest */
548
+ feature: FeatureEntry | undefined;
549
+ /** Dismiss the feature (also tracks dismissal in engine) */
550
+ dismiss: () => void;
551
+ /** Engine's confidence in this timing decision (0-1) */
552
+ confidence: number;
553
+ /** Reason for the timing decision */
554
+ reason: string;
555
+ }
556
+ /**
557
+ * Engine-powered smart feature display hook.
558
+ *
559
+ * Combines the TimingOptimizer and FormatSelector to decide
560
+ * whether to show a feature and what format to use.
561
+ *
562
+ * Without an engine, gracefully degrades to always-show with badge format.
563
+ *
564
+ * @param featureId - The feature ID to check
565
+ * @returns `{ show, format, fallbackFormat, feature, dismiss, confidence, reason }`
566
+ *
567
+ * @example
568
+ * ```tsx
569
+ * function MyFeature() {
570
+ * const { show, format, feature, dismiss } = useSmartFeature('dark-mode')
571
+ *
572
+ * if (!show) return null
573
+ *
574
+ * switch (format) {
575
+ * case 'badge': return <NewBadge id="dark-mode" />
576
+ * case 'toast': return <Toast feature={feature} onDismiss={dismiss} />
577
+ * case 'modal': return <AnnouncementModal feature={feature} onDismiss={dismiss} />
578
+ * default: return <NewBadge id="dark-mode" />
579
+ * }
580
+ * }
581
+ * ```
582
+ */
583
+ declare function useSmartFeature(featureId: string): UseSmartFeatureResult;
584
+
585
+ type UseAdoptionScoreResult = AdoptionScore;
586
+ /**
587
+ * Get the user's overall feature adoption score.
588
+ *
589
+ * Returns a 0-100 score with letter grade, breakdown, and recommendations.
590
+ * Useful for admin dashboards, debug panels, or gamification.
591
+ *
592
+ * Without an engine, returns a perfect score with no recommendations.
593
+ *
594
+ * @returns `{ score, grade, breakdown, recommendations }`
595
+ *
596
+ * @example
597
+ * ```tsx
598
+ * function AdoptionDashboard() {
599
+ * const { score, grade, breakdown, recommendations } = useAdoptionScore()
600
+ *
601
+ * return (
602
+ * <div>
603
+ * <h2>Adoption Score: {score}/100 ({grade})</h2>
604
+ * <p>Features explored: {Math.round(breakdown.featuresExplored * 100)}%</p>
605
+ * <p>Completion rate: {Math.round(breakdown.completionRate * 100)}%</p>
606
+ * <ul>
607
+ * {recommendations.map((r, i) => <li key={i}>{r}</li>)}
608
+ * </ul>
609
+ * </div>
610
+ * )
611
+ * }
612
+ * ```
613
+ */
614
+ declare function useAdoptionScore(): UseAdoptionScoreResult;
615
+
616
+ interface UseBehaviorProfileResult {
617
+ /** Total sessions tracked */
618
+ sessionCount: number;
619
+ /** Dismiss rate (0-1) — fraction of announcements dismissed */
620
+ dismissRate: number;
621
+ /** Engagement rate (0-1) — fraction of announcements clicked/completed */
622
+ engagementRate: number;
623
+ /** User's preferred display format based on past behavior */
624
+ preferredFormat: DisplayFormat;
625
+ /** Whether an engine is available */
626
+ hasEngine: boolean;
627
+ }
628
+ /**
629
+ * Access the user's behavior profile for debug or admin views.
630
+ *
631
+ * Exposes aggregated behavior data from the AdoptionEngine's BehaviorTracker.
632
+ * Without an engine, returns default values.
633
+ *
634
+ * @returns `{ sessionCount, dismissRate, engagementRate, preferredFormat, hasEngine }`
635
+ *
636
+ * @example
637
+ * ```tsx
638
+ * function DebugPanel() {
639
+ * const { sessionCount, dismissRate, engagementRate, preferredFormat, hasEngine } = useBehaviorProfile()
640
+ *
641
+ * if (!hasEngine) return <p>No engine configured</p>
642
+ *
643
+ * return (
644
+ * <div>
645
+ * <p>Sessions: {sessionCount}</p>
646
+ * <p>Dismiss rate: {(dismissRate * 100).toFixed(0)}%</p>
647
+ * <p>Engagement rate: {(engagementRate * 100).toFixed(0)}%</p>
648
+ * <p>Preferred format: {preferredFormat}</p>
649
+ * </div>
650
+ * )
651
+ * }
652
+ * ```
653
+ */
654
+ declare function useBehaviorProfile(): UseBehaviorProfileResult;
655
+
656
+ export { type TourSequenceItem, type UseAdoptionScoreResult, type UseBehaviorProfileResult, type UseChangelogResult, type UseChecklistResult, type UseNewFeatureResult, type UseSmartFeatureResult, type UseSurveyResult, type UseTabNotificationOptions, type UseTourResult, type UseTourSequencerResult, useAdoptionAnalytics, useAdoptionScore, useBehaviorProfile, useChangelog, useChecklist, useFeatureDrop, useNewCount, useNewFeature, useSmartFeature, useSurvey, useTabNotification, useTour, useTourSequencer };