@patch-adams/core 1.5.18 → 1.5.19

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.
package/dist/cli.cjs CHANGED
@@ -2288,12 +2288,12 @@ function generateLrsBridgeCode(options) {
2288
2288
  // Without this override, our statements have a different object.id than cloudplayer
2289
2289
  // statements, so Analytics treats them as unrelated to the document.
2290
2290
  if (docData.guid) {
2291
- if (LRS.courseInfo.guid && LRS.courseInfo.guid !== docData.guid) {
2292
- log('Overriding baked-in GUID with Bravais GUID:', LRS.courseInfo.guid, '->', docData.guid);
2293
- }
2291
+ var oldGuid = LRS.courseInfo.guid;
2294
2292
  LRS.courseInfo.guid = docData.guid;
2295
2293
  LRS.courseInfo.id = 'http://xyleme.com/bravais/document/' + docData.guid;
2296
- log('Document GUID from API:', docData.guid);
2294
+ // Always-visible log (not behind DEBUG) so we can confirm override in production
2295
+ console.info('[PA-LRS] Document GUID set from API:', docData.guid,
2296
+ oldGuid && oldGuid !== docData.guid ? '(was: ' + oldGuid + ')' : '');
2297
2297
  }
2298
2298
 
2299
2299
  // Version GUID \u2014 same principle: Bravais version GUID must override baked-in
@@ -2602,21 +2602,20 @@ function generateLrsBridgeCode(options) {
2602
2602
  info.sharedLinkName = launchInfo.sharedLinkName || info.sharedLinkName;
2603
2603
  }
2604
2604
 
2605
- // 3b. Try to extract GUIDs from Xyleme Cloud Player's internal data
2606
- // This is more reliable than API calls which may fail with 401
2607
- if (!info.guid || !info.versionGuid) {
2608
- var cloudPlayerData = extractFromXylemeCloudPlayer();
2609
- if (cloudPlayerData) {
2610
- info.guid = cloudPlayerData.guid || info.guid;
2611
- info.versionGuid = cloudPlayerData.versionGuid || info.versionGuid;
2612
- info.documentId = cloudPlayerData.documentId || info.documentId;
2613
- info.title = cloudPlayerData.title || info.title;
2614
- log('Updated course info from Cloud Player:', {
2615
- guid: info.guid,
2616
- versionGuid: info.versionGuid,
2617
- documentId: info.documentId
2618
- });
2619
- }
2605
+ // 3b. Always try to extract GUIDs from Xyleme Cloud Player's internal data.
2606
+ // Cloud Player data is authoritative \u2014 it has the canonical Bravais GUID.
2607
+ // This overrides any baked-in GUID which is just a random UUID from wrap time.
2608
+ var cloudPlayerData = extractFromXylemeCloudPlayer();
2609
+ if (cloudPlayerData) {
2610
+ if (cloudPlayerData.guid) info.guid = cloudPlayerData.guid;
2611
+ if (cloudPlayerData.versionGuid) info.versionGuid = cloudPlayerData.versionGuid;
2612
+ info.documentId = cloudPlayerData.documentId || info.documentId;
2613
+ info.title = cloudPlayerData.title || info.title;
2614
+ log('Updated course info from Cloud Player:', {
2615
+ guid: info.guid,
2616
+ versionGuid: info.versionGuid,
2617
+ documentId: info.documentId
2618
+ });
2620
2619
  }
2621
2620
 
2622
2621
  // 4. Try getCourseTitle() from preloadIntegrity.js
@@ -5238,12 +5237,18 @@ function generateLrsBridgeCode(options) {
5238
5237
 
5239
5238
  // Always-visible bridge summary (not gated by DEBUG)
5240
5239
  // This ensures diagnostics are available even in production builds
5240
+ // Shows current GUID (may be from Cloud Player, baked-in, or pending API override)
5241
+ var currentGuid = LRS.courseInfo ? LRS.courseInfo.guid : DOCUMENT_GUID;
5242
+ var currentVerGuid = LRS.courseInfo ? LRS.courseInfo.versionGuid : VERSION_GUID;
5243
+ var sharedToken = LRS.courseInfo ? LRS.courseInfo.sharedLinkToken : null;
5241
5244
  if (window.console && window.console.info) {
5242
5245
  console.info('[PA-LRS] Bridge v' + LRS.version + ': mode=' + LRS.mode +
5243
5246
  ', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
5244
5247
  ', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
5245
- ', docGuid=' + (DOCUMENT_GUID || 'NONE') +
5246
- ', verGuid=' + (VERSION_GUID || 'NONE') +
5248
+ ', docGuid=' + (currentGuid || 'NONE') +
5249
+ (currentGuid !== DOCUMENT_GUID ? ' (overridden from baked: ' + DOCUMENT_GUID + ')' : '') +
5250
+ ', verGuid=' + (currentVerGuid || 'NONE') +
5251
+ ', sharedToken=' + (sharedToken || 'NONE') +
5247
5252
  ', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none') +
5248
5253
  ', hasRefreshActor=' + (typeof LRS.refreshActor === 'function'));
5249
5254
  }
@@ -5314,35 +5319,30 @@ function generateLrsBridgeCode(options) {
5314
5319
  });
5315
5320
  }
