Closed burhan-syed closed 1 year ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated (UTC) |
---|---|---|---|
troddit | ✅ Ready (Inspect) | Visit Preview | Jun 5, 2023 1:50am |
I signed up to Supabase buti keep getting 500 error
İ have setup the env like this
DATABASE_URL: db.jnxneredacted.supabase.co
SUPABASE_URL: https://jnxneredacted.supabase.co
SUPABASE_SERVICE_ROLE_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsI
@kgnfth not too sure what's happening there but Supabase logging isn't really intended for self hosted instances. I've just put out a commit to make this opt in so your self hosted instance isn't spammed with 500 errors.
If you do want to set this up you will need to setup an instance of Supabase with a table like the following:
and create a function named "increment_log" with the following variables:
is_oauth: bool
route_type: text
c_date: date
and definition:
BEGIN
IF EXISTS (SELECT FROM analytics WHERE type=route_type AND oauth=is_oauth::bool AND date=c_date::date) THEN
UPDATE analytics
SET count = count + 1,
last_updated = now()
WHERE type=route_type AND oauth=is_oauth::bool AND date=c_date::date;
ELSE
INSERT into analytics(type,oauth,date) VALUES (route_type,is_oauth,c_date);
END IF;
END;
Then setup your troddit environment variables:
ENABLE_API_LOG=true
SUPABASE_URL=<https://your-supabase-url>
SUPABASE_SERVICE_ROLE_KEY=<your service role key>
The exact schema of the table and function definition can be whatever you want. Troddit just calls the remote function with the route_type, c_date, and is_oauth variables.
@burhan-syed Thanks it is working ❤️
Anonymously logging Reddit API in response to #159