PhoenixKit 2.2.0: Notifications that update in place, and a quieter session log
PhoenixKit 2.2.0 lets modules refresh an unread notification when the same thing happens again, instead of adding one more beside it. It also makes the session fingerprint lines in the log worth reading, and warns when module JavaScript hooks will never load.
Notifications that update in place
A new function, Notifications.upsert_inapp/3, takes a key. When a notification with the same key is still unseen, a repeat event refreshes it, so a user reads “3 new comments” once instead of three separate notifications. Once the user has seen it, the next event gets a new notification, so nothing new is hidden inside something already read. An open notification bell updates by itself, whether the notification was refreshed or new.
Two cases where updating could go wrong are handled: a notification deleted between the lookup and the write is replaced with its key kept, so later events still find it, and one the user read or dismissed in that moment is left alone, with the event getting its own notification. create_inapp/2 now also keeps a caller’s :dedupe_key and :metadata, which it dropped before.
A session log worth reading
PhoenixKit compares each session with the browser it started in. Browsers change their user agent string with every update, so one site logged 765 warnings of this kind. A changed user agent with the same IP address is now logged at info level. Every line names its session with a short hash of the token, never the token itself, and a duplicate line that named nothing is gone.
The level now follows what happens to the request. In strict mode, where every mismatch signs the user out, each one is logged as an error saying access was denied. Otherwise the request is served and the line gets a lower level, instead of an error about a possible hijacking for a request that went through.
A warning for hooks that never load
Modules can ship JavaScript hooks, which only reach the browser through the :phoenix_kit_js_sources compiler. A site without that compiler in :compilers got no bundle and no error, and the module’s pages used hooks the browser never had. The build now prints a warning naming the fix. It does not fail a build run with --warnings-as-errors.
Upgrading
No migration. Update the dependency. If the build prints the hooks warning, add :phoenix_kit_js_sources to compilers: in your mix.exs.
Full release notes: PhoenixKit 2.2.0
2.2.0 · 11 August 2026
Notification collapsing, an honest fingerprint log, and a compile-time warning for a silent JS-hook misconfiguration. No schema change — the chain stays at V166.
Added
-
Notifications.upsert_inapp/3(#704) — the GitHub-style collapsing entry. A repeat event refreshes the row already standing for the same key (“3 new comments on earlier chapters”) instead of posting another beside it. Only unseen rows collapse: once someone has read a notification the next event is news again and gets its own row, so nothing new can be hidden inside something already dealt with. Broadcasts{:notification_updated, n}for a refresh and{:notification_created, n}for a new row, so an open bell keeps up without the caller broadcasting anything. Doing this before meant querying the schema directly and re-broadcasting by hand — one host that tried it schemalessly stringifiedmetadatainto the jsonb column and 500’d that user’s bell.create_inapp/2now also carries:dedupe_keyand merges a caller’s:metadata; both were dropped silently before. -
A compile-time warning when installed modules ship JS hooks the host will never load (#703).
js_sources/0is consumed only by the:phoenix_kit_js_sourcescompiler; a host without it in:compilersgot no bundle, no error and no warning, while the module’s templates went on renderingphx-hooknames the LiveSocket had never heard of.phoenix_kit_boardsshipped that state twice before anyone traced it. Silent when the compiler is present and when nothing declares a bundle.
Changed
-
The session-fingerprint log says something worth reading (#705). A user-agent change with an unchanged IP is
:info, not:warning— browsers rewrite their UA roughly monthly, for every user, and one reporting app carried 765 of these in a single log. Every line now names its session (a truncated SHA-256 of the token; the raw token is a bearer credential and never reaches the log), and the duplicate line inPhoenixKitWeb.Users.Auththat said only"for token", naming no token, is gone. -
A mismatch is logged at the level its consequence earns. Strict mode refuses every fingerprint mismatch, so under strict mode all of them log at
:errorand sayaccess denied; otherwise the request is served and the line takes its own severity. Logging “possible hijacking attempt” at:errorand then serving the request is what taught people the log was noise — and the inverse was just as bad: a strict-mode host logging someone out over a browser update recorded it at:info, below the default threshold, so there was no record at all.
Fixed
-
upsert_inapp/3could silently stop collapsing forever. When the row vanished between the read and the write, the replacement was posted without its dedupe key, so it could never be found again and every later event for that key opened a new row. -
upsert_inapp/3could lose an event to a row the user had just dealt with. Theupdate_allfiltered onuuidalone, so a comment dismissed or read between the read and the write was refreshed anyway: the update reported success and the event ended up recorded only on a row that would never be shown again. The unseen/undismissed guard now appears in the write as well as the read. -
The JS-hook warning no longer breaks the build. It was emitted with
IO.warn/1, which registers a compiler diagnostic — so on any host building with--warnings-as-errorsit failed the compile on upgrade, over a mix.exs condition that was not a regression in the host’s own code.
PhoenixKit 2.2.0. Install or update: {:phoenix_kit, "~> 2.2"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.