@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/index.cjs CHANGED
@@ -1956,12 +1956,12 @@ function generateLrsBridgeCode(options) {
1956
1956
  // Without this override, our statements have a different object.id than cloudplayer
1957
1957
  // statements, so Analytics treats them as unrelated to the document.
1958
1958
  if (docData.guid) {
1959
- if (LRS.courseInfo.guid && LRS.courseInfo.guid !== docData.guid) {
1960
- log('Overriding baked-in GUID with Bravais GUID:', LRS.courseInfo.guid, '->', docData.guid);
1961
- }
1959
+ var oldGuid = LRS.courseInfo.guid;
1962
1960
  LRS.courseInfo.guid = docData.guid;
1963
1961
  LRS.courseInfo.id = 'http://xyleme.com/bravais/document/' + docData.guid;
1964
- log('Document GUID from API:', docData.guid);
1962
+ // Always-visible log (not behind DEBUG) so we can confirm override in production
1963
+ console.info('[PA-LRS] Document GUID set from API:', docData.guid,
1964
+ oldGuid && oldGuid !== docData.guid ? '(was: ' + oldGuid + ')' : '');
1965
1965
  }
1966
1966
 
1967
1967
  // Version GUID \u2014 same principle: Bravais version GUID must override baked-in
@@ -2270,21 +2270,20 @@ function generateLrsBridgeCode(options) {
2270
2270
  info.sharedLinkName = launchInfo.sharedLinkName || info.sharedLinkName;
2271
2271
  }
2272
2272
 
2273
- // 3b. Try to extract GUIDs from Xyleme Cloud Player's internal data
2274
- // This is more reliable than API calls which may fail with 401
2275
- if (!info.guid || !info.versionGuid) {
2276
- var cloudPlayerData = extractFromXylemeCloudPlayer();
2277
- if (cloudPlayerData) {
2278
- info.guid = cloudPlayerData.guid || info.guid;
2279
- info.versionGuid = cloudPlayerData.versionGuid || info.versionGuid;
2280
- info.documentId = cloudPlayerData.documentId || info.documentId;
2281
- info.title = cloudPlayerData.title || info.title;
2282
- log('Updated course info from Cloud Player:', {
2283
- guid: info.guid,
2284
- versionGuid: info.versionGuid,
2285
- documentId: info.documentId
2286
- });
2287
- }
2273
+ // 3b. Always try to extract GUIDs from Xyleme Cloud Player's internal data.
2274
+ // Cloud Player data is authoritative \u2014 it has the canonical Bravais GUID.
2275
+ // This overrides any baked-in GUID which is just a random UUID from wrap time.
2276
+ var cloudPlayerData = extractFromXylemeCloudPlayer();
2277
+ if (cloudPlayerData) {
2278
+ if (cloudPlayerData.guid) info.guid = cloudPlayerData.guid;
2279
+ if (cloudPlayerData.versionGuid) info.versionGuid = cloudPlayerData.versionGuid;
2280
+ info.documentId = cloudPlayerData.documentId || info.documentId;
2281
+ info.title = cloudPlayerData.title || info.title;
2282
+ log('Updated course info from Cloud Player:', {
2283
+ guid: info.guid,
2284
+ versionGuid: info.versionGuid,
2285
+ documentId: info.documentId
2286
+ });
2288
2287
  }
2289
2288
 
2290
2289
  // 4. Try getCourseTitle() from preloadIntegrity.js
@@ -4906,12 +4905,18 @@ function generateLrsBridgeCode(options) {
4906
4905
 
4907
4906
  // Always-visible bridge summary (not gated by DEBUG)
4908
4907
  // This ensures diagnostics are available even in production builds
4908
+ // Shows current GUID (may be from Cloud Player, baked-in, or pending API override)
4909
+ var currentGuid = LRS.courseInfo ? LRS.courseInfo.guid : DOCUMENT_GUID;
4910
+ var currentVerGuid = LRS.courseInfo ? LRS.courseInfo.versionGuid : VERSION_GUID;
4911
+ var sharedToken = LRS.courseInfo ? LRS.courseInfo.sharedLinkToken : null;
4909
4912
  if (window.console && window.console.info) {
4910
4913
  console.info('[PA-LRS] Bridge v' + LRS.version + ': mode=' + LRS.mode +
4911
4914
  ', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
4912
4915
  ', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
4913
- ', docGuid=' + (DOCUMENT_GUID || 'NONE') +
4914
- ', verGuid=' + (VERSION_GUID || 'NONE') +
4916
+ ', docGuid=' + (currentGuid || 'NONE') +
4917
+ (currentGuid !== DOCUMENT_GUID ? ' (overridden from baked: ' + DOCUMENT_GUID + ')' : '') +
4918
+ ', verGuid=' + (currentVerGuid || 'NONE') +
4919
+ ', sharedToken=' + (sharedToken || 'NONE') +
4915
4920
  ', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none') +
4916
4921
  ', hasRefreshActor=' + (typeof LRS.refreshActor === 'function'));
4917
4922
  }
@@ -4982,35 +4987,30 @@ function generateLrsBridgeCode(options) {
4982
4987
  });
4983
4988
  }
