mirror of
https://github.com/bitwarden/server
synced 2025-12-17 16:53:23 +00:00
[PM-23804] Add logging to AdjustSeatsAsync to identify Stripe/Organization seat disrecpancy (#6098)
* Add logging for seat scale * Run dotnet format
This commit is contained in:
@@ -324,8 +324,14 @@ public class OrganizationService : IOrganizationService
|
|||||||
throw new BadRequestException("You cannot have more Secrets Manager seats than Password Manager seats.");
|
throw new BadRequestException("You cannot have more Secrets Manager seats than Password Manager seats.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("{Method}: Invoking _paymentService.AdjustSeatsAsync with {AdditionalSeats} additional seats for Organization ({OrganizationID})",
|
||||||
|
nameof(AdjustSeatsAsync), additionalSeats, organization.Id);
|
||||||
|
|
||||||
var paymentIntentClientSecret = await _paymentService.AdjustSeatsAsync(organization, plan, additionalSeats);
|
var paymentIntentClientSecret = await _paymentService.AdjustSeatsAsync(organization, plan, additionalSeats);
|
||||||
organization.Seats = (short?)newSeatTotal;
|
organization.Seats = (short?)newSeatTotal;
|
||||||
|
|
||||||
|
_logger.LogInformation("{Method}: Invoking _organizationRepository.ReplaceAsync with {Seats} seats for Organization ({OrganizationID})", nameof(AdjustSeatsAsync), organization.Seats, organization.Id); ;
|
||||||
|
|
||||||
await ReplaceAndUpdateCacheAsync(organization);
|
await ReplaceAndUpdateCacheAsync(organization);
|
||||||
|
|
||||||
if (organization.Seats.HasValue && organization.MaxAutoscaleSeats.HasValue &&
|
if (organization.Seats.HasValue && organization.MaxAutoscaleSeats.HasValue &&
|
||||||
@@ -1190,12 +1196,20 @@ public class OrganizationService : IOrganizationService
|
|||||||
|
|
||||||
public async Task ReplaceAndUpdateCacheAsync(Organization org, EventType? orgEvent = null)
|
public async Task ReplaceAndUpdateCacheAsync(Organization org, EventType? orgEvent = null)
|
||||||
{
|
{
|
||||||
await _organizationRepository.ReplaceAsync(org);
|
try
|
||||||
await _applicationCacheService.UpsertOrganizationAbilityAsync(org);
|
|
||||||
|
|
||||||
if (orgEvent.HasValue)
|
|
||||||
{
|
{
|
||||||
await _eventService.LogOrganizationEventAsync(org, orgEvent.Value);
|
await _organizationRepository.ReplaceAsync(org);
|
||||||
|
await _applicationCacheService.UpsertOrganizationAbilityAsync(org);
|
||||||
|
|
||||||
|
if (orgEvent.HasValue)
|
||||||
|
{
|
||||||
|
await _eventService.LogOrganizationEventAsync(org, orgEvent.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
_logger.LogError(exception, "An error occurred while calling {Method} for Organization ({OrganizationID})", nameof(ReplaceAndUpdateCacheAsync), org.Id);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user