mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[PM-166] [PM-198] - Add Event Logs for CLI Actions (#6527)
* Added the DeviceType changes for windows CLI * Event logging for CLI commands * Changing the icons to cli icons
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationUserService } from "@bitwarden/common/admin-console/abstractions/organization-user/organization-user.service";
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
import { ListResponse as ApiListResponse } from "@bitwarden/common/models/response/list.response";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
@@ -32,7 +34,8 @@ export class ListCommand {
|
||||
private organizationService: OrganizationService,
|
||||
private searchService: SearchService,
|
||||
private organizationUserService: OrganizationUserService,
|
||||
private apiService: ApiService
|
||||
private apiService: ApiService,
|
||||
private eventCollectionService: EventCollectionService
|
||||
) {}
|
||||
|
||||
async run(object: string, cmdOptions: Record<string, any>): Promise<Response> {
|
||||
@@ -123,6 +126,17 @@ export class ListCommand {
|
||||
ciphers = this.searchService.searchCiphersBasic(ciphers, options.search, options.trash);
|
||||
}
|
||||
|
||||
ciphers.forEach((c, index) => {
|
||||
// Set upload immediately on the last item in the ciphers collection to avoid the event collection
|
||||
// service from uploading each time.
|
||||
this.eventCollectionService.collect(
|
||||
EventType.Cipher_ClientViewed,
|
||||
c.id,
|
||||
index === ciphers.length - 1,
|
||||
c.organizationId
|
||||
);
|
||||
});
|
||||
|
||||
const res = new ListResponse(ciphers.map((o) => new CipherResponse(o)));
|
||||
return Response.success(res);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user