Skip to content
Commits on Source (9)
......@@ -17,6 +17,7 @@ import { BlockListService } from './common/services/block-list.service';
import { FeaturesService } from './services/features.service';
import { ThemeService } from './common/services/theme.service';
import { BannedService } from './modules/report/banned/banned.service';
import { DiagnosticsService } from './services/diagnostics.service';
@Component({
moduleId: module.id,
......@@ -50,12 +51,16 @@ export class Minds {
public blockListService: BlockListService,
public featuresService: FeaturesService,
public themeService: ThemeService,
private bannedService: BannedService
private bannedService: BannedService,
private diagnostics: DiagnosticsService
) {
this.name = 'Minds';
}
async ngOnInit() {
this.diagnostics.setUser(this.minds.user);
this.diagnostics.listen(); // Listen for user changes
this.notificationService.getNotifications();
this.session.isLoggedIn(async is => {
......
import { Injectable } from '@angular/core';
import * as Sentry from '@sentry/browser';
import { Session } from './session';
@Injectable()
export class DiagnosticsService {
constructor(protected session: Session) {}
listen() {
this.session.getLoggedInUser(currentUser => {
this.setUser(currentUser);
});
}
setUser(currentUser) {
let userId = null;
if (currentUser) {
userId = currentUser.guid || null;
}
Sentry.setUser({
id: userId,
});
console.info('Diagnostics ID:', userId);
}
}
......@@ -42,6 +42,7 @@ import { InMemoryStorageService } from './in-memory-storage.service';
import { FeedsService } from '../common/services/feeds.service';
import { ThemeService } from '../common/services/theme.service';
import { GlobalScrollService } from './ux/global-scroll.service';
import { DiagnosticsService } from './diagnostics.service';
export const MINDS_PROVIDERS: any[] = [
{
......@@ -222,4 +223,5 @@ export const MINDS_PROVIDERS: any[] = [
useFactory: ThemeService._,
deps: [RendererFactory2, Client, Session, Storage],
},
DiagnosticsService,
];
......@@ -2,7 +2,6 @@
* Sessions
*/
import { EventEmitter } from '@angular/core';
import * as Sentry from '@sentry/browser';
export class Session {
loggedinEmitter: EventEmitter<any> = new EventEmitter();
......@@ -51,9 +50,6 @@ export class Session {
if (window.Minds.user) {
// Attach user_guid to debug logs
Sentry.setUser({
id: window.Minds.user.guid,
});
return window.Minds.user;
}
......