Skip to content

Commit 16f2c43

Browse files
authored
Improved cc-award component
Improved cc-award component
2 parents be44593 + eb78c38 commit 16f2c43

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

docs/javascripts/cc-award.js

+36-13
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
// #functionsBaseUrl = 'http://localhost:7071/api/'; // Local testing
6363
#functionsBaseUrl = 'https://cc-awards.azurewebsites.net/api/'; // Production
6464

65+
#badgeClaimedTrackingUrl = 'https://m365-visitor-stats.azurewebsites.net/copilot-camp/badge-claimed/'; // Badge claimed tracking URL
66+
6567
#debugMode = false; // Debug mode
6668

6769
constructor() {
@@ -101,7 +103,7 @@
101103
awardButton.className = 'award-button';
102104
awardButton.onclick = this.#clickHandler;
103105
this.#containerElement.appendChild(awardButton);
104-
106+
105107
// Hide the container by default
106108
this.#containerElement.style.display = 'none';
107109

@@ -184,19 +186,40 @@
184186
}
185187

186188
async #updateAwardStatus(pathName, isEligible) {
187-
// Update the award status for the current user
188-
const uniqueId = this.#ensureAwardUniqueId();
189-
const awardStatusUrl = `${this.#functionsBaseUrl}assignAward/${uniqueId}/${pathName}`;
190-
const response = await fetch(awardStatusUrl, {
191-
method: 'POST',
192-
headers: {
193-
'Content-Type': 'application/json'
194-
},
195-
body: JSON.stringify({ status: isEligible })
196-
});
197-
if (!response.ok) {
198-
console.error('Failed to update award status:', response.status, response.statusText);
189+
190+
try {
191+
// Update the award status for the current user
192+
const uniqueId = this.#ensureAwardUniqueId();
193+
const awardStatusUrl = `${this.#functionsBaseUrl}assignAward/${uniqueId}/${pathName}`;
194+
const awardStatusResponse = await fetch(awardStatusUrl, {
195+
method: 'POST',
196+
headers: {
197+
'Content-Type': 'application/json'
198+
},
199+
body: JSON.stringify({ status: isEligible })
200+
});
201+
if (!awardStatusResponse.ok) {
202+
console.error('Failed to update award status via API:', awardStatusResponse.status, awardStatusResponse.statusText);
203+
}
204+
} catch (error) {
205+
console.error('Failed to update award status:', error);
206+
}
207+
208+
try {
209+
if (isEligible) {
210+
// Track the award status on telemetry
211+
const awardTrackingUrl = `${this.#badgeClaimedTrackingUrl}${pathName}`;
212+
const trackingResponse = await fetch(awardTrackingUrl, {
213+
method: 'GET'
214+
});
215+
if (!trackingResponse.ok) {
216+
console.error('Failed to track award status via telemetry:', response.status, response.statusText);
217+
}
218+
}
219+
} catch (error) {
220+
console.error('Failed to track award status:', error);
199221
}
222+
200223
}
201224

202225
// Public method to check award eligibility

docs/pages/make/copilot-studio/05-connectors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,6 @@ Wonderful! You were able to configure a custom connector and consume it within M
280280

281281
You have completed Lab MCS5 - Power Platform custom connector!
282282

283-
<!-- <cc-award path="Make" /> -->
283+
<cc-award path="Make" />
284284

285285
<img src="https://m365-visitor-stats.azurewebsites.net/copilot-camp/make/copilot-studio/05-connectors" />

0 commit comments

Comments
 (0)