Skip to content

fix(core): make callbacks config optional#36

Open
vklimontovich wants to merge 2 commits into
mainfrom
fix/optional-callbacks
Open

fix(core): make callbacks config optional#36
vklimontovich wants to merge 2 commits into
mainfrom
fix/optional-callbacks

Conversation

@vklimontovich
Copy link
Copy Markdown
Collaborator

Summary

  • Nextlytics({ backends: [...] }) without callbacks crashed with
    TypeError: Cannot read properties of undefined (reading 'getUser')
  • The README and quickstart present callbacks as optional, but the type required it and withDefaults did not provide a default. server.tsx and api-handler.ts dereferenced undefined.
  • Mark callbacks optional on NextlyticsConfig, default it to {} in withDefaults, and add a small regression test.

Found while running an external e2e (Next 15 + Next 16 apps using postgrestBackend) — events stopped landing in the destination until I added callbacks: {} to the config.

Test plan

  • bun run typecheck passes
  • bun run test passes (new config-helpers.test.ts locks the behavior)
  • Manually re-ran the minimal quickstart config (no callbacks field) — middleware now dispatches and events arrive at PostgREST

Crash on `Nextlytics({ backends: [...] })` without `callbacks`:
`TypeError: Cannot read properties of undefined (reading 'getUser')`.
README and quickstart treat callbacks as optional, but the type required
it and `withDefaults` did not provide a default, so `server.tsx` and
`api-handler.ts` dereferenced `undefined`.

- Mark `callbacks` optional on `NextlyticsConfig`.
- Default it to `{}` in `withDefaults` so internal access stays simple.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant