1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

add back events for browser refresh extension (#11085)

- something went sideways in a merge
This commit is contained in:
Nick Krantz
2024-09-16 14:02:20 -05:00
committed by GitHub
parent 51a2ec393c
commit 26f3dcfc66
22 changed files with 300 additions and 16 deletions

View File

@@ -30,6 +30,7 @@
bitIconButton
bitPasswordInputToggle
data-testid="toggle-number"
(toggledChange)="logCardEvent($event, EventType.Cipher_ClientToggledCardNumberVisible)"
></button>
<button
bitIconButton="bwi-clone"
@@ -69,6 +70,7 @@
bitIconButton
bitPasswordInputToggle
data-testid="toggle-code"
(toggledChange)="logCardEvent($event, EventType.Cipher_ClientToggledCardCodeVisible)"
></button>
<button
bitIconButton="bwi-clone"
@@ -79,6 +81,7 @@
[valueLabel]="'securityCode' | i18n"
[appA11yTitle]="'copyValue' | i18n"
data-testid="copy-code"
(click)="logCardEvent(true, EventType.Cipher_ClientCopiedCardCode)"
></button>
</bit-form-field>
</read-only-cipher-card>

View File

@@ -2,8 +2,10 @@ import { CommonModule } from "@angular/common";
import { Component, Input } from "@angular/core";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
import { EventType } from "@bitwarden/common/enums";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CardView } from "@bitwarden/common/vault/models/view/card.view";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import {
CardComponent,
SectionComponent,
@@ -32,9 +34,17 @@ import { ReadOnlyCipherCardComponent } from "../read-only-cipher-card/read-only-
],
})
export class CardDetailsComponent {
@Input() card: CardView;
@Input() cipher: CipherView;
EventType = EventType;
constructor(private i18nService: I18nService) {}
constructor(
private i18nService: I18nService,
private eventCollectionService: EventCollectionService,
) {}
get card() {
return this.cipher.card;
}
get setSectionTitle() {
if (this.card.brand && this.card.brand !== "Other") {
@@ -42,4 +52,15 @@ export class CardDetailsComponent {
}
return this.i18nService.t("cardDetails");
}
async logCardEvent(conditional: boolean, event: EventType) {
if (conditional) {
await this.eventCollectionService.collect(
event,
this.cipher.id,
false,
this.cipher.organizationId,
);
}
}
}

View File

@@ -29,7 +29,7 @@
</app-autofill-options-view>
<!-- CARD DETAILS -->
<app-card-details-view *ngIf="hasCard" [card]="cipher.card"></app-card-details-view>
<app-card-details-view *ngIf="hasCard" [cipher]="cipher"></app-card-details-view>
<!-- IDENTITY SECTIONS -->
<app-view-identity-sections *ngIf="cipher.identity" [cipher]="cipher">
@@ -42,8 +42,7 @@
<!-- CUSTOM FIELDS -->
<ng-container *ngIf="cipher.fields">
<app-custom-fields-v2 [fields]="cipher.fields" [cipherType]="cipher.type">
</app-custom-fields-v2>
<app-custom-fields-v2 [cipher]="cipher"> </app-custom-fields-v2>
</ng-container>
<!-- ATTACHMENTS SECTION -->

View File

@@ -5,7 +5,7 @@
<bit-card>
<div
class="tw-border-secondary-300 [&_bit-form-field:last-of-type]:tw-mb-0"
*ngFor="let field of fields; let last = last"
*ngFor="let field of cipher.fields; let last = last"
[ngClass]="{ 'tw-mb-4': !last }"
>
<bit-form-field *ngIf="field.type === fieldType.Text" [disableReadOnlyBorder]="last">
@@ -24,7 +24,13 @@
<bit-form-field *ngIf="field.type === fieldType.Hidden" [disableReadOnlyBorder]="last">
<bit-label>{{ field.name }}</bit-label>
<input readonly bitInput type="password" [value]="field.value" aria-readonly="true" />
<button bitSuffix type="button" bitIconButton bitPasswordInputToggle></button>
<button
bitSuffix
type="button"
bitIconButton
bitPasswordInputToggle
(toggledChange)="logHiddenEvent($event)"
></button>
<button
bitIconButton="bwi-clone"
bitSuffix
@@ -33,6 +39,7 @@
showToast
[valueLabel]="field.name"
[appA11yTitle]="'copyValue' | i18n"
(click)="logCopyEvent()"
></button>
</bit-form-field>
<bit-form-control *ngIf="field.type === fieldType.Boolean">

View File

@@ -2,10 +2,12 @@ import { CommonModule } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
import { EventType } from "@bitwarden/common/enums";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherType, FieldType, LinkedIdType } from "@bitwarden/common/vault/enums";
import { CardView } from "@bitwarden/common/vault/models/view/card.view";
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { IdentityView } from "@bitwarden/common/vault/models/view/identity.view";
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
import {
@@ -37,12 +39,14 @@ import {
],
})
export class CustomFieldV2Component implements OnInit {
@Input() fields: FieldView[];
@Input() cipherType: CipherType;
@Input() cipher: CipherView;
fieldType = FieldType;
fieldOptions: any;
constructor(private i18nService: I18nService) {}
constructor(
private i18nService: I18nService,
private eventCollectionService: EventCollectionService,
) {}
ngOnInit(): void {
this.fieldOptions = this.getLinkedFieldsOptionsForCipher();
@@ -53,8 +57,28 @@ export class CustomFieldV2Component implements OnInit {
return this.i18nService.t(linkedType.i18nKey);
}
async logHiddenEvent(hiddenFieldVisible: boolean) {
if (hiddenFieldVisible) {
await this.eventCollectionService.collect(
EventType.Cipher_ClientToggledHiddenFieldVisible,
this.cipher.id,
false,
this.cipher.organizationId,
);
}
}
async logCopyEvent() {
await this.eventCollectionService.collect(
EventType.Cipher_ClientCopiedHiddenField,
this.cipher.id,
false,
this.cipher.organizationId,
);
}
private getLinkedFieldsOptionsForCipher() {
switch (this.cipherType) {
switch (this.cipher.type) {
case CipherType.Login:
return LoginView.prototype.linkedFieldOptions;
case CipherType.Card:

View File

@@ -66,6 +66,7 @@
showToast
[appA11yTitle]="'copyValue' | i18n"
data-testid="copy-password"
(click)="logCopyEvent()"
></button>
</bit-form-field>
<div

View File

@@ -4,7 +4,9 @@ import { Router } from "@angular/router";
import { Observable, shareReplay } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions";
import { EventType } from "@bitwarden/common/enums";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import {
@@ -61,6 +63,7 @@ export class LoginCredentialsViewComponent {
private billingAccountProfileStateService: BillingAccountProfileStateService,
private router: Router,
private i18nService: I18nService,
private eventCollectionService: EventCollectionService,
) {}
get fido2CredentialCreationDateValue(): string {
@@ -76,8 +79,17 @@ export class LoginCredentialsViewComponent {
await this.router.navigate(["/premium"]);
}
pwToggleValue(evt: boolean) {
this.passwordRevealed = evt;
async pwToggleValue(passwordVisible: boolean) {
this.passwordRevealed = passwordVisible;
if (passwordVisible) {
await this.eventCollectionService.collect(
EventType.Cipher_ClientToggledPasswordVisible,
this.cipher.id,
false,
this.cipher.organizationId,
);
}
}
togglePasswordCount() {
@@ -87,4 +99,13 @@ export class LoginCredentialsViewComponent {
setTotpCopyCode(e: TotpCodeValues) {
this.totpCodeCopyObj = e;
}
async logCopyEvent() {
await this.eventCollectionService.collect(
EventType.Cipher_ClientCopiedPassword,
this.cipher.id,
false,
this.cipher.organizationId,
);
}
}