Task/n04 02 01 engagement sessions table#225
Closed
Piedra-1988 wants to merge 29 commits into
Closed
Conversation
…t-comments-schema
…ents-schema feat(db): align post_comments schema with N03 spec — body CHECK + pag…
…mments-ui feat(comments): mobile UI to create/list post comments (paginated) — …
test(rls): add post_comments INSERT-negative case + align ADR-002 pol…
feat(comments): post comment count aggregate + finalize RLS moderation
…ng-ui feat(ratings): add StarRating UI with optimistic idempotent upsert (#169)
…ratings feat(ratings): formalize post_ratings RLS policy names to _own (#168)
feat(ratings): show post rating average in the feed (#159)
…k-register feat(engagement): track link_clicked before opening external link (#170)
Detecta lectura real de un post combinando AppState, foco de navegación (useIsFocused) y scroll: - sessionId estable por sesión de lectura (expo-crypto randomUUID). - focusedSeconds solo avanza mientras app en primer plano y pantalla enfocada. - maxScrollPct monótono en [0,1] desde onScroll. - heartbeat de 5s que emite init/tick a un sink inyectable (opts.onEvent); la cola offline real llega en I-F-N04-01-02. - cleanup de timer y listener de AppState en unmount. Closes #176 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…engagement feat(engagement): hook usePostEngagement (#176)
Cola FIFO persistente que entrega los eventos de usePostEngagement a la Edge Function track-engagement, sobreviviendo a caídas de red y cierres de app: - lib/engagement/queue.ts: enqueue/flush/size sobre AsyncStorage (@engagement/queue), cap de 500 con descarte FIFO + dropped_count, envío en lotes de ≤50 vía fetch, backoff exponencial 1s→30s, 401 → refresh de sesión + 1 reintento, 4xx → descarte. - lib/engagement/sink.ts: adaptador de EngagementEvent (focusedSeconds acumulado) a EngagementPayload del servidor (focused_seconds_delta). - lib/engagement/sync.ts: flush() al recuperar conectividad (NetInfo). - lib/engagement.ts → lib/engagement/index.ts (conserva trackLinkClick + re-exports). - jest.setup.ts: mocks globales de AsyncStorage y NetInfo. Añade @react-native-async-storage/async-storage y @react-native-community/netinfo. El cableado en la pantalla y el consumo del nuevo payload (Edge Function/DB) quedan para issues posteriores (integración y N04-02-02). Closes #177 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s-offline-queue feat(engagement): heartbeats + cola offline (#177)
…lient feat(engagement): wire post engagement tracking into UI (#173)
…del (#178) Sustituye el modelo (user_id, post_id)/link_clicked de ADR-001 por uno por sesión de lectura: 1 fila por session_id con focused_seconds, max_scroll_pct y state (viewed → skimmed → read). - migración 20260710000000: dropea la tabla anterior y recrea engagement_sessions (session_id PK, FK post_id/user_id on delete cascade, CHECK en focused_seconds y max_scroll_pct, enum engagement_state, índices, trigger updated_at, enable RLS + grant select). - schema_engagement_sessions.sql: tests pgTAP de estructura, constraints, upsert por session_id y cascades (post y perfil). - rls_engagement_sessions.sql: reemplazado por test de default-deny (las policies reales llegan en EPIC-S00). - ADR-0003 (reading sessions) supersede ADR-001; database.types.ts actualizado al nuevo esquema + enum engagement_state. Alcance: solo tabla + RLS enable + tests SQL. La Edge Function track-engagement queda incoherente hasta #179; policies RLS en EPIC-S00. FK user_id -> profiles(id): #179 y EPIC-S00 deben mapear auth.uid() -> profiles.id. supabase db reset + pgTAP: 144 tests PASS. typecheck + lint en verde. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Surround lists with blank lines (blanks-around-lists) so the ADR markdown lint CI check passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Se rechaza PR porque la información de la Epic no es correcta para su implementación. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(engagement): replace engagement_sessions with reading-session model (#178)
Sustituye el modelo (user_id, post_id)/link_clicked de ADR-001 por uno
por sesión de lectura: 1 fila por session_id con focused_seconds,
max_scroll_pct y state (viewed → skimmed → read).
engagement_sessions (session_id PK, FK post_id/user_id on delete cascade,
CHECK en focused_seconds y max_scroll_pct, enum engagement_state,
índices, trigger updated_at, enable RLS + grant select).
upsert por session_id y cascades (post y perfil).
(las policies reales llegan en EPIC-S00).
actualizado al nuevo esquema + enum engagement_state.
Alcance: solo tabla + RLS enable + tests SQL. La Edge Function
track-engagement queda incoherente hasta #179; policies RLS en EPIC-S00.
FK user_id -> profiles(id): #179 y EPIC-S00 deben mapear auth.uid() -> profiles.id.
supabase db reset + pgTAP: 144 tests PASS. typecheck + lint en verde.