Skip to content

Commit e30d8d3

Browse files
authored
[25.x] [Copilot] Add telemetry when data movement is updated (#3321)
<!-- Thank you for submitting a Pull Request. If you're new to contributing to BCApps please read our pull request guideline below * https://github.com/microsoft/BCApps/Contributing.md --> #### Summary <!-- Provide a general summary of your changes --> Add telemetry when data movement is updated. Also emit once during install and upgrade to get current state. #### Work Item(s) <!-- Add the issue number here after the #. The issue needs to be open and approved. Submitting PRs with no linked issues or unapproved issues is highly discouraged. --> Fixes [AB#571729](https://dynamicssmb2.visualstudio.com/Dynamics%20SMB/_workitems/edit/571729)
1 parent 6762e4d commit e30d8d3

6 files changed

+130
-10
lines changed

src/System Application/App/AI/app.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
"publisher": "Microsoft",
3030
"version": "25.6.0.0"
3131
},
32+
{
33+
"id": "93b83ef6-9666-4c1d-b130-c232f4047621",
34+
"name": "Upgrade Tags",
35+
"publisher": "Microsoft",
36+
"version": "25.6.0.0"
37+
},
3238
{
3339
"id": "7e3b999e-1182-45d2-8b82-d5127ddba9b2",
3440
"publisher": "Microsoft",
@@ -90,7 +96,7 @@
9096
"idRanges": [
9197
{
9298
"from": 7758,
93-
"to": 7778
99+
"to": 7782
94100
}
95101
],
96102
"target": "OnPrem",

src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al

+4-9
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,7 @@ page 7775 "Copilot AI Capabilities"
248248
OnRegisterCopilotCapability();
249249

250250
CopilotCapabilityImpl.CheckGeoAndEUDB(WithinGeo, WithinEUDB);
251-
252-
case PrivacyNotice.GetPrivacyNoticeApprovalState(CopilotCapabilityImpl.GetAzureOpenAICategory(), false) of
253-
Enum::"Privacy Notice Approval State"::Agreed:
254-
AllowDataMovement := true;
255-
Enum::"Privacy Notice Approval State"::Disagreed:
256-
AllowDataMovement := false;
257-
else
258-
AllowDataMovement := true;
259-
end;
251+
CopilotCapabilityImpl.GetDataMovementAllowed(AllowDataMovement);
260252

261253
AllowDataMovementEditable := CopilotCapabilityImpl.IsAdmin();
262254

@@ -277,6 +269,8 @@ page 7775 "Copilot AI Capabilities"
277269
end;
278270

279271
local procedure UpdateAllowDataMovement()
272+
var
273+
CopilotTelemetry: Codeunit "Copilot Telemetry";
280274
begin
281275
if AllowDataMovement then
282276
PrivacyNotice.SetApprovalState(CopilotCapabilityImpl.GetAzureOpenAICategory(), Enum::"Privacy Notice Approval State"::Agreed)
@@ -286,6 +280,7 @@ page 7775 "Copilot AI Capabilities"
286280
CurrPage.GenerallyAvailableCapabilities.Page.SetDataMovement(AllowDataMovement);
287281
CurrPage.PreviewCapabilities.Page.SetDataMovement(AllowDataMovement);
288282
CopilotCapabilityImpl.UpdateGuidedExperience(AllowDataMovement);
283+
CopilotTelemetry.SendCopilotDataMovementUpdatedTelemetry(AllowDataMovement);
289284
end;
290285

291286
[IntegrationEvent(false, false)]

src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al

+14
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,20 @@ codeunit 7774 "Copilot Capability Impl"
263263
WithinEUDB := ALCopilotFunctions.IsWithinEUDB();
264264
end;
265265

266+
procedure GetDataMovementAllowed(var AllowDataMovement: Boolean)
267+
var
268+
PrivacyNotice: Codeunit "Privacy Notice";
269+
begin
270+
case PrivacyNotice.GetPrivacyNoticeApprovalState(GetAzureOpenAICategory(), false) of
271+
Enum::"Privacy Notice Approval State"::Agreed:
272+
AllowDataMovement := true;
273+
Enum::"Privacy Notice Approval State"::Disagreed:
274+
AllowDataMovement := false;
275+
else
276+
AllowDataMovement := true;
277+
end;
278+
end;
279+
266280
procedure UpdateGuidedExperience(AllowDataMovement: Boolean)
267281
var
268282
GuidedExperience: Codeunit "Guided Experience";

src/System Application/App/AI/src/Copilot/CopilotTelemetry.Codeunit.al

+38
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace System.AI;
66

77
using System.Telemetry;
8+
using System.Globalization;
89

910
/// <summary>
1011
/// This codeunit is called from Platform.
@@ -21,6 +22,7 @@ codeunit 7775 "Copilot Telemetry"
2122
AppId: Guid;
2223
TelemetryFeedbackOnCopilotCapabilityLbl: Label 'Feedback on Copilot Capability.', Locked = true;
2324
TelemetryActionInvokedOnCopilotCapabilityLbl: Label 'Action invoked on Copilot Capability.', Locked = true;
25+
TelemetryAllowDataMovementUpdatedLbl: Label 'Allow data movement was updated.', Locked = true;
2426

2527
procedure SetCopilotCapability(NewCopilotCapability: Enum "Copilot Capability"; NewAppId: Guid)
2628
begin
@@ -47,4 +49,40 @@ codeunit 7775 "Copilot Telemetry"
4749
CopilotCapabilitiesImpl.AddTelemetryDimensions(CopilotCapability, AppId, CustomDimensions);
4850
FeatureTelemetry.LogUsage('0000LLW', CopilotCapabilitiesImpl.GetCopilotCategory(), TelemetryActionInvokedOnCopilotCapabilityLbl, CustomDimensions);
4951
end;
52+
53+
procedure SendCopilotDataMovementUpdatedTelemetry()
54+
var
55+
CopilotCapabilityImpl: Codeunit "Copilot Capability Impl";
56+
AllowDataMovement: Boolean;
57+
begin
58+
CopilotCapabilityImpl.GetDataMovementAllowed(AllowDataMovement);
59+
60+
SendCopilotDataMovementUpdatedTelemetry(AllowDataMovement);
61+
end;
62+
63+
procedure SendCopilotDataMovementUpdatedTelemetry(AllowDataMovement: Boolean)
64+
var
65+
CopilotCapabilitiesImpl: Codeunit "Copilot Capability Impl";
66+
FeatureTelemetry: Codeunit "Feature Telemetry";
67+
Language: Codeunit Language;
68+
CustomDimensions: Dictionary of [Text, Text];
69+
WithinGeo: Boolean;
70+
WithinEUDB: Boolean;
71+
SavedGlobalLanguageId: Integer;
72+
begin
73+
CopilotCapabilitiesImpl.CheckGeoAndEUDB(WithinGeo, WithinEUDB);
74+
75+
SavedGlobalLanguageId := GlobalLanguage();
76+
77+
GlobalLanguage(Language.GetDefaultApplicationLanguageId());
78+
79+
CustomDimensions.Add('Category', CopilotCapabilitiesImpl.GetCopilotCategory());
80+
CustomDimensions.Add('AllowDataMovement', Format(AllowDataMovement));
81+
CustomDimensions.Add('WithinGeo', Format(WithinGeo));
82+
CustomDimensions.Add('WithinEUDB', Format(WithinEUDB));
83+
84+
GlobalLanguage(SavedGlobalLanguageId);
85+
86+
FeatureTelemetry.LogUsage('0000OQK', CopilotCapabilitiesImpl.GetCopilotCategory(), TelemetryAllowDataMovementUpdatedLbl, CustomDimensions);
87+
end;
5088
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// ------------------------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License. See License.txt in the project root for license information.
4+
// ------------------------------------------------------------------------------------------------
5+
namespace System.AI;
6+
7+
codeunit 7782 "Copilot Telemetry Install"
8+
{
9+
Subtype = Install;
10+
InherentEntitlements = X;
11+
InherentPermissions = X;
12+
13+
trigger OnInstallAppPerDatabase()
14+
var
15+
CopilotTelemetryUpgrade: Codeunit "Copilot Telemetry Upgrade";
16+
begin
17+
CopilotTelemetryUpgrade.SendCopilotDataMovementUpgradeTelemetry();
18+
end;
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// ------------------------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License. See License.txt in the project root for license information.
4+
// ------------------------------------------------------------------------------------------------
5+
namespace System.AI;
6+
7+
using System.Upgrade;
8+
using System.Environment;
9+
10+
codeunit 7781 "Copilot Telemetry Upgrade"
11+
{
12+
Subtype = Upgrade;
13+
InherentEntitlements = X;
14+
InherentPermissions = X;
15+
16+
trigger OnUpgradePerDatabase()
17+
begin
18+
SendCopilotDataMovementUpgradeTelemetry();
19+
end;
20+
21+
internal procedure SendCopilotDataMovementUpgradeTelemetry()
22+
var
23+
UpgradeTag: Codeunit "Upgrade Tag";
24+
CopilotTelemetry: Codeunit "Copilot Telemetry";
25+
EnvironmentInformation: Codeunit "Environment Information";
26+
begin
27+
if EnvironmentInformation.IsOnPrem() then
28+
exit;
29+
30+
if UpgradeTag.HasUpgradeTag(GetSendCopilotDataMovementUpgradeTelemetryTag(), '') then
31+
exit;
32+
33+
CopilotTelemetry.SendCopilotDataMovementUpdatedTelemetry();
34+
35+
UpgradeTag.SetUpgradeTag(GetSendCopilotDataMovementUpgradeTelemetryTag());
36+
end;
37+
38+
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Upgrade Tag", OnGetPerDatabaseUpgradeTags, '', false, false)]
39+
local procedure RegisterUpgradeTags(var PerDatabaseUpgradeTags: List of [Code[250]])
40+
begin
41+
PerDatabaseUpgradeTags.Add(GetSendCopilotDataMovementUpgradeTelemetryTag());
42+
end;
43+
44+
local procedure GetSendCopilotDataMovementUpgradeTelemetryTag(): Text[250]
45+
begin
46+
exit('MS-561464-CopilotDataMovement-20250212');
47+
end;
48+
}

0 commit comments

Comments
 (0)