mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-07 09:31:31 +01:00
[PM-14180] Provide more debugging details in wasm-debug (#11771)
Improve error logging to include some additional information about the error.
This commit is contained in:
parent
4de7cb8012
commit
5e157c5bca
@ -1347,14 +1347,17 @@ export default class MainBackground {
|
||||
if (flagEnabled("sdk")) {
|
||||
// Warn if the SDK for some reason can't be initialized
|
||||
let supported = false;
|
||||
let error: Error;
|
||||
try {
|
||||
supported = await firstValueFrom(this.sdkService.supported$);
|
||||
} catch (e) {
|
||||
// Do nothing.
|
||||
error = e;
|
||||
}
|
||||
|
||||
if (!supported) {
|
||||
this.sdkService.failedToInitialize().catch((e) => this.logService.error(e));
|
||||
this.sdkService
|
||||
.failedToInitialize("background", error)
|
||||
.catch((e) => this.logService.error(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit, inject } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { NavigationEnd, Router, RouterOutlet } from "@angular/router";
|
||||
import { Subject, takeUntil, firstValueFrom, concatMap, filter, tap, catchError, of } from "rxjs";
|
||||
import { Subject, takeUntil, firstValueFrom, concatMap, filter, tap } from "rxjs";
|
||||
|
||||
import { LogoutReason } from "@bitwarden/auth/common";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
@ -71,21 +71,24 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
) {
|
||||
if (flagEnabled("sdk")) {
|
||||
// Warn if the SDK for some reason can't be initialized
|
||||
this.sdkService.supported$
|
||||
.pipe(
|
||||
takeUntilDestroyed(),
|
||||
catchError(() => {
|
||||
return of(false);
|
||||
}),
|
||||
)
|
||||
.subscribe((supported) => {
|
||||
this.sdkService.supported$.pipe(takeUntilDestroyed()).subscribe({
|
||||
next: (supported) => {
|
||||
if (!supported) {
|
||||
this.logService.debug("SDK is not supported");
|
||||
this.sdkService.failedToInitialize().catch((e) => this.logService.error(e));
|
||||
this.sdkService
|
||||
.failedToInitialize("popup", undefined)
|
||||
.catch((e) => this.logService.error(e));
|
||||
} else {
|
||||
this.logService.debug("SDK is supported");
|
||||
}
|
||||
});
|
||||
},
|
||||
error: (e: unknown) => {
|
||||
this.sdkService
|
||||
.failedToInitialize("popup", e as Error)
|
||||
.catch((e) => this.logService.error(e));
|
||||
this.logService.error(e);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -872,7 +872,7 @@ export class ServiceContainer {
|
||||
}
|
||||
|
||||
if (!supported) {
|
||||
this.sdkService.failedToInitialize().catch((e) => this.logService.error(e));
|
||||
this.sdkService.failedToInitialize("cli").catch((e) => this.logService.error(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
.subscribe((supported) => {
|
||||
if (!supported) {
|
||||
this.logService.debug("SDK is not supported");
|
||||
this.sdkService.failedToInitialize().catch((e) => this.logService.error(e));
|
||||
this.sdkService.failedToInitialize("desktop").catch((e) => this.logService.error(e));
|
||||
} else {
|
||||
this.logService.debug("SDK is supported");
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
.subscribe((supported) => {
|
||||
if (!supported) {
|
||||
this.logService.debug("SDK is not supported");
|
||||
this.sdkService.failedToInitialize().catch((e) => this.logService.error(e));
|
||||
this.sdkService.failedToInitialize("web").catch((e) => this.logService.error(e));
|
||||
} else {
|
||||
this.logService.debug("SDK is supported");
|
||||
}
|
||||
|
@ -29,5 +29,5 @@ export abstract class SdkService {
|
||||
*/
|
||||
abstract userClient$(userId: UserId): Observable<BitwardenClient>;
|
||||
|
||||
abstract failedToInitialize(): Promise<void>;
|
||||
abstract failedToInitialize(category: string, error?: Error): Promise<void>;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ export class DefaultSdkService implements SdkService {
|
||||
return client$;
|
||||
}
|
||||
|
||||
async failedToInitialize(): Promise<void> {
|
||||
async failedToInitialize(category: string, error?: Error): Promise<void> {
|
||||
// Only log on cloud instances
|
||||
if (
|
||||
this.platformUtilsService.isDev() ||
|
||||
@ -139,9 +139,20 @@ export class DefaultSdkService implements SdkService {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.apiService.send("POST", "/wasm-debug", null, false, false, null, (headers) => {
|
||||
headers.append("SDK-Version", "1.0.0");
|
||||
});
|
||||
return this.apiService.send(
|
||||
"POST",
|
||||
"/wasm-debug",
|
||||
{
|
||||
category: category,
|
||||
error: error?.message,
|
||||
},
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
(headers) => {
|
||||
headers.append("SDK-Version", "1.0.0");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
private async initializeClient(
|
||||
|
Loading…
Reference in New Issue
Block a user