diff --git a/lib/common b/lib/common index cd17189540..547df8a0e1 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit cd171895401eef3cf5ad1a75310cbc4f01b1493f +Subproject commit 547df8a0e1c6feccf3becfa597c44b78b8d90797 diff --git a/lib/services/analytics-settings-service.ts b/lib/services/analytics-settings-service.ts index 4dc0bbba5d..fdf19a8d24 100644 --- a/lib/services/analytics-settings-service.ts +++ b/lib/services/analytics-settings-service.ts @@ -1,16 +1,28 @@ /// "use strict"; +import { createGUID } from "../common/helpers"; class AnalyticsSettingsService implements IAnalyticsSettingsService { constructor(private $userSettingsService: UserSettings.IUserSettingsService, - private $staticConfig: IStaticConfig) { } + private $staticConfig: IStaticConfig, + private $logger: ILogger) { } public canDoRequest(): IFuture { return (() => { return true; }).future()(); } public getUserId(): IFuture { - return this.$userSettingsService.getSettingValue(this.$staticConfig.ANALYTICS_INSTALLATION_ID_SETTING_NAME); + return (() => { + let currentUserId = this.$userSettingsService.getSettingValue("USER_ID").wait(); + if(!currentUserId) { + currentUserId = createGUID(false); + + this.$logger.trace(`Setting new USER_ID: ${currentUserId}.`); + this.$userSettingsService.saveSetting("USER_ID", currentUserId).wait(); + } + + return currentUserId; + }).future()(); } public getClientName(): string { @@ -20,5 +32,15 @@ class AnalyticsSettingsService implements IAnalyticsSettingsService { public getPrivacyPolicyLink(): string { return "http://www.telerik.com/company/privacy-policy"; } + + public getUserSessionsCount(): IFuture { + return (() => { + return this.$userSettingsService.getSettingValue("SESSIONS_STARTED").wait() || 0; + }).future()(); + } + + public setUserSessionsCount(count: number): IFuture { + return this.$userSettingsService.saveSetting("SESSIONS_STARTED", count); + } } $injector.register("analyticsSettingsService", AnalyticsSettingsService);