Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherrypick analytics update #10372

Merged
merged 4 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions src/DynamoCore/Logging/DynamoAnalyticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ public void Dispose()
else
StabilityCookie.WriteCleanShutdown();

Service.ShutDown();
//Unregister the GATrackerFactory only after shutdown is recorded.
//Unregister is required, so that the host app can re-start Analytics service.
Service.Instance.Unregister(GATrackerFactory.Name);
// If the Analytics Client was initialized, shut it down.
// Otherwise skip this step because it would cause an exception.
if (Service.IsInitialized)
{
Service.ShutDown();
// Unregister the GATrackerFactory only after shutdown is recorded.
// Unregister is required, so that the host app can re-start Analytics service.
Service.Instance.Unregister(GATrackerFactory.Name);
}

if (null != heartbeat)
Heartbeat.DestroyInstance();
Expand Down Expand Up @@ -123,14 +128,27 @@ public void Dispose() { }

public virtual IAnalyticsSession Session { get; private set; }

/// <summary>
/// Return if Analytics Client is allowed to send analytics info
/// </summary>
public bool ReportingAnalytics
{
get { return preferences != null && preferences.IsAnalyticsReportingApproved; }
get
{
return preferences != null
&& Service.IsInitialized
&& preferences.IsAnalyticsReportingApproved;
}
}

/// <summary>
/// Return if Analytics Client is allowed to send instrumentation info
/// </summary>
public bool ReportingUsage
{
get { return preferences != null && preferences.IsUsageReportingApproved; }
get { return preferences != null
&& Service.IsInitialized
&& preferences.IsUsageReportingApproved; }
}

/// <summary>
Expand Down Expand Up @@ -160,12 +178,14 @@ public DynamoAnalyticsClient(DynamoModel dynamoModel)
/// </summary>
public void Start()
{
//If not ReportingAnalytics, then set the idle time as infinite so idle state is not recorded.
Service.StartUp(product,
new UserInfo(Session.UserId), ReportingAnalytics ? TimeSpan.FromMinutes(30) : TimeSpan.MaxValue);

TrackPreferenceInternal("ReportingAnalytics", "", ReportingAnalytics ? 1 : 0);
TrackPreferenceInternal("ReportingUsage", "", ReportingUsage ? 1 : 0);
if (preferences!= null && preferences.IsAnalyticsReportingApproved)
{
//If not ReportingAnalytics, then set the idle time as infinite so idle state is not recorded.
Service.StartUp(product,
new UserInfo(Session.UserId), preferences.IsAnalyticsReportingApproved ? TimeSpan.FromMinutes(30) : TimeSpan.MaxValue);
TrackPreferenceInternal("ReportingAnalytics", "", ReportingAnalytics ? 1 : 0);
TrackPreferenceInternal("ReportingUsage", "", ReportingUsage ? 1 : 0);
}
}

public void ShutDown()
Expand Down
58 changes: 18 additions & 40 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 6 additions & 19 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -768,25 +768,9 @@ You will get a chance to save your work.</value>
<value>Decimal Inch</value>
<comment>Setting menu | Decimal inch</comment>
</data>
<data name="DynamoViewSettingMenuEnableDataReporting" xml:space="preserve">
<value>Enable detailed usability data reporting (Instrumentation)</value>
<comment>Setting menu | Enable data reporting during usage</comment>
</data>
<data name="DynamoViewSettingMenuEnableDataReportingTooltip" xml:space="preserve">
<value>Detailed reporting sends behaviour data that we use for improving {0}.

It includes the graph being created as well as errors and warnings</value>
<comment>Setting menu | Tooltip for enable data reporting during usage menu item</comment>
</data>
<data name="DynamoViewSettingMenuEnableSummaryReporting" xml:space="preserve">
<value>Enable anonymous summary reporting (Google Analytics)</value>
<comment>Setting menu | Enable summary reporting</comment>
</data>
<data name="DynamoViewSettingMenuEnableSummaryReportingTooltip" xml:space="preserve">
<value>Anonymous summary reporting sends a minimal set of data for computing user counts, stability and performance metrics.

