mirror of
https://github.com/bitwarden/browser
synced 2026-02-10 05:30:01 +00:00
end-to-end achievments!
This commit is contained in:
@@ -5,12 +5,14 @@ import { UserEventCollector } from "../log/user-event-collector";
|
||||
|
||||
import { AchievementHub } from "./achievement-hub";
|
||||
import { AchievementService } from "./achievement.service.abstraction";
|
||||
import {
|
||||
FiveItemsCreatedValidator,
|
||||
ItemCreatedValidator,
|
||||
ThreeItemsCreatedValidator,
|
||||
TotallyAttachedValidator,
|
||||
} from "./examples/example-validators";
|
||||
import { isEarnedEvent, isProgressEvent } from "./meta";
|
||||
import { Achievement, AchievementEvent, AchievementValidator } from "./types";
|
||||
import { ItemCreatedCountConfig } from "./validators/config/item-created-count-config";
|
||||
import { SendItemCreatedCountConfig } from "./validators/config/send-created-count-config";
|
||||
import { SendItemCreatedCountValidator } from "./validators/send-item-created-count-validator";
|
||||
import { VaultItemCreatedCountValidator } from "./validators/vault-item-created-count-validator";
|
||||
|
||||
export class DefaultAchievementService implements AchievementService {
|
||||
constructor(private readonly collector: UserEventCollector) {}
|
||||
@@ -21,8 +23,10 @@ export class DefaultAchievementService implements AchievementService {
|
||||
if (!this.hubs.has(account.id)) {
|
||||
// FIXME: sync these from the server and load them
|
||||
const validators$ = new BehaviorSubject<AchievementValidator[]>([
|
||||
...VaultItemCreatedCountValidator.createValidators(ItemCreatedCountConfig.AllConfigs),
|
||||
...SendItemCreatedCountValidator.createValidators(SendItemCreatedCountConfig.AllConfigs),
|
||||
ItemCreatedValidator,
|
||||
ThreeItemsCreatedValidator,
|
||||
FiveItemsCreatedValidator,
|
||||
TotallyAttachedValidator,
|
||||
]);
|
||||
|
||||
// FIXME: load stored achievements
|
||||
@@ -37,8 +41,10 @@ export class DefaultAchievementService implements AchievementService {
|
||||
}
|
||||
|
||||
private _achievements: Achievement[] = [
|
||||
...ItemCreatedCountConfig.AllConfigs,
|
||||
...SendItemCreatedCountConfig.AllConfigs,
|
||||
ItemCreatedValidator,
|
||||
ThreeItemsCreatedValidator,
|
||||
FiveItemsCreatedValidator,
|
||||
TotallyAttachedValidator,
|
||||
];
|
||||
|
||||
achievementMap() {
|
||||
|
||||
@@ -21,7 +21,6 @@ const ItemCreatedEarnedEvent: AchievementEarnedEvent = {
|
||||
node: {
|
||||
name: "an-installation-identifier-for-this-client-instance",
|
||||
},
|
||||
environment: "local",
|
||||
version: "2025.3.1-innovation-sprint",
|
||||
},
|
||||
user: {
|
||||
@@ -42,7 +41,6 @@ const NextItemCreatedEarnedEvent: AchievementEarnedEvent = {
|
||||
node: {
|
||||
name: "an-installation-identifier-for-this-client-instance",
|
||||
},
|
||||
environment: "local",
|
||||
version: "2025.3.1-innovation-sprint",
|
||||
},
|
||||
user: {
|
||||
@@ -63,7 +61,6 @@ const ThreeItemsCreatedEarnedEvent: AchievementEarnedEvent = {
|
||||
node: {
|
||||
name: "an-installation-identifier-for-this-client-instance",
|
||||
},
|
||||
environment: "local",
|
||||
version: "2025.3.1-innovation-sprint",
|
||||
},
|
||||
user: {
|
||||
@@ -84,7 +81,6 @@ const ItemCreatedProgressEvent: AchievementProgressEvent = {
|
||||
node: {
|
||||
name: "an-installation-identifier-for-this-client-instance",
|
||||
},
|
||||
environment: "local",
|
||||
version: "2025.3.1-innovation-sprint",
|
||||
},
|
||||
user: {
|
||||
@@ -105,7 +101,6 @@ const NextItemCreatedProgressEvent: AchievementProgressEvent = {
|
||||
node: {
|
||||
name: "an-installation-identifier-for-this-client-instance",
|
||||
},
|
||||
environment: "local",
|
||||
version: "2025.3.1-innovation-sprint",
|
||||
},
|
||||
user: {
|
||||
@@ -126,7 +121,6 @@ const CredentialGeneratedProgressEvent: AchievementProgressEvent = {
|
||||
node: {
|
||||
name: "an-installation-identifier-for-this-client-instance",
|
||||
},
|
||||
environment: "local",
|
||||
version: "2025.3.1-innovation-sprint",
|
||||
},
|
||||
user: {
|
||||
|
||||
@@ -50,7 +50,7 @@ export class DefaultCipherFormService implements CipherFormService {
|
||||
"vault-item-uri-quantity": cipher.type === CipherType.Login ? cipher.login.uris.length : null,
|
||||
};
|
||||
const tags = [
|
||||
cipher.attachments.length > 0 ? "with-attachment" : null,
|
||||
(cipher.attachments?.length ?? 0) > 0 ? "with-attachment" : null,
|
||||
cipher.folderId ? "with-folder" : null,
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user