Log salts hash (#5401)

* log salts hash

* cleanup
This commit is contained in:
ruslandoga 2025-05-21 10:19:23 +03:00 committed by GitHub
parent 5495947c8d
commit 811a0f049a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
defmodule Plausible.Session.Salts do
use GenServer
use Plausible.Repo
require Logger
def start_link(opts) do
GenServer.start_link(__MODULE__, opts, name: opts[:name] || __MODULE__)
@ -26,9 +27,11 @@ defmodule Plausible.Session.Salts do
state =
case salts do
[current, prev] ->
Logger.notice("[salts] current salt hash: #{:erlang.phash2(current)}")
%{previous: prev, current: current}
[current] ->
Logger.notice("[salts] current salt hash: #{:erlang.phash2(current)}")
%{previous: nil, current: current}
[] ->
@ -67,7 +70,7 @@ defmodule Plausible.Session.Salts do
defp generate_and_persist_new_salt(now) do
salt = :crypto.strong_rand_bytes(16)
Logger.notice("[salts] generated salt hash: #{:erlang.phash2(salt)}")
Repo.insert_all("salts", [%{salt: salt, inserted_at: now}])
salt
end