It does not contain your graph or any personal data</value>
<comment>Setting menu | Tooltip for enable summary reporting during usage menu item</comment>
<data name="DynamoViewSettingMenuShowDataReportingDialog" xml:space="preserve">
<value>Agreement to Collect Usability Data</value>
<comment>Setting menu | Show user agreement dialog about data collecting</comment>
</data>
<data name="DynamoViewSettingMenuFractionalFoot" xml:space="preserve">
<value>Fractional Foot</value>
Expand Down Expand Up @@ -2199,4 +2183,7 @@ Do you want to install the latest Dynamo update?</value>
<data name="RerunButtonToolTip" xml:space="preserve">
<value>Rerun the graph.</value>
</data>
<data name="DynamoViewSettingMenuShowDataReportingDialogTooltip" xml:space="preserve">
<value>Display the dialog for user to pick agreement on data collecting.</value>
</data>
</root>
25 changes: 6 additions & 19 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -482,25 +482,9 @@
<value>Decimal Inch</value>
<comment>Setting menu | Decimal inch</comment>
</data>
<data name="DynamoViewSettingMenuEnableDataReporting" xml:space="preserve">
<value>Enable detailed usability data reporting (Instrumentation)</value>
<comment>Setting menu | Enable data reporting during usage</comment>
</data>
<data name="DynamoViewSettingMenuEnableDataReportingTooltip" xml:space="preserve">
<value>Detailed reporting sends behaviour data that we use for improving {0}.

It includes the graph being created as well as errors and warnings</value>
<comment>Setting menu | Tooltip for enable data reporting during usage menu item</comment>
</data>
<data name="DynamoViewSettingMenuEnableSummaryReporting" xml:space="preserve">
<value>Enable anonymous summary reporting (Google Analytics)</value>
<comment>Setting menu | Enable summary reporting</comment>
</data>
<data name="DynamoViewSettingMenuEnableSummaryReportingTooltip" xml:space="preserve">
<value>Anonymous summary reporting sends a minimal set of data for computing user counts, stability and performance metrics.

It does not contain your graph or any personal data</value>
<comment>Setting menu | Tooltip for enable summary reporting during usage menu item</comment>
<data name="DynamoViewSettingMenuShowDataReportingDialog" xml:space="preserve">
<value>Agreement to Collect Usability Data</value>
<comment>Setting menu | Show user agreement dialog about data collecting</comment>
</data>
<data name="DynamoViewSettingShowRunPreview" xml:space="preserve">
<value>Show Run Preview</value>
Expand Down Expand Up @@ -2196,4 +2180,7 @@ Want to publish a different package?</value>
<value>Custom Nodes will be placed in the Add-Ons section of the library.</value>
<comment>Note regarding Custom Node library location</comment>
</data>
<data name="DynamoViewSettingMenuShowDataReportingDialogTooltip" xml:space="preserve">
<value>Display the dialog for user to pick agreement on data collecting.</value>
</data>
</root>
30 changes: 13 additions & 17 deletions src/DynamoCoreWpf/Services/UsageReportingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ private set

public UsageReportingManager()
{
ToggleIsUsageReportingApprovedCommand = new DelegateCommand(
ToggleIsUsageReportingApproved, p => true);
ToggleIsAnalyticsReportingApprovedCommand = new DelegateCommand(
ToggleIsAnalyticsReportingApproved, p => true);
}
Expand All @@ -163,6 +161,7 @@ public void CheckIsFirstRun(Window ownerWindow, IBrandingResourceProvider resour
}
}

[Obsolete("Function will be deprecated in Dynamo 3.0, please set IsUsageReportingApproved.")]
public void ToggleIsUsageReportingApproved(object parameter)
{
var ownerWindow = parameter as Window;
Expand Down Expand Up @@ -195,27 +194,24 @@ public void ToggleIsAnalyticsReportingApproved(object parameter)
throw new InvalidOperationException(
"DynamoView must be supplied for this command");
}

