Skip to content

Commit 42854fa

Browse files
committed
Merge pull request #31 from NativeScript/fatme/analytics
Analytics
2 parents 2acf482 + 96854a6 commit 42854fa

File tree

7 files changed

+58
-2
lines changed

7 files changed

+58
-2
lines changed

lib/bootstrap.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ $injector.require("projectTemplatesService", "./services/project-templates-servi
1212
$injector.require("platformsData", "./services/platform-service");
1313
$injector.require("platformService", "./services/platform-service");
1414

15+
$injector.require("userSettingsService", "./services/user-settings-service");
16+
$injector.require("analyticsSettingsService", "./services/analytics-settings-service");
17+
1518
$injector.requireCommand("create", "./commands/create-project");
1619
$injector.requireCommand("platform|*list", "./commands/list-platforms");
1720
$injector.requireCommand("platform|add", "./commands/add-platform");

lib/config.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import path = require("path");
55
export class StaticConfig implements IStaticConfig {
66
public PROJECT_FILE_NAME = ".tnsproject";
77
public CLIENT_NAME = "tns";
8-
public ANALYTICS_API_KEY = "";
8+
public ANALYTICS_API_KEY = "5752dabccfc54c4ab82aea9626b7338e";
9+
public TRACK_FEATURE_USAGE_SETTING_NAME = "TrackFeatureUsage";
10+
public ANALYTICS_INSTALLATION_ID_SETTING_NAME = "AnalyticsInstallationID";
911

1012
public version = require("../package.json").version;
1113

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
///<reference path="../.d.ts"/>
2+
3+
class AnalyticsSettingsService implements IAnalyticsSettingsService {
4+
constructor(private $userSettingsService: UserSettings.IUserSettingsService,
5+
private $staticConfig: IStaticConfig) { }
6+
7+
public canRequestConsent(): IFuture<boolean> {
8+
return (() => { return true; }).future<boolean>()();
9+
}
10+
11+
public getUserId(): IFuture<string> {
12+
return this.$userSettingsService.getSettingValue<string>(this.$staticConfig.ANALYTICS_INSTALLATION_ID_SETTING_NAME);
13+
}
14+
}
15+
$injector.register("analyticsSettingsService", AnalyticsSettingsService);

lib/services/user-settings-service.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
///<reference path="../.d.ts"/>
2+
3+
import path = require("path");
4+
import options = require("./../options");
5+
import userSettingsServiceBaseLib = require("./../common/services/user-settings-service");
6+
7+
class UserSettingsService extends userSettingsServiceBaseLib.UserSettingsServiceBase {
8+
constructor($fs: IFileSystem) {
9+
var userSettingsFilePath = path.join(options["profile-dir"], "user-settings.json");
10+
super(userSettingsFilePath, $fs);
11+
}
12+
}
13+
$injector.register("userSettingsService", UserSettingsService);

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@
2222
"mobile"
2323
],
2424
"dependencies": {
25+
"colors": "0.6.2",
2526
"fibers": "https://github.com/icenium/node-fibers/tarball/master",
2627
"filesize": "2.0.3",
2728
"log4js": "0.6.9",
2829
"mkdirp": "0.3.5",
30+
"mute-stream": "0.0.4",
31+
"node-uuid": "1.4.1",
2932
"npm": "1.4.10",
3033
"osenv": "0.1.0",
3134
"progress-stream": "0.5.0",
35+
"prompt": "https://github.com/Icenium/prompt/tarball/master",
3236
"properties-parser": "0.2.3",
3337
"rimraf": "2.2.6",
3438
"semver": "3.0.1",
@@ -37,6 +41,7 @@
3741
"underscore": "1.5.2",
3842
"unzip": "0.1.9",
3943
"watchr": "2.4.11",
44+
"xmlhttprequest": "1.6.0",
4045
"yargs": "1.2.2"
4146
},
4247
"analyze": true,

resources/help.txt

+18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ General commands:
1515
This lets you build the project with the SDK for the selected platform and deploy it on device.
1616
build Builds the project for the selected target platform and produces an application package.
1717
run Runs your project on a connected device. This is shorthand for prepare, build, and deploy.
18+
feature-usage-tracking Configures anonymous feature usage tracking.
1819

1920
General options:
2021
--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
157158

158159
--[/]--
159160

161+
--[feature-usage-tracking]--
162+
163+
Usage:
164+
$ tns feature-usage-tracking [<Command>]
165+
166+
Configures anonymous usage statistics tracking for the Telerik NativeScript command-line interface.
167+
All data gathered is used strictly for improving the product and will never be used to identify or contact you.
168+
169+
<Command> is a related command that extends the feature-usage-tracking command. You can run the following related commands:
170+
status - Shows the current configuration for anonymous usage tracking for the
171+
Telerik NativeScript command-line interface.
172+
enable - Enables anonymous usage statistics tracking. All data gathered is used strictly
173+
for improving the product and will never be used to identify or contact you.
174+
disable - Disables anonymous usage statistics tracking.
175+
176+
--[/]--
177+

0 commit comments

Comments
 (0)