Skip to content

Commit

Permalink
feat: add trace about client_type & app_language
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Feb 16, 2023
1 parent 263cb4f commit 4bd7ea2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
// If you import a module but never use any of the imported values other than as TypeScript types,
// the resulting javascript file will look as if you never imported the module at all.
import { getSettings } from 'eo/workbench/browser/src/app/modules/system-setting/settings.service';
import { TraceService } from 'eo/workbench/browser/src/app/shared/services/trace.service';
import { getBrowserType } from 'eo/workbench/browser/src/app/utils/browser-type';
import StorageUtil from 'eo/workbench/browser/src/app/utils/storage/storage.utils';

Expand All @@ -18,7 +19,7 @@ type DescriptionsItem = {
})
export class ElectronService {
ipcRenderer;
constructor(private store: StoreService) {
constructor(private store: StoreService, private trace: TraceService) {
// Conditional imports
if (this.isElectron) {
// Notes :
Expand All @@ -33,6 +34,7 @@ export class ElectronService {
// https://www.electronjs.org/docs/latest/api/ipc-renderer#ipcrendererinvokechannel-args
this.ipcRenderer = window.electron.ipcRenderer;
}
this.trace.setUser({ client_type: this.isElectron ? 'client' : 'web' });
}

get isElectron(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { ElectronService } from 'eo/workbench/browser/src/app/core/services/electron/electron.service';
import { LANGUAGES } from 'eo/workbench/browser/src/app/core/services/language/language.model';
import { SettingService } from 'eo/workbench/browser/src/app/modules/system-setting/settings.service';
import { TraceService } from 'eo/workbench/browser/src/app/shared/services/trace.service';
import { APP_CONFIG } from 'eo/workbench/browser/src/environments/environment';

@Injectable({
Expand All @@ -13,12 +14,13 @@ export class LanguageService {
// Web from nginx setting and App from computer system setting
systemLanguage;
langHashMap = new Map().set('zh-Hans', 'zh').set('en-US', 'en');
constructor(private electron: ElectronService, private setting: SettingService) {
constructor(private electron: ElectronService, private setting: SettingService, private trace: TraceService) {
//Curent language
this.systemLanguage =
this.languages.find(val => window.location.pathname.includes(`/${val.path}/`))?.value ||
this.setting.settings?.['system.language'] ||
(navigator.language.includes('zh') ? 'zh-Hans' : 'en-US');
this.trace.setUser({ app_language: this.systemLanguage });
}
get langHash() {
return this.langHashMap.get(this.systemLanguage);
Expand Down

0 comments on commit 4bd7ea2

Please sign in to comment.