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

CB-3995 move anonymous id to const #2292

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion webapp/packages/core-authentication/src/UserInfoResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface ILoginOptions {
linkUser?: boolean;
}

export const ANONYMOUS_USER_ID = 'anonymous';

@injectable()
export class UserInfoResource extends CachedDataResource<UserInfo | null, void, UserInfoIncludes> {
readonly onUserChange: ISyncExecutor<string>;
Expand Down Expand Up @@ -66,7 +68,7 @@ export class UserInfoResource extends CachedDataResource<UserInfo | null, void,
}

getId(): string {
return this.data?.userId || 'anonymous';
return this.data?.userId || ANONYMOUS_USER_ID;
}

hasToken(providerId: string): boolean {
Expand Down
4 changes: 2 additions & 2 deletions webapp/packages/core-projects/src/ProjectsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { computed, makeObservable } from 'mobx';

import { UserDataService, UserInfoResource } from '@cloudbeaver/core-authentication';
import { ANONYMOUS_USER_ID, UserDataService, UserInfoResource } from '@cloudbeaver/core-authentication';
import { Dependency, injectable } from '@cloudbeaver/core-di';
import { Executor, ExecutorInterrupter, IExecutor, ISyncExecutor, SyncExecutor } from '@cloudbeaver/core-executor';
import { CachedMapAllKey, resourceKeyList, ResourceKeyUtils } from '@cloudbeaver/core-resource';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class ProjectsService extends Dependency {
if (this.userInfoResource.data) {
project = this.projectInfoResource.getUserProject(this.userInfoResource.data.userId);
} else {
project = this.projectInfoResource.get('anonymous');
project = this.projectInfoResource.get(ANONYMOUS_USER_ID);
}

return project;
Expand Down
Loading