Skip to content

enhance: add audit logging from UI and more logging from auth#4946

Draft
rschlaefli wants to merge 6 commits into
audit-logfrom
audit-log-ui
Draft

enhance: add audit logging from UI and more logging from auth#4946
rschlaefli wants to merge 6 commits into
audit-logfrom
audit-log-ui

Conversation

@rschlaefli

@rschlaefli rschlaefli commented Sep 29, 2025

Copy link
Copy Markdown
Member
  • TODO: add fallback for frontend audit logs when audit log service is not reachable -> send directly to backend and pass into hatchet, which can retry

ClickUp Links

This was generated by AI during triage.

@coderabbitai

coderabbitai Bot commented Sep 29, 2025

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4cde6f85-aefe-4a72-b037-ddadc9600fa4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rschlaefli rschlaefli changed the title Audit log UI enhance: add audit logging from UI and more logging from auth Sep 29, 2025
Review of PR #4946 with evidence (file:line), findings on frontend
behavior regressions, event delivery/fallback, i18n, and auth flow
latency, plus ordered instructions to finish the PR.
@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

The assessment autosave path, page remount behavior, and auth login audit flush need fixes before merging.

  • Active answer editing can keep restarting the autosave timer.
  • Query-only route changes can remount full pages and discard local state.
  • Participant login now waits on best-effort audit network retries.

apps/frontend-pwa/src/components/liveQuiz/QuestionArea.tsx, apps/frontend-pwa/src/pages/_app.tsx, apps/auth/src/lib/helpers.ts

Important Files Changed

Filename Overview
apps/auth/src/lib/helpers.ts Adds invitation audit event collection and flushes it after participant create/link transactions.
apps/frontend-pwa/src/components/liveQuiz/QuestionArea.tsx Adds assessment audit events around quiz participation, answer updates, and submissions.
apps/frontend-pwa/src/pages/_app.tsx Adds global client error audit logging and wraps assessment pages in an error boundary.
apps/frontend-pwa/src/components/common/AssessmentErrorBoundary.tsx Adds a React error boundary with reset support for assessment mode.
apps/frontend-pwa/src/components/liveQuiz/storageHelpers.ts Adds an optional callback that reports loaded local response details.
packages/shared-components/src/hooks/useAuditClient.ts Filters top-level undefined fields from audit event request bodies.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
  participant Student
  participant QuestionArea
  participant LocalForage
  participant AuditHook
  participant AuditService
  Student->>QuestionArea: Edit answer
  QuestionArea->>QuestionArea: Re-render
  QuestionArea->>QuestionArea: Clear and recreate 10s interval
  Note over QuestionArea,LocalForage: Frequent renders can keep the timer from firing
  QuestionArea--xLocalForage: Draft save delayed or skipped
  QuestionArea--xAuditService: Update audit event delayed or skipped
  Student->>QuestionArea: Submit answer
  QuestionArea->>AuditHook: Send submit audit event
  AuditHook->>AuditService: Fire-and-forget request
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
  participant Student
  participant QuestionArea
  participant LocalForage
  participant AuditHook
  participant AuditService
  Student->>QuestionArea: Edit answer
  QuestionArea->>QuestionArea: Re-render
  QuestionArea->>QuestionArea: Clear and recreate 10s interval
  Note over QuestionArea,LocalForage: Frequent renders can keep the timer from firing
  QuestionArea--xLocalForage: Draft save delayed or skipped
  QuestionArea--xAuditService: Update audit event delayed or skipped
  Student->>QuestionArea: Submit answer
  QuestionArea->>AuditHook: Send submit audit event
  AuditHook->>AuditService: Fire-and-forget request
Loading

Fix All in Codex Fix All in Claude Code

Reviews (1): Last reviewed commit: "docs(project): add review for UI/auth au..." | Re-trigger Greptile

Comment on lines +260 to +267
}, [
auditLog,
currentInstance,
execution,
isAssessmentMode,
isStaticPreview,
quizId,
])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Autosave Timer Keeps Restarting

When a participant edits an answer, QuestionArea re-renders and useAuditClient() supplies a new wrapper object for auditLog. Because this effect depends on that object, it clears and recreates the 10-second interval on each render, so active typing can prevent temporary response saves and answer-update audit events from ever firing.

Fix in Codex Fix in Claude Code

? (locale as (typeof routing.locales)[number])
: routing.defaultLocale

const pageComponent = <Component key={router.asPath} {...pageProps} />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Query Changes Remount Pages

router.asPath includes the query string, so any router.push or router.replace that changes a query parameter gives the page a new key. That unmounts and remounts the whole page tree, which can drop local assessment state such as in-progress quiz answers, scroll position, and mounted refs even though the user stayed on the same page.

Fix in Codex Fix in Claude Code

// Ensure the transaction returns the participant for the caller
return participant
})
await flushAuditEvents(invitationAuditEvents)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Audit Service Delays Login

This awaits best-effort audit delivery in the participant sign-in path after the transaction has already committed. If the audit service is slow or unreachable, AuditClient.log() retries with network timeouts before NextAuth can finish the Edu-ID login, so a degraded audit service can make successful participant logins hang or time out.

Fix in Codex Fix in Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant