@pack/hydrogen 3.2.5 → 3.2.6

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
@@ -5811,71 +5811,62 @@ async function getTestInfo({
5811
5811
  );
5812
5812
  if (testSessionData?.id && testSessionData?.testVariant) {
5813
5813
  debug3("[Pack Test] Found existing test data in session");
5814
- if (!testSessionExpireAt || new Date(testSessionExpireAt) >= /* @__PURE__ */ new Date()) {
5815
- debug3(
5816
- "[Pack Test] Test session not expired by time, fetching rules to validate if test is still active"
5814
+ try {
5815
+ const validationResult = await packClientFetchTestByRules(
5816
+ packClient,
5817
+ testTargetAudienceAttributes,
5818
+ testSession,
5819
+ request,
5820
+ withCache,
5821
+ token,
5822
+ null,
5823
+ true
5824
+ // validateOnly - but will assign new test if current is inactive
5817
5825
  );
5818
- try {
5819
- const validationResult = await packClientFetchTestByRules(
5820
- packClient,
5821
- testTargetAudienceAttributes,
5822
- testSession,
5823
- request,
5824
- withCache,
5825
- token,
5826
- null,
5827
- true
5828
- // validateOnly - but will assign new test if current is inactive
5829
- );
5830
- if (validationResult) {
5831
- if (validationResult.id === testSessionData.id) {
5832
- debug3(
5833
- "[Pack Test] Test is still active, using refreshed data",
5834
- JSON.stringify({
5835
- testId: validationResult.id,
5836
- testHandle: validationResult.handle,
5837
- variantId: validationResult.testVariant.id,
5838
- variantHandle: validationResult.testVariant.handle
5839
- })
5840
- );
5841
- return validationResult;
5842
- } else {
5843
- debug3(
5844
- "[Pack Test] Original test no longer active, new test assigned",
5845
- JSON.stringify({
5846
- oldTestId: testSessionData.id,
5847
- newTestId: validationResult.id,
5848
- newTestHandle: validationResult.handle,
5849
- newVariantId: validationResult.testVariant.id,
5850
- newVariantHandle: validationResult.testVariant.handle
5851
- })
5852
- );
5853
- return {
5854
- ...validationResult,
5855
- isFirstExposure: true
5856
- };
5857
- }
5826
+ if (validationResult) {
5827
+ if (validationResult.id === testSessionData.id) {
5828
+ debug3(
5829
+ "[Pack Test] Test is still active, using refreshed data",
5830
+ JSON.stringify({
5831
+ testId: validationResult.id,
5832
+ testHandle: validationResult.handle,
5833
+ variantId: validationResult.testVariant.id,
5834
+ variantHandle: validationResult.testVariant.handle
5835
+ })
5836
+ );
5837
+ return validationResult;
5858
5838
  } else {
5859
5839
  debug3(
5860
- "[Pack Test] Test is no longer active and no new test was assigned"
5840
+ "[Pack Test] Original test no longer active, new test assigned",
5841
+ JSON.stringify({
5842
+ oldTestId: testSessionData.id,
5843
+ newTestId: validationResult.id,
5844
+ newTestHandle: validationResult.handle,
5845
+ newVariantId: validationResult.testVariant.id,
5846
+ newVariantHandle: validationResult.testVariant.handle
5847
+ })
5861
5848
  );
5862
- return void 0;
5849
+ return {
5850
+ ...validationResult,
5851
+ isFirstExposure: true
5852
+ };
5863
5853
  }
5864
- } catch (error) {
5854
+ } else {
5865
5855
  debug3(
5866
- "[Pack Test] Error validating test, using cached data:",
5867
- JSON.stringify(error)
5856
+ "[Pack Test] Test is no longer active and no new test was assigned"
5868
5857
  );
5869
- console.error(
5870
- "[Pack Test] Error validating test, using cached data:",
5871
- error
5872
- );
5873
- return { ...testSessionData, isFirstExposure: void 0 };
5858
+ return void 0;
5874
5859
  }
5875
- } else {
5876
- debug3("[Pack Test] Test session has expired by time");
5877
- debug3("[Pack Test] Clearing expired test session data");
5878
- testSession.clearTestData();
5860
+ } catch (error) {
5861
+ debug3(
5862
+ "[Pack Test] Error validating test, using cached data:",
5863
+ JSON.stringify(error)
5864
+ );
5865
+ console.error(
5866
+ "[Pack Test] Error validating test, using cached data:",
5867
+ error
5868
+ );
5869
+ return { ...testSessionData, isFirstExposure: void 0 };
5879
5870
  }
5880
5871
  }
5881
5872
  if (exposedTestCookieString) {