Skip to content

Commit 77a938c

Browse files
Merge pull request #4203 from NativeScript/vladimirov/track-accept-tracking
feat: add tracking for answer is we can track
2 parents d6198c6 + 92d9d56 commit 77a938c

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

lib/constants.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export const enum TrackActionNames {
150150
RunSetupScript = "Run Setup Script",
151151
CheckLocalBuildSetup = "Check Local Build Setup",
152152
CheckEnvironmentRequirements = "Check Environment Requirements",
153-
Options = "Options"
153+
Options = "Options",
154+
AcceptTracking = "Accept Tracking"
154155
}
155156

156157
export const AnalyticsEventLabelDelimiter = "__";

lib/services/analytics/analytics-service.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from "path";
33
import { cache } from "../../common/decorators";
44
import { isInteractive, toBoolean } from '../../common/helpers';
55
import { DeviceTypes, AnalyticsClients } from "../../common/constants";
6+
import { TrackActionNames } from "../../constants";
67

78
export class AnalyticsService implements IAnalyticsService, IDisposable {
89
private static ANALYTICS_BROKER_START_TIMEOUT = 10 * 1000;
@@ -72,10 +73,14 @@ export class AnalyticsService implements IAnalyticsService, IDisposable {
7273
}
7374

7475
public async trackAcceptFeatureUsage(settings: { acceptTrackFeatureUsage: boolean }): Promise<void> {
75-
await this.sendMessageToBroker(<IAcceptUsageReportingInformation>{
76-
type: TrackingTypes.AcceptTrackFeatureUsage,
77-
acceptTrackFeatureUsage: settings.acceptTrackFeatureUsage
78-
});
76+
const acceptTracking = !!(settings && settings.acceptTrackFeatureUsage);
77+
const googleAnalyticsEventData: IGoogleAnalyticsEventData = {
78+
googleAnalyticsDataType: GoogleAnalyticsDataType.Event,
79+
action: TrackActionNames.AcceptTracking,
80+
label: acceptTracking.toString()
81+
};
82+
83+
await this.forcefullyTrackInGoogleAnalytics(googleAnalyticsEventData);
7984
}
8085

8186
public async trackInGoogleAnalytics(gaSettings: IGoogleAnalyticsData): Promise<void> {

lib/services/analytics/analytics.d.ts

-10
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ interface ITrackingInformation {
88
type: TrackingTypes
99
}
1010

11-
/**
12-
* Describes if the user allows to be tracked.
13-
*/
14-
interface IAcceptUsageReportingInformation extends ITrackingInformation {
15-
/**
16-
* The answer of the question if user allows us to track them.
17-
*/
18-
acceptTrackFeatureUsage: boolean;
19-
}
20-
2111
/**
2212
* Describes information for exception that should be tracked.
2313
*/

0 commit comments

Comments
 (0)