// If reporting is not currently enabled, then the user should be
// shown the agreement dialog (on which he/she can choose to accept
// or reject the reporting). If the reporting is currently enabled,
// then set it to false (user chooses not to accept the reporting).
//
if (IsAnalyticsReportingApproved)
{
IsAnalyticsReportingApproved = false;
}
else
{
ShowUsageReportingPrompt(ownerWindow);
}
ShowUsageReportingPrompt(ownerWindow);
}

/// <summary>
/// Setting UsageReportingAgreement. Please notice
/// that IsUsageReportingApproved is dominated by
/// IsAnalyticsReportingApproved.
/// </summary>
/// <param name="approved"></param>
public void SetUsageReportingAgreement(bool approved)
{
IsUsageReportingApproved = approved;
IsUsageReportingApproved = approved && IsAnalyticsReportingApproved;
}

/// <summary>
/// Setting AnalyticsReportingAgreement.
/// </summary>
/// <param name="approved"></param>
public void SetAnalyticsReportingAgreement(bool approved)
{
IsAnalyticsReportingApproved = approved;
Expand Down
48 changes: 26 additions & 22 deletions src/DynamoCoreWpf/UI/Prompts/UsageReportingAgreementPrompt.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

<Grid.RowDefinitions>
<RowDefinition Height="100"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="160"></RowDefinition>
<RowDefinition Height="160"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
Expand Down Expand Up @@ -52,26 +52,8 @@
BorderThickness="0" />
</ScrollViewer>

<CheckBox x:Name="AcceptAnalyticsReportingCheck"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
Click="ToggleIsAnalyticsReportingChecked"
Margin="15,16,15,14"
VerticalAlignment="Center"
Foreground="#4790cd"
FontSize="13.333"
Background="White"
IsChecked="True">
<TextBlock FontWeight="SemiBold"
Foreground="#4790cd"
TextWrapping="Wrap"
Name="AcceptAnalyticsReportingTextBlock"
Text="{x:Static p:Resources.ConsentFormGoogleAnalyticsCheckBoxContent}"/>
</CheckBox>

<ScrollViewer Background="#363636"
Grid.Row="3"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
HorizontalScrollBarVisibility="Disabled"
Expand All @@ -87,12 +69,32 @@
BorderThickness="0" />
</ScrollViewer>

<CheckBox x:Name="AcceptAnalyticsReportingCheck"
Grid.Row="3"
Grid.Column="0"
Grid.ColumnSpan="2"
Click="ToggleIsAnalyticsReportingChecked"
Margin="15,16,15,0"
VerticalAlignment="Center"
Foreground="#4790cd"
FontSize="13.333"
Background="White"
IsChecked="True">
<TextBlock FontWeight="SemiBold"
Foreground="#4790cd"
TextWrapping="Wrap"
Name="AcceptAnalyticsReportingTextBlock"
Text="{x:Static p:Resources.ConsentFormGoogleAnalyticsCheckBoxContent}"/>
</CheckBox>

<!--The instrumentation checkbox will be hidden and unchecked by default-->
<CheckBox x:Name="AcceptUsageReportingCheck"
Grid.Row="4"
Grid.Column="0"
Grid.ColumnSpan="2"
Click="ToggleIsUsageReportingChecked"
Margin="15,16,15,14"
Visibility="Hidden"
Margin="35,16,15,14"
VerticalAlignment="Center"
Foreground="#4790cd"
FontSize="13.333"
Expand All @@ -103,6 +105,7 @@
Name="AcceptUsageReportingTextBlock"/>
</CheckBox>

<!--Learn More Button-->
<TextBlock Grid.Row="5"
Grid.Column="0"
Margin="15,0,15,0"
Expand All @@ -115,6 +118,7 @@
</Hyperlink>
</TextBlock>

<!--Continue Button-->
<Button Grid.Row="5"
Grid.Column="1"
x:Name="okButton"
Expand Down
Loading