5316
5321
 
5317
- if (!LRS.courseInfo.guid) {
5318
- // When we have a shared link token, use /api/shared/{token}/documents directly
5319
- // This endpoint does NOT require authentication and returns both document GUID and version GUID
5320
- if (sharedLinkToken) {
5321
- log('Have shared link token, fetching document data via shared API...');
5322
- // fetchDocumentMetadata will use /api/shared/{token}/documents when sharedLinkToken is present
5323
- fetchDocumentMetadata(null, function(docData) {
5324
- if (docData) {
5325
- updateCourseInfoFromApi(docData);
5326
- // Also update document name if available
5327
- if (docData.name) {
5328
- LRS.courseInfo.sharedLinkName = docData.name;
5329
- }
5330
- } else {
5331
- warn('Could not fetch document data from shared API - statements may fail aggregation');
5322
+ // ALWAYS fetch document metadata from the Bravais API.
5323
+ // Even if we have a baked-in GUID, we must override it with the canonical
5324
+ // Bravais GUID so our statements link to the same document as cloudplayer.
5325
+ // The baked-in GUID is a random UUID from wrap time; the Bravais GUID is
5326
+ // assigned at upload and is what Analytics uses for aggregation.
5327
+ if (sharedLinkToken) {
5328
+ log('Have shared link token, fetching document data via shared API...');
5329
+ fetchDocumentMetadata(null, function(docData) {
5330
+ if (docData) {
5331
+ updateCourseInfoFromApi(docData);
5332
+ if (docData.name) {
5333
+ LRS.courseInfo.sharedLinkName = docData.name;
5332
5334
  }
5333
- maybeEnrichAndReady();
5334
- });
5335
- } else if (documentId) {
5336
- // No shared link token, try with extracted document ID (requires auth)
5337
- log('No shared link token, fetching document data with ID:', documentId);
5338
- fetchDocDataAndReady(documentId);
5339
- } else {
5340
- // No identifiers available
5341
- warn('No shared link token or document ID - statements may fail aggregation');
5335
+ } else {
5336
+ warn('Could not fetch document data from shared API - statements may use baked-in GUID');
5337
+ }
5342
5338
  maybeEnrichAndReady();
5343
- }
5339
+ });
5340
+ } else if (documentId) {
5341
+ log('Fetching document data with ID:', documentId);
5342
+ fetchDocDataAndReady(documentId);
5344
5343
  } else {
5345
- // Already have GUID \u2014 still try to enrich packageName if missing
5344
+ // No identifiers available
5345
+ warn('No shared link token or document ID - statements will use baked-in GUID');
5346
5346
  maybeEnrichAndReady();
5347
5347
  }
5348
5348