@@ -54,15 +54,47 @@ const finishTracking = async (data?: ITrackingInformation) => {
54
54
}
55
55
} ;
56
56
57
+ const trackPreviewAppData = async ( data : any ) => {
58
+ const mobileHelper = $injector . resolve < Mobile . IMobileHelper > ( "mobileHelper" ) ;
59
+ const devicesService = $injector . resolve < Mobile . IDevicesService > ( "devicesService" ) ;
60
+ await devicesService . initialize ( { platform : data . platform , skipDeviceDetectionInterval : true , skipEmulatorStart : true } ) ;
61
+
62
+ const devices = await devicesService . getDevicesForPlatform ( data . platform ) ;
63
+ _ . each ( devices , async ( device : Mobile . IDevice ) => {
64
+ try {
65
+ let previewAppFilePath = null ;
66
+ if ( mobileHelper . isAndroidPlatform ( device . deviceInfo . platform ) ) {
67
+ previewAppFilePath = "/sdcard/org.nativescript.preview/device.json" ;
68
+ } else if ( mobileHelper . isiOSPlatform ( device . deviceInfo . platform ) ) {
69
+ previewAppFilePath = "Documents/device.json" ;
70
+ }
71
+
72
+ const previewAppFileContent = await device . fileSystem . getFileContent ( previewAppFilePath , "org.nativescript.preview" ) ;
73
+ const previewAppDeviceId = JSON . parse ( previewAppFileContent ) . id ;
74
+ data . label += `_${ previewAppDeviceId } ` ;
75
+
76
+ analyticsLoggingService . logData ( { message : `analytics-broker-process will send the data from preview app: ${ data } ` } ) ;
77
+ await sendDataForTracking ( data ) ;
78
+ } catch ( err ) {
79
+ // ignore the error
80
+ }
81
+ } ) ;
82
+ } ;
83
+
57
84
process . on ( "message" , async ( data : ITrackingInformation ) => {
58
- analyticsLoggingService . logData ( { message : `analytics-broker-process received message of type: ${ data . type } ` } ) ;
85
+ analyticsLoggingService . logData ( { message : `analytics-broker-process received message of type: ${ JSON . stringify ( data ) } ` } ) ;
59
86
60
87
if ( data . type === TrackingTypes . Finish ) {
61
88
receivedFinishMsg = true ;
62
89
await finishTracking ( data ) ;
63
90
return ;
64
91
}
65
92
93
+ if ( data . type === TrackingTypes . PreviewAppData ) {
94
+ await trackPreviewAppData ( < IPreviewAppTrackingInformation > data ) ;
95
+ return ;
96
+ }
97
+
66
98
await sendDataForTracking ( data ) ;
67
99
} ) ;
68
100
0 commit comments