diff --git a/api/src/redirector.py b/api/src/redirector.py index beb1025..ad0398e 100644 --- a/api/src/redirector.py +++ b/api/src/redirector.py @@ -40,6 +40,8 @@ async def _handle_request(path: str): return await _handle_short_url(path, short_url) if short_url.loading_screen: + await _track_visit(short_url) + return render_template( "redirect.html", key=short_url.short_url, @@ -53,6 +55,11 @@ async def _handle_short_url(path: str, short_url: ShortUrl): if path.startswith("api/"): path = path.replace("api/", "") + await _track_visit(short_url) + + return _do_redirect(short_url.target_url) + +async def _track_visit(short_url: ShortUrl): try: await shortUrlVisitDao.create( ShortUrlVisit(0, short_url.id, request.headers.get("User-Agent")) @@ -60,9 +67,6 @@ async def _handle_short_url(path: str, short_url: ShortUrl): except Exception as e: logger.error(f"Failed to update short url {short_url.short_url} with error", e) - return _do_redirect(short_url.target_url) - - async def _find_short_url_by_url(url: str) -> ShortUrl: return await shortUrlDao.find_single_by({ShortUrl.short_url: url}) diff --git a/version.txt b/version.txt index afaf360..7f20734 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.0 \ No newline at end of file +1.0.1 \ No newline at end of file