Skip to content

Commit

Permalink
optional sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
KTachibanaM committed Nov 10, 2024
1 parent 48ff83b commit ab7d498
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This is a forked version of Nitter ([original version](https://github.com/sekai-
* Fix video playback via Nitter proxying
* Fix photo rail section on profile page
* Add optional Sentry error reporting
* (TBD) Rate-limit retrier baked-in: Optionally start a coprocess that gathers all requests that had been rate-limited and retry them later. This ensures that those rate-limited requests will be cached by the next time the same requests come in, e.g. from a RSS reader.
* Unified Docker image for x86_64 and arm64

## Usage
Expand Down
1 change: 1 addition & 0 deletions nitter.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ requires "zippy#ca5989a"
requires "flatty#e668085"
requires "jsony#1de1f08"
requires "oauth#b8c163b"
requires "https://github.com/iffy/nim-sentry.git"

# Tasks

Expand Down
5 changes: 4 additions & 1 deletion src/apiutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import jsony, packedjson, zippy, oauth1
import types, auth, consts, parserutils, http_pool
import experimental/types/common

import sentry

const
rlRemaining = "x-rate-limit-remaining"
rlReset = "x-rate-limit-reset"
Expand Down Expand Up @@ -110,9 +112,10 @@ template fetchImpl(result, fetchBody) {.dirty.} =
template retry(bod) =
try:
bod
except RateLimitError:
except RateLimitError as e:
let currentTime = now().format("yyyy-MM-dd HH:mm:ss")
echo currentTime, " - [accounts] Rate limited, retrying ", api, " request..."
captureException(e)
bod

proc fetch*(url: Uri; api: Api): Future[JsonNode] {.async.} =
Expand Down
10 changes: 9 additions & 1 deletion src/nitter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncdispatch, strformat, logging
from net import Port
from htmlgen import a
from os import getEnv
from os import getEnv, existsEnv

import jester

Expand All @@ -12,9 +12,17 @@ import routes/[
preferences, timeline, status, media, search, rss, list, debug,
unsupported, embed, resolver, router_utils]

import sentry

const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
const issuesUrl = "https://github.com/zedeus/nitter/issues"

if existsEnv("SENTRY_DSN"):
echo "Sentry enabled"
init(getEnv("SENTRY_DSN"))
else:
echo "Sentry disabled"

let
configPath = getEnv("NITTER_CONF_FILE", "./nitter.conf")
(cfg, fullCfg) = getConfig(configPath)
Expand Down

0 comments on commit ab7d498

Please sign in to comment.