@@ -22,11 +22,14 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
22
22
23
23
await this . $analyticsService . track ( "Template used for project creation" , templateName ) ;
24
24
25
- await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
26
- action : constants . TrackActionNames . CreateProject ,
27
- isForDevice : null ,
28
- additionalData : this . getTemplateNameToBeTracked ( templateName , realTemplatePath )
29
- } ) ;
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
+ }
30
33
31
34
// this removes dependencies from templates so they are not copied to app folder
32
35
this . $fs . deleteDirectory ( path . join ( realTemplatePath , constants . NODE_MODULES_FOLDER_NAME ) ) ;
@@ -48,19 +51,23 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
48
51
}
49
52
50
53
private getTemplateNameToBeTracked ( templateName : string , realTemplatePath : string ) : string {
51
- if ( this . $fs . exists ( templateName ) ) {
52
- // local template is used
53
- const pathToPackageJson = path . join ( realTemplatePath , constants . PACKAGE_JSON_FILE_NAME ) ;
54
- let templateNameToTrack = path . basename ( templateName ) ;
55
- if ( this . $fs . exists ( pathToPackageJson ) ) {
56
- const templatePackageJsonContent = this . $fs . readJson ( pathToPackageJson ) ;
57
- templateNameToTrack = templatePackageJsonContent . name ;
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 } ` ;
58
65
}
59
66
60
- return `${ constants . ANALYTICS_LOCAL_TEMPLATE_PREFIX } ${ templateNameToTrack } ` ;
67
+ return templateName ;
68
+ } catch ( err ) {
69
+ this . $logger . trace ( `Unable to get template name to be tracked, error is: ${ err } ` ) ;
61
70
}
62
-
63
- return templateName ;
64
71
}
65
72
}
66
73
$injector . register ( "projectTemplatesService" , ProjectTemplatesService ) ;
0 commit comments