mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-28446] Log package types (#17496)
* User agent * Update to use header * Fix build on cli * Replace unsandboxed with unknown * Apply feedback * Prevent sending null values
This commit is contained in:
@@ -329,6 +329,25 @@ export abstract class BrowserPlatformUtilsService implements PlatformUtilsServic
|
||||
return autofillCommand;
|
||||
}
|
||||
|
||||
async packageType(): Promise<string | null> {
|
||||
switch (this.getDevice()) {
|
||||
case DeviceType.ChromeExtension:
|
||||
return "Chrome Extension";
|
||||
case DeviceType.FirefoxExtension:
|
||||
return "Firefox Extension";
|
||||
case DeviceType.OperaExtension:
|
||||
return "Opera Extension";
|
||||
case DeviceType.EdgeExtension:
|
||||
return "Edge Extension";
|
||||
case DeviceType.VivaldiExtension:
|
||||
return "Vivaldi Extension";
|
||||
case DeviceType.SafariExtension:
|
||||
return "Safari Extension";
|
||||
default:
|
||||
return "Unknown Browser Extension";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers the offscreen document API to copy the text to the clipboard.
|
||||
*/
|
||||
|
||||
@@ -152,4 +152,8 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
|
||||
getAutofillKeyboardShortcut(): Promise<string> {
|
||||
return null;
|
||||
}
|
||||
|
||||
async packageType(): Promise<string | null> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ export class WindowMain {
|
||||
|
||||
await this.createWindow();
|
||||
resolve();
|
||||
|
||||
if (this.argvCallback != null) {
|
||||
this.argvCallback(process.argv);
|
||||
}
|
||||
|
||||
@@ -151,4 +151,20 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
|
||||
getAutofillKeyboardShortcut(): Promise<string> {
|
||||
return null;
|
||||
}
|
||||
|
||||
async packageType(): Promise<string> {
|
||||
if (ipc.platform.isMacAppStore) {
|
||||
return "MacAppStore";
|
||||
} else if (ipc.platform.isWindowsStore) {
|
||||
return "WindowsStore";
|
||||
} else if (ipc.platform.isAppImage) {
|
||||
return "AppImage";
|
||||
} else if (ipc.platform.isSnapStore) {
|
||||
return "Snap";
|
||||
} else if (ipc.platform.isFlatpak) {
|
||||
return "Flatpak";
|
||||
} else {
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,4 +219,8 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
||||
getAutofillKeyboardShortcut(): Promise<string> {
|
||||
return null;
|
||||
}
|
||||
|
||||
packageType(): Promise<string | null> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,4 +55,5 @@ export abstract class PlatformUtilsService {
|
||||
abstract readFromClipboard(): Promise<string>;
|
||||
abstract supportsSecureStorage(): boolean;
|
||||
abstract getAutofillKeyboardShortcut(): Promise<string>;
|
||||
abstract packageType(): Promise<string | null>;
|
||||
}
|
||||
|
||||
@@ -1325,6 +1325,11 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
"Bitwarden-Client-Version",
|
||||
await this.platformUtilsService.getApplicationVersionNumber(),
|
||||
);
|
||||
|
||||
const packageType = await this.platformUtilsService.packageType();
|
||||
if (packageType != null) {
|
||||
request.headers.set("Bitwarden-Package-Type", packageType);
|
||||
}
|
||||
return this.nativeFetch(request);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user