Skip to content

Commit

Permalink
🧹 Remove debug prints that were left in and fix debug logging (hedyor…
Browse files Browse the repository at this point in the history
…g#5527)

The user activity tracking code logs a lot of errors to the JavaScript console. Nothing goes wrong, but the `postJson` function that is begin used expects a `200` response, but is getting a `204` response.

Only signal an error if we actually get a `400` or higher response.

Also remove some Python `print()`s that were left in most likely for debugging.

**How to test**

Open the console, use the website, observe that the following error does not appear:

![image](https://github.com/hedyorg/hedy/assets/524162/2e810a6e-009a-4f6d-98f5-d44dcb930c84)
  • Loading branch information
rix0rrr authored May 14, 2024
1 parent c35ae6c commit 9aee957
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -103970,7 +103970,7 @@ def note_with_error(value, err):
internetError: true
});
}
if (response.status !== 200) {
if (response.status >= 400) {
let errorMessage = await response.text();
try {
const parsed = JSON.parse(errorMessage);
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/js/comm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function postJsonUsingFetch(url: string, data?: any): Promise<any> {
});
}

if (response.status !== 200) {
if (response.status >= 400) {
// The error message is:
// - response.error, if the response can be parsed as JSON
// - A generic error message if the response is too big (indicating we're probably getting an HTML page back here)
Expand Down
2 changes: 0 additions & 2 deletions website/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ def show_bla(user):

@wraps(f)
def inner(*args, **kws):
print('session before', session)
just_logged_out = session.pop(JUST_LOGGED_OUT, False)
print('session after', session)
if not is_user_logged_in():
return redirect('/') if just_logged_out else utils.error_page(error=401)
# The reason we pass by keyword argument is to make this
Expand Down
3 changes: 0 additions & 3 deletions website/user_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def index(self, user):
user = self.db.user_by_username(user["username"])
if not user:
return {}, 304
print("\n\n TRACKING index \n\n")
body = request.json
data = []

Expand All @@ -58,8 +57,6 @@ def index(self, user):

data.append(data_row)

print(data)

try:
logger.log(data)
return make_response('', 204)
Expand Down

0 comments on commit 9aee957

Please sign in to comment.