> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# PF-37 Phase 2 & 3: Gesture Preferences, Analytics, Advanced Gestures — Integration

> Status: ✅ Complete — 2026-03-05 Spec Reference: PF-37 Phase 2 & 3 Expansion Parent: PF-37 Mobile Swipe Gestures Last Updated: 2026-03-04

# Phase 2 & 3: Gesture Preferences, Analytics, Advanced Gestures — Integration

**Status:** ✅ Complete — 2026-03-05\
**Spec Reference:** [PF-37 Phase 2 & 3 Expansion](../../../specs/pf/specs/PF-37-PHASE-2-3-EXPANSION.md)\
**Parent:** [PF-37 Mobile Swipe Gestures](../../../specs/pf/specs/PF-37-mobile-swipe-gestures.md)\
**Last Updated:** 2026-03-04

***

## Purpose

PF-37 Phase 2 adds user gesture preferences (sensitivity, haptic, per-gesture toggles) and gesture usage analytics. Phase 3 adds pinch-to-zoom, multi-touch, and custom gesture recognition. This document captures integration points: dependencies consumed by PF-37 Phase 2/3 and the platform layer consumed by other cores.

***

## PF Dependencies (Consumed by PF-37 Phase 2/3)

| Dependency                      | Use                                                                                | Type                 |
| ------------------------------- | ---------------------------------------------------------------------------------- | -------------------- |
| PF-37 Phase 1                   | Core gesture system (swipe-to-dismiss, swipe-actions, pull-to-refresh, edge-swipe) | Same spec / platform |
| PF-06 (User Profile Management) | `pf_profiles.preferences` JSONB for `preferences.gestures`                         | Data                 |
| Settings Hub                    | Add "Gestures" card and route `/settings/gestures`, `/settings/gestures/analytics` | Platform UI          |
| PF-11 (Document Management)     | Document/PDF viewer integration for ZoomableImage / pinch-to-zoom (Phase 3)        | Platform integration |
| PF-09 (Form Analytics)          | Batching pattern reference for gesture analytics (queue + flush)                   | Pattern              |

***

## Platform Integration Layer

**Location:** `/src/platform/gestures/` (existing); settings pages in `/src/platform/settings/`\
**Import path:** `@/platform/gestures`, `@/platform/settings`\
**Status:** ✅ Complete — 2026-03-05

### Public API (Phase 2 — from spec)

| API                                                          | Type    | Description                                                            |
| ------------------------------------------------------------ | ------- | ---------------------------------------------------------------------- |
| `useGesturePreferences()`                                    | Hook    | Read/write gesture preferences from `pf_profiles.preferences.gestures` |
| `useHapticFeedback()`                                        | Hook    | Trigger haptic patterns (success, error, warning) per user settings    |
| `useGestureAnalytics(options?)`                              | Hook    | Aggregate gesture usage and success rate for current user              |
| `trackGestureEvent(userId, orgId, type, success, metadata?)` | Utility | Record analytics event (callers pass context; batched client-side)     |

### Public API (Phase 3 — from spec)

| API                                     | Type      | Description                                                  |
| --------------------------------------- | --------- | ------------------------------------------------------------ |
| `usePinchToZoom(options)`               | Hook      | Pinch-to-zoom and pan bindings; zoom limits, double-tap zoom |
| `useMultiTouch(options)`                | Hook      | Two-finger swipe/rotate; configurable per component          |
| `useCustomGesture(options)`             | Hook      | Register custom gesture pattern and action                   |
| `ZoomableImage` / `ZoomableImageViewer` | Component | Image with pinch-to-zoom and pan                             |

### Consumer Cores

* **All cores** that use gesture-enabled components (e.g. swipe-to-dismiss lists, pull-to-refresh) automatically benefit from Phase 2 preferences and analytics when they use `@/platform/gestures` hooks.
* **Document/image viewers:** PF-11, CL, PM, or any core with image/PDF preview consumes `ZoomableImage` / `ZoomableImageViewer` for Phase 3.

***

## Event Contracts

PF-37 Phase 2/3 does not publish domain events. Analytics are written to `pf_gesture_analytics_events`; retention job (scheduled) deletes events older than 90 days.

***

## API Contracts

No REST or edge API for gesture preferences or analytics. All access is via React hooks and utilities above. RLS on `pf_gesture_analytics_events` and `pf_profiles` enforces tenant and user isolation.

***

## Integration Matrix

* **CROSS\_CORE\_INTEGRATIONS.md:** PF-37 Phase 2/3 → PF-06, Settings Hub, PF-11 (Phase 3); Platform Layer (gestures) consumed by all cores. See matrix row added for this doc.

***

## See Also

* [PF-37 Mobile Swipe Gestures](../../../specs/pf/specs/PF-37-mobile-swipe-gestures.md) — Parent spec
* [PF-06 User Profile Management](../../../specs/pf/specs/PF-06-user-profile-management.md) — Preferences storage
* [PF-09 Form Analytics](../../../specs/pf/specs/PF-09-form-analytics.md) — Batching pattern
* [PLATFORM\_INTEGRATION\_LAYERS.md](./PLATFORM_INTEGRATION_LAYERS.md) — PF-37 Gestures Integration Layer
