Skip to content

Commit 103f3f7

Browse files
chore: Merge release in master
2 parents f7a4594 + e11b1c2 commit 103f3f7

File tree

7 files changed

+1026
-914
lines changed

7 files changed

+1026
-914
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
NativeScript CLI Changelog
22
================
33

4+
4.0.2 (2018, May 18)
5+
==
6+
7+
### Fixed
8+
* [Fixed #3595](https://github.com/NativeScript/nativescript-cli/issues/3595): Do not track local paths in Analytics
9+
* [Fixed #3597](https://github.com/NativeScript/nativescript-cli/issues/3597): Users who subscribe to Progess Newsletter are not informed for the privacy policy
10+
411
4.0.1 (2018, May 11)
512
==
613

lib/constants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require("colors");
2+
13
export const APP_FOLDER_NAME = "app";
24
export const APP_RESOURCES_FOLDER_NAME = "App_Resources";
35
export const PROJECT_FRAMEWORK_FOLDER_NAME = "framework";
@@ -78,6 +80,8 @@ export const RESERVED_TEMPLATE_NAMES: IStringDictionary = {
7880
"angular": "tns-template-hello-world-ng"
7981
};
8082

83+
export const ANALYTICS_LOCAL_TEMPLATE_PREFIX = "localTemplate_";
84+
8185
export class ITMSConstants {
8286
static ApplicationMetadataFile = "metadata.xml";
8387
static VerboseLoggingLevels = {
@@ -178,3 +182,10 @@ export class MacOSVersions {
178182
}
179183

180184
export const MacOSDeprecationStringFormat = "Support for macOS %s is deprecated and will be removed in one of the next releases of NativeScript. Please, upgrade to the latest macOS version.";
185+
export const PROGRESS_PRIVACY_POLICY_URL = "https://www.progress.com/legal/privacy-policy";
186+
export class SubscribeForNewsletterMessages {
187+
public static AgreeToReceiveEmailMsg = "I agree to receive email communications from Progress Software or its Partners (`https://www.progress.com/partners/partner-directory`)," +
188+
"containing information about Progress Software's products. Consent may be withdrawn at any time.";
189+
public static ReviewPrivacyPolicyMsg = `You can review the Progress Software Privacy Policy at \`${PROGRESS_PRIVACY_POLICY_URL}\``;
190+
public static PromptMsg = "Input your e-mail address to agree".green + " or " + "leave empty to decline".red.bold + ":";
191+
}

lib/services/project-templates-service.ts

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
1818

1919
const templateName = constants.RESERVED_TEMPLATE_NAMES[name.toLowerCase()] || name;
2020

21-
await this.$analyticsService.track("Template used for project creation", templateName);
21+
const realTemplatePath = await this.prepareNativeScriptTemplate(templateName, version, projectDir);
2222

23-
await this.$analyticsService.trackEventActionInGoogleAnalytics({
24-
action: constants.TrackActionNames.CreateProject,
25-
isForDevice: null,
26-
additionalData: templateName
27-
});
23+
await this.$analyticsService.track("Template used for project creation", templateName);
2824

29-
const realTemplatePath = await this.prepareNativeScriptTemplate(templateName, version, projectDir);
25+
const templateNameToBeTracked = this.getTemplateNameToBeTracked(templateName, realTemplatePath);
26+
if (templateNameToBeTracked) {
27+
await this.$analyticsService.trackEventActionInGoogleAnalytics({
28+
action: constants.TrackActionNames.CreateProject,
29+
isForDevice: null,
30+
additionalData: templateNameToBeTracked
31+
});
32+
}
3033

3134
// this removes dependencies from templates so they are not copied to app folder
3235
this.$fs.deleteDirectory(path.join(realTemplatePath, constants.NODE_MODULES_FOLDER_NAME));
@@ -46,5 +49,25 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
4649
this.$logger.trace(`Using NativeScript verified template: ${templateName} with version ${version}.`);
4750
return this.$npmInstallationManager.install(templateName, projectDir, { version: version, dependencyType: "save" });
4851
}
52+
53+
private getTemplateNameToBeTracked(templateName: string, realTemplatePath: string): string {
54+
try {
55+
if (this.$fs.exists(templateName)) {
56+
// local template is used
57+
const pathToPackageJson = path.join(realTemplatePath, constants.PACKAGE_JSON_FILE_NAME);
58+
let templateNameToTrack = path.basename(templateName);
59+
if (this.$fs.exists(pathToPackageJson)) {
60+
const templatePackageJsonContent = this.$fs.readJson(pathToPackageJson);
61+
templateNameToTrack = templatePackageJsonContent.name;
62+
}
63+
64+
return `${constants.ANALYTICS_LOCAL_TEMPLATE_PREFIX}${templateNameToTrack}`;
65+
}
66+
67+
return templateName;
68+
} catch (err) {
69+
this.$logger.trace(`Unable to get template name to be tracked, error is: ${err}`);
70+
}
71+
}
4972
}
5073
$injector.register("projectTemplatesService", ProjectTemplatesService);

lib/services/subscription-service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as emailValidator from "email-validator";
22
import * as queryString from "querystring";
33
import * as helpers from "../common/helpers";
4+
import { SubscribeForNewsletterMessages } from "../constants";
45

56
export class SubscriptionService implements ISubscriptionService {
67
constructor(private $httpClient: Server.IHttpClient,
@@ -11,8 +12,10 @@ export class SubscriptionService implements ISubscriptionService {
1112

1213
public async subscribeForNewsletter(): Promise<void> {
1314
if (await this.shouldAskForEmail()) {
14-
this.$logger.out("Enter your e-mail address to subscribe to the NativeScript Newsletter and hear about product updates, tips & tricks, and community happenings:");
15-
const email = await this.getEmail("(press Enter for blank)");
15+
this.$logger.printMarkdown(SubscribeForNewsletterMessages.AgreeToReceiveEmailMsg);
16+
this.$logger.printMarkdown(SubscribeForNewsletterMessages.ReviewPrivacyPolicyMsg);
17+
18+
const email = await this.getEmail(SubscribeForNewsletterMessages.PromptMsg);
1619
await this.$userSettingsService.saveSetting("EMAIL_REGISTERED", true);
1720
await this.sendEmail(email);
1821
}

0 commit comments

Comments
 (0)