diff --git a/concordia/signals/handlers.py b/concordia/signals/handlers.py index 94caf3fb9..ce781c8dc 100644 --- a/concordia/signals/handlers.py +++ b/concordia/signals/handlers.py @@ -26,7 +26,9 @@ @receiver(user_logged_in) def clear_reservation_token(sender, user, request, **kwargs): try: + token = request.session["reservation_token"] del request.session["reservation_token"] + logger.info("Clearing reservation token %s for %s on login", token, user) except KeyError: pass logger.info("Successful user login with username %s", user) @@ -141,6 +143,12 @@ def send_asset_update(*, instance, **kwargs): @receiver(reservation_obtained) def send_asset_reservation_obtained(sender, **kwargs): + logger.info( + "Reservation obtained by %s for asset %s with token %s", + sender, + kwargs["asset_pk"], + kwargs["reservation_token"], + ) send_asset_reservation_message( sender=sender, message_type="asset_reservation_obtained", @@ -151,6 +159,12 @@ def send_asset_reservation_obtained(sender, **kwargs): @receiver(reservation_released) def send_asset_reservation_released(sender, **kwargs): + logger.info( + "Reservation released by %s for asset %s with token %s", + sender, + kwargs["asset_pk"], + kwargs["reservation_token"], + ) send_asset_reservation_message( sender=sender, message_type="asset_reservation_released", diff --git a/concordia/static/js/src/asset-reservation.js b/concordia/static/js/src/asset-reservation.js index 3e7522f17..bb1ef4cfe 100644 --- a/concordia/static/js/src/asset-reservation.js +++ b/concordia/static/js/src/asset-reservation.js @@ -1,4 +1,4 @@ -/* global jQuery displayMessage displayHtmlMessage buildErrorMessage */ +/* global jQuery displayMessage displayHtmlMessage buildErrorMessage Sentry */ /* exported attemptToReserveAsset */ function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) { @@ -18,7 +18,7 @@ function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) { // If the asset was successfully reserved, continue reserving it window.setTimeout( attemptToReserveAsset, - 60000, + 60_000, reservationURL, findANewPageURL, actionType, @@ -40,12 +40,24 @@ function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) { '">Find a new page to review', 'transcription-reservation', ); + Sentry.captureException(errorThrown, function (scope) { + scope.setTransactionName( + '409 error when attempting to reserve asset at ' + + reservationURL, + ); + }); } } else if (jqXHR.status == 408) { $transcriptionEditor .data('hasReservation', false) .trigger('update-ui-state'); jQuery('#asset-reservation-failure-modal').modal(); + Sentry.captureException(errorThrown, function (scope) { + scope.setTransactionName( + '408 error when attempting to reserve asset at ' + + reservationURL, + ); + }); } else { displayMessage( 'error', @@ -53,6 +65,12 @@ function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) { buildErrorMessage(jqXHR, textStatus, errorThrown), 'transcription-reservation', ); + Sentry.captureException(errorThrown, function (scope) { + scope.setTransactionName( + 'Error when attempting to reserve asset at ' + + reservationURL, + ); + }); } });