From 96854a61ba77d828d09e30cdf582c0e49b967fa7 Mon Sep 17 00:00:00 2001 From: fatme Date: Thu, 7 Aug 2014 07:18:56 +0300 Subject: [PATCH] Analytics service --- lib/bootstrap.ts | 3 +++ lib/common | 2 +- lib/config.ts | 4 +++- lib/services/analytics-settings-service.ts | 15 +++++++++++++++ lib/services/user-settings-service.ts | 13 +++++++++++++ package.json | 5 +++++ resources/help.txt | 18 ++++++++++++++++++ 7 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 lib/services/analytics-settings-service.ts create mode 100644 lib/services/user-settings-service.ts diff --git a/lib/bootstrap.ts b/lib/bootstrap.ts index a5e60f64ff..ce34667ba4 100644 --- a/lib/bootstrap.ts +++ b/lib/bootstrap.ts @@ -12,6 +12,9 @@ $injector.require("projectTemplatesService", "./services/project-templates-servi $injector.require("platformsData", "./services/platform-service"); $injector.require("platformService", "./services/platform-service"); +$injector.require("userSettingsService", "./services/user-settings-service"); +$injector.require("analyticsSettingsService", "./services/analytics-settings-service"); + $injector.requireCommand("create", "./commands/create-project"); $injector.requireCommand("platform|*list", "./commands/list-platforms"); $injector.requireCommand("platform|add", "./commands/add-platform"); diff --git a/lib/common b/lib/common index 210d47e475..b954f93b21 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 210d47e475b369edd00f51001d6c4269ee60ba62 +Subproject commit b954f93b2192c88c3879502766716fd514c97bb2 diff --git a/lib/config.ts b/lib/config.ts index 8aeb2179a2..6cc911e00d 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -5,7 +5,9 @@ import path = require("path"); export class StaticConfig implements IStaticConfig { public PROJECT_FILE_NAME = ".tnsproject"; public CLIENT_NAME = "tns"; - public ANALYTICS_API_KEY = ""; + public ANALYTICS_API_KEY = "5752dabccfc54c4ab82aea9626b7338e"; + public TRACK_FEATURE_USAGE_SETTING_NAME = "TrackFeatureUsage"; + public ANALYTICS_INSTALLATION_ID_SETTING_NAME = "AnalyticsInstallationID"; public version = require("../package.json").version; diff --git a/lib/services/analytics-settings-service.ts b/lib/services/analytics-settings-service.ts new file mode 100644 index 0000000000..e4ddfec1b9 --- /dev/null +++ b/lib/services/analytics-settings-service.ts @@ -0,0 +1,15 @@ +/// + +class AnalyticsSettingsService implements IAnalyticsSettingsService { + constructor(private $userSettingsService: UserSettings.IUserSettingsService, + private $staticConfig: IStaticConfig) { } + + public canRequestConsent(): IFuture { + return (() => { return true; }).future()(); + } + + public getUserId(): IFuture { + return this.$userSettingsService.getSettingValue(this.$staticConfig.ANALYTICS_INSTALLATION_ID_SETTING_NAME); + } +} +$injector.register("analyticsSettingsService", AnalyticsSettingsService); \ No newline at end of file diff --git a/lib/services/user-settings-service.ts b/lib/services/user-settings-service.ts new file mode 100644 index 0000000000..38fbed0610 --- /dev/null +++ b/lib/services/user-settings-service.ts @@ -0,0 +1,13 @@ +/// + +import path = require("path"); +import options = require("./../options"); +import userSettingsServiceBaseLib = require("./../common/services/user-settings-service"); + +class UserSettingsService extends userSettingsServiceBaseLib.UserSettingsServiceBase { + constructor($fs: IFileSystem) { + var userSettingsFilePath = path.join(options["profile-dir"], "user-settings.json"); + super(userSettingsFilePath, $fs); + } +} +$injector.register("userSettingsService", UserSettingsService); \ No newline at end of file diff --git a/package.json b/package.json index 8fa856746c..f835ccf89a 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,17 @@ "mobile" ], "dependencies": { + "colors": "0.6.2", "fibers": "https://github.com/icenium/node-fibers/tarball/master", "filesize": "2.0.3", "log4js": "0.6.9", "mkdirp": "0.3.5", + "mute-stream": "0.0.4", + "node-uuid": "1.4.1", "npm": "1.4.10", "osenv": "0.1.0", "progress-stream": "0.5.0", + "prompt": "https://github.com/Icenium/prompt/tarball/master", "properties-parser": "0.2.3", "rimraf": "2.2.6", "semver": "3.0.1", @@ -37,6 +41,7 @@ "underscore": "1.5.2", "unzip": "0.1.9", "watchr": "2.4.11", + "xmlhttprequest": "1.6.0", "yargs": "1.2.2" }, "analyze": true, diff --git a/resources/help.txt b/resources/help.txt index 4b38485eb8..2da9b416b5 100644 --- a/resources/help.txt +++ b/resources/help.txt @@ -15,6 +15,7 @@ General commands: This lets you build the project with the SDK for the selected platform and deploy it on device. build Builds the project for the selected target platform and produces an application package. run Runs your project on a connected device. This is shorthand for prepare, build, and deploy. + feature-usage-tracking Configures anonymous feature usage tracking. General options: --help Prints help about the selected command. @@ -157,3 +158,20 @@ Runs your project on a connected device. This is shorthand for prepare, build, a --[/]-- +--[feature-usage-tracking]-- + +Usage: + $ tns feature-usage-tracking [] + +Configures anonymous usage statistics tracking for the Telerik NativeScript command-line interface. +All data gathered is used strictly for improving the product and will never be used to identify or contact you. + + is a related command that extends the feature-usage-tracking command. You can run the following related commands: + status - Shows the current configuration for anonymous usage tracking for the + Telerik NativeScript command-line interface. + enable - Enables anonymous usage statistics tracking. All data gathered is used strictly + for improving the product and will never be used to identify or contact you. + disable - Disables anonymous usage statistics tracking. + +--[/]-- +