Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logging when updating token #192412

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,13 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat

this._register(this.authenticationService.onDidChangeDeclaredProviders(() => this.updateAuthenticationProviders()));

this._register(
this._register(Event.filter(
Event.any(
Event.filter(
Event.any(
this.authenticationService.onDidRegisterAuthenticationProvider,
this.authenticationService.onDidUnregisterAuthenticationProvider,
), info => this.isSupportedAuthenticationProviderId(info.id)),
Event.filter(this.userDataSyncAccountService.onTokenFailed, isSuccessive => !isSuccessive))
(() => this.update()));
this.authenticationService.onDidRegisterAuthenticationProvider,
this.authenticationService.onDidUnregisterAuthenticationProvider,
), info => this.isSupportedAuthenticationProviderId(info.id))(() => this.update()));

this._register(Event.filter(this.userDataSyncAccountService.onTokenFailed, isSuccessive => !isSuccessive)(() => this.update('token failure')));

this._register(Event.filter(this.authenticationService.onDidChangeSessions, e => this.isSupportedAuthenticationProviderId(e.providerId))(({ event }) => this.onDidChangeSessions(event)));
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, this._register(new DisposableStore()))(() => this.onDidChangeStorage()));
Expand All @@ -205,7 +203,11 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
}));
}

private async update(): Promise<void> {
private async update(reason?: string): Promise<void> {

if (reason) {
this.logService.info(`Settings Sync: Updating due to ${reason}`);
}

this.updateAuthenticationProviders();
await this.updateCurrentAccount();
Expand Down Expand Up @@ -611,20 +613,20 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
private async onDidAuthFailure(): Promise<void> {
this.telemetryService.publicLog2<{}, { owner: 'sandy081'; comment: 'Report when there are successive auth failures during settings sync' }>('sync/successiveAuthFailures');
this.currentSessionId = undefined;
await this.update();
await this.update('auth failure');
}

private onDidChangeSessions(e: AuthenticationSessionsChangeEvent): void {
if (this.currentSessionId && e.removed.find(session => session.id === this.currentSessionId)) {
this.currentSessionId = undefined;
}
this.update();
this.update('change in sessions');
}

private onDidChangeStorage(): void {
if (this.currentSessionId !== this.getStoredCachedSessionId() /* This checks if current window changed the value or not */) {
this._cachedCurrentSessionId = null;
this.update();
this.update('change in storage');
}
}

Expand Down