@iblai/iblai-js 2.2.10 → 2.3.0
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.
|
@@ -254,7 +254,7 @@ function useTimeTracking(config = {}) {
|
|
|
254
254
|
}
|
|
255
255
|
}, [config.getTenantKey, config.getMentorId]);
|
|
256
256
|
const handleTimeUpdate = useCallback(async (url, timeSpent) => {
|
|
257
|
-
var _a;
|
|
257
|
+
var _a, _b, _c;
|
|
258
258
|
// Check if user is logged in before making time tracking API call
|
|
259
259
|
if (config.storageService) {
|
|
260
260
|
try {
|
|
@@ -278,6 +278,10 @@ function useTimeTracking(config = {}) {
|
|
|
278
278
|
const currentSessionUuid = config.getSessionUuid
|
|
279
279
|
? config.getSessionUuid()
|
|
280
280
|
: config.sessionUuid;
|
|
281
|
+
// Course/unit context is resolved per-update from the tracked URL (not
|
|
282
|
+
// cached like tenant/mentor) because it changes as the user navigates.
|
|
283
|
+
const courseId = (_a = config.getCourseId) === null || _a === void 0 ? void 0 : _a.call(config, url);
|
|
284
|
+
const blockId = (_b = config.getBlockId) === null || _b === void 0 ? void 0 : _b.call(config, url);
|
|
281
285
|
const timeTrackingData = {
|
|
282
286
|
timestamp: new Date().toISOString(),
|
|
283
287
|
url: url,
|
|
@@ -285,8 +289,10 @@ function useTimeTracking(config = {}) {
|
|
|
285
289
|
count: Math.floor(timeSpent / 1000), // Convert milliseconds to seconds
|
|
286
290
|
...(mentorId && { mentor_uuid: mentorId }),
|
|
287
291
|
...(currentSessionUuid && { session_uuid: currentSessionUuid }),
|
|
292
|
+
...(courseId && { course_id: courseId }),
|
|
293
|
+
...(blockId && { block_id: blockId }),
|
|
288
294
|
};
|
|
289
|
-
if ((
|
|
295
|
+
if ((_c = config.storageService) === null || _c === void 0 ? void 0 : _c.getItem(LOCAL_STORAGE_KEYS.USER_DATA)) {
|
|
290
296
|
await timeTracking(timeTrackingData).unwrap();
|
|
291
297
|
}
|
|
292
298
|
else {
|
|
@@ -298,7 +304,7 @@ function useTimeTracking(config = {}) {
|
|
|
298
304
|
...(currentSessionUuid && { sessionUuid: currentSessionUuid }),
|
|
299
305
|
});
|
|
300
306
|
}
|
|
301
|
-
catch (
|
|
307
|
+
catch (_d) {
|
|
302
308
|
// console.error('Failed to send time tracking data:', error);
|
|
303
309
|
// Don't throw the error to prevent disrupting the user experience
|
|
304
310
|
}
|
|
@@ -307,6 +313,8 @@ function useTimeTracking(config = {}) {
|
|
|
307
313
|
mentorId,
|
|
308
314
|
config.getSessionUuid,
|
|
309
315
|
config.sessionUuid,
|
|
316
|
+
config.getCourseId,
|
|
317
|
+
config.getBlockId,
|
|
310
318
|
config.storageService,
|
|
311
319
|
timeTracking,
|
|
312
320
|
]);
|
|
@@ -181658,10 +181666,13 @@ function TopBanner({ parentContainerSelector, bannerText = '', loading = false,
|
|
|
181658
181666
|
* getSessionUuid={() => getCurrentSessionId()}
|
|
181659
181667
|
* getTenantKey={() => localStorage.getItem('tenant') || ''}
|
|
181660
181668
|
* getMentorId={() => extractMentorIdFromUrl()}
|
|
181669
|
+
* // Course/unit context is parsed from the URL the time was spent on:
|
|
181670
|
+
* getCourseId={(url) => parseCourseId(url)}
|
|
181671
|
+
* getBlockId={(url) => parseUnitId(url)}
|
|
181661
181672
|
* />
|
|
181662
181673
|
* ```
|
|
181663
181674
|
*/
|
|
181664
|
-
function TimeTrackingProvider({ intervalSeconds = 30, enabled = true, sessionUuid, getSessionUuid, getTenantKey, getMentorId, getCurrentUrl, onRouteChange, }) {
|
|
181675
|
+
function TimeTrackingProvider({ intervalSeconds = 30, enabled = true, sessionUuid, getSessionUuid, getTenantKey, getMentorId, getCourseId, getBlockId, getCurrentUrl, onRouteChange, }) {
|
|
181665
181676
|
// Initialize time tracking
|
|
181666
181677
|
useTimeTracking({
|
|
181667
181678
|
intervalSeconds,
|
|
@@ -181670,6 +181681,8 @@ function TimeTrackingProvider({ intervalSeconds = 30, enabled = true, sessionUui
|
|
|
181670
181681
|
getSessionUuid,
|
|
181671
181682
|
getTenantKey,
|
|
181672
181683
|
getMentorId,
|
|
181684
|
+
getCourseId,
|
|
181685
|
+
getBlockId,
|
|
181673
181686
|
getCurrentUrl,
|
|
181674
181687
|
onRouteChange,
|
|
181675
181688
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iblai/iblai-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Unified JavaScript SDK for IBL.ai — re-exports data-layer, web-containers, and web-utils under a single package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -76,9 +76,9 @@
|
|
|
76
76
|
"axios": "1.13.6",
|
|
77
77
|
"dotenv": "16.6.1",
|
|
78
78
|
"winston": "3.19.0",
|
|
79
|
-
"@iblai/data-layer": "1.11.3",
|
|
80
|
-
"@iblai/web-containers": "1.15.11",
|
|
81
79
|
"@iblai/mcp": "1.8.7",
|
|
80
|
+
"@iblai/data-layer": "1.12.0",
|
|
81
|
+
"@iblai/web-containers": "1.16.0",
|
|
82
82
|
"@iblai/web-utils": "2.1.8"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|