@learningpool/ui 1.15.1 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -57,11 +57,17 @@ import { defaultAttributes } from '../../../utils/dataAttributes';
|
|
|
57
57
|
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
58
58
|
import PromotionalCampaignItem from './PromotionalCampaignItem';
|
|
59
59
|
var addUtmParams = function (baseUrl, source, medium, campaign) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
try {
|
|
61
|
+
var url = new URL(baseUrl);
|
|
62
|
+
url.searchParams.append('utm_source', source);
|
|
63
|
+
url.searchParams.append('utm_medium', medium);
|
|
64
|
+
url.searchParams.append('utm_campaign', campaign);
|
|
65
|
+
return url.toString();
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('Error adding UTM params to advert redirect - invalid URL:', baseUrl, error);
|
|
69
|
+
return baseUrl;
|
|
70
|
+
}
|
|
65
71
|
};
|
|
66
72
|
var AppSwitcher = function (props) {
|
|
67
73
|
var _a;
|
|
@@ -87,7 +93,7 @@ var AppSwitcher = function (props) {
|
|
|
87
93
|
* @returns {Promise<IApplication[]>} Get a Promotional Campaign to show.
|
|
88
94
|
*/
|
|
89
95
|
var getLatestPromotionalCampaign = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
-
var response, data, error_1;
|
|
96
|
+
var response, responseData, data, error_1;
|
|
91
97
|
return __generator(this, function (_a) {
|
|
92
98
|
switch (_a.label) {
|
|
93
99
|
case 0:
|
|
@@ -108,15 +114,14 @@ var AppSwitcher = function (props) {
|
|
|
108
114
|
case 2:
|
|
109
115
|
response = _a.sent();
|
|
110
116
|
if (!response.ok) {
|
|
111
|
-
console.error('Unable to retrieve latest promotional campaign from
|
|
117
|
+
console.error('Unable to retrieve latest promotional campaign from Hub API, returned statuscode:', response.status);
|
|
112
118
|
return [2 /*return*/, null];
|
|
113
119
|
}
|
|
114
|
-
return [4 /*yield*/, response.json()
|
|
115
|
-
// Store the latest access token.
|
|
116
|
-
];
|
|
120
|
+
return [4 /*yield*/, response.json()];
|
|
117
121
|
case 3:
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
responseData = _a.sent();
|
|
123
|
+
data = responseData.records;
|
|
124
|
+
// Store the latest access token
|
|
120
125
|
window.localStorage.setItem(Constants.LocalStorageKey.Token, token);
|
|
121
126
|
return [2 /*return*/, (data === null || data === void 0 ? void 0 : data.map(function (_a) {
|
|
122
127
|
var id = _a.id, name = _a.name, appSwitcherImageUrl = _a.appSwitcherImageUrl, hubImageUrl = _a.hubImageUrl, altText = _a.altText, basePromoUrl = _a.basePromoUrl, isActive = _a.isActive;
|
|
@@ -132,7 +137,7 @@ var AppSwitcher = function (props) {
|
|
|
132
137
|
})) || null];
|
|
133
138
|
case 4:
|
|
134
139
|
error_1 = _a.sent();
|
|
135
|
-
console.error('Unable to retrieve latest promotional campaign from
|
|
140
|
+
console.error('Unable to retrieve and display latest promotional campaign from Hub API', error_1);
|
|
136
141
|
return [2 /*return*/, null];
|
|
137
142
|
case 5: return [2 /*return*/];
|
|
138
143
|
}
|