@pack/hydrogen 2.0.1 → 2.0.3

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.js CHANGED
@@ -5299,8 +5299,10 @@ async function fetchTestRulesShared(packClient, withCache, token) {
5299
5299
  async ({
5300
5300
  addDebugData
5301
5301
  }) => {
5302
- const URL2 = process.env.NODE_ENV === "development" ? "http://localhost:8787/tests-updated-at" : "https://test-cache-check-production.packdigital.workers.dev/tests-updated-at";
5303
- debug3("[Pack Test] Fetching timestamp from:", URL2);
5302
+ const URL2 = process.env.PACK_TEST_CACHE_CHECK_URL || "https://test-cache-check-production.packdigital.workers.dev/tests-updated-at";
5303
+ debug3("[Pack Test] Fetching timestamp from:", URL2, {
5304
+ isCustom: !!process.env.PACK_TEST_CACHE_CHECK_URL
5305
+ });
5304
5306
  const resp2 = await fetch(URL2, {
5305
5307
  headers: {
5306
5308
  Authorization: `Bearer ${token}`
@@ -5447,11 +5449,7 @@ async function packClientFetchTestByRules(packClient, testTargetAudienceAttribut
5447
5449
  if (withCache && token) {
5448
5450
  debug3("[Pack Test] Fetching test rules through shared cache");
5449
5451
  try {
5450
- const rules = await fetchTestRulesShared(
5451
- packClient,
5452
- withCache,
5453
- token
5454
- );
5452
+ const rules = await fetchTestRulesShared(packClient, withCache, token);
5455
5453
  localTestResolver.setTestRules(rules);
5456
5454
  debug3(
5457
5455
  "[Pack Test] Updated local resolver with rules from shared cache"
@@ -5459,7 +5457,9 @@ async function packClientFetchTestByRules(packClient, testTargetAudienceAttribut
5459
5457
  const currentTestData = testSession.getTestData();
5460
5458
  let needsNewTest = false;
5461
5459
  if (currentTestData?.id) {
5462
- const freshTestData = localTestResolver.getTestById(currentTestData.id);
5460
+ const freshTestData = localTestResolver.getTestById(
5461
+ currentTestData.id
5462
+ );
5463
5463
  if (!freshTestData) {
5464
5464
  debug3(
5465
5465
  "[Pack Test] Current session test is no longer active (paused/stopped), clearing session:",
@@ -5516,10 +5516,7 @@ async function packClientFetchTestByRules(packClient, testTargetAudienceAttribut
5516
5516
  return void 0;
5517
5517
  }
5518
5518
  } catch (error) {
5519
- debug3(
5520
- "[Pack Test] Failed to fetch test rules:",
5521
- JSON.stringify(error)
5522
- );
5519
+ debug3("[Pack Test] Failed to fetch test rules:", JSON.stringify(error));
5523
5520
  console.error("[Pack Test] Failed to fetch test rules:", error);
5524
5521
  }
5525
5522
  } else {
@@ -5589,9 +5586,7 @@ async function packClientFetchTestByRules(packClient, testTargetAudienceAttribut
5589
5586
  })
5590
5587
  );
5591
5588
  if (!assignedTest) {
5592
- debug3(
5593
- "[Pack Test] No test assigned - user not eligible for any tests"
5594
- );
5589
+ debug3("[Pack Test] No test assigned - user not eligible for any tests");
5595
5590
  return void 0;
5596
5591
  }
5597
5592
  const result = {
@@ -5721,7 +5716,9 @@ async function getTestInfo({
5721
5716
  };
5722
5717
  }
5723
5718
  } else {
5724
- debug3("[Pack Test] Test is no longer active and no new test was assigned");
5719
+ debug3(
5720
+ "[Pack Test] Test is no longer active and no new test was assigned"
5721
+ );
5725
5722
  return void 0;
5726
5723
  }
5727
5724
  } catch (error) {
@@ -5778,9 +5775,7 @@ async function getTestInfo({
5778
5775
  // Not validateOnly - allow assigning new tests
5779
5776
  );
5780
5777
  if (testInfo?.id === exposedTest.id) {
5781
- debug3(
5782
- "[Pack Test] Exposed test was restored (still active)"
5783
- );
5778
+ debug3("[Pack Test] Exposed test was restored (still active)");
5784
5779
  } else if (testInfo) {
5785
5780
  debug3(
5786
5781
  "[Pack Test] Exposed test is no longer active, using newly assigned test:",
@@ -6540,6 +6535,7 @@ var usePackLoaderData = () => {
6540
6535
  packIsPreviewMode = root?.data?.packIsPreviewMode;
6541
6536
  revalidator = useRevalidator();
6542
6537
  } catch (error) {
6538
+ console.error("PackTestRoute router error:", error);
6543
6539
  packTestInfo = void 0;
6544
6540
  packIsPreviewMode = void 0;
6545
6541
  revalidator = void 0;
@@ -6593,7 +6589,9 @@ var usePackLoaderData = () => {
6593
6589
  }
6594
6590
  });
6595
6591
  testExposureCallback?.({ ...packTestInfo, exposureTime: Date.now() });
6596
- revalidator?.revalidate();
6592
+ setTimeout(() => {
6593
+ revalidator?.revalidate();
6594
+ }, 750);
6597
6595
  }
6598
6596
  }, [packTestInfo, testExposureCallback, exposedTestInfo, hasUserConsent2]);
6599
6597
  };