4984
4989
 
4985
- if (!LRS.courseInfo.guid) {
4986
- // When we have a shared link token, use /api/shared/{token}/documents directly
4987
- // This endpoint does NOT require authentication and returns both document GUID and version GUID
4988
- if (sharedLinkToken) {
4989
- log('Have shared link token, fetching document data via shared API...');
4990
- // fetchDocumentMetadata will use /api/shared/{token}/documents when sharedLinkToken is present
4991
- fetchDocumentMetadata(null, function(docData) {
4992
- if (docData) {
4993
- updateCourseInfoFromApi(docData);
4994
- // Also update document name if available
4995
- if (docData.name) {
4996
- LRS.courseInfo.sharedLinkName = docData.name;
4997
- }
4998
- } else {
4999
- warn('Could not fetch document data from shared API - statements may fail aggregation');
4990
+ // ALWAYS fetch document metadata from the Bravais API.
4991
+ // Even if we have a baked-in GUID, we must override it with the canonical
4992
+ // Bravais GUID so our statements link to the same document as cloudplayer.
4993
+ // The baked-in GUID is a random UUID from wrap time; the Bravais GUID is
4994
+ // assigned at upload and is what Analytics uses for aggregation.
4995
+ if (sharedLinkToken) {
4996
+ log('Have shared link token, fetching document data via shared API...');
4997
+ fetchDocumentMetadata(null, function(docData) {
4998
+ if (docData) {
4999
+ updateCourseInfoFromApi(docData);
5000
+ if (docData.name) {
5001
+ LRS.courseInfo.sharedLinkName = docData.name;
5000
5002
  }
5001
- maybeEnrichAndReady();
5002
- });
5003
- } else if (documentId) {
5004
- // No shared link token, try with extracted document ID (requires auth)
5005
- log('No shared link token, fetching document data with ID:', documentId);
5006
- fetchDocDataAndReady(documentId);
5007
- } else {
5008
- // No identifiers available
5009
- warn('No shared link token or document ID - statements may fail aggregation');
5003
+ } else {
5004
+ warn('Could not fetch document data from shared API - statements may use baked-in GUID');
5005
+ }
5010
5006
  maybeEnrichAndReady();
5011
- }
5007
+ });
5008
+ } else if (documentId) {
5009
+ log('Fetching document data with ID:', documentId);
5010
+ fetchDocDataAndReady(documentId);
5012
5011
  } else {
5013
- // Already have GUID \u2014 still try to enrich packageName if missing
5012
+ // No identifiers available
5013
+ warn('No shared link token or document ID - statements will use baked-in GUID');
5014
5014
  maybeEnrichAndReady();
5015
5015
  }
5016
5016