@pack/hydrogen 1.0.1-ab-test.11 → 1.0.1-ab-test.12
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.
|
@@ -255,7 +255,7 @@ export function createPackClient(options) {
|
|
|
255
255
|
variables: queryVariables,
|
|
256
256
|
headers: headers,
|
|
257
257
|
})),
|
|
258
|
-
|
|
258
|
+
packTestInfo: testInfoForLoader,
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
catch (error) {
|
|
@@ -279,7 +279,7 @@ export function createPackClient(options) {
|
|
|
279
279
|
});
|
|
280
280
|
return response.error
|
|
281
281
|
? response
|
|
282
|
-
: { ...response,
|
|
282
|
+
: { ...response, packTestInfo: testInfoForLoader };
|
|
283
283
|
},
|
|
284
284
|
session,
|
|
285
285
|
};
|
|
@@ -5,30 +5,30 @@ import { useRevalidator } from "react-router-dom";
|
|
|
5
5
|
import { usePackTestContext } from "./pack-test-context";
|
|
6
6
|
const usePackLoaderData = () => {
|
|
7
7
|
const [exposedTestInfo, setExposedTestInfo] = useState();
|
|
8
|
-
const {
|
|
8
|
+
const { packTestInfo } = useLoaderData();
|
|
9
9
|
const [root] = useMatches();
|
|
10
10
|
const { packIsPreviewMode } = root?.data;
|
|
11
11
|
const { testExposureCallback } = usePackTestContext();
|
|
12
12
|
const revalidator = useRevalidator();
|
|
13
13
|
const exposedTestCookieString = Cookies.get("exposedTest");
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
if (
|
|
15
|
+
if (packTestInfo &&
|
|
16
16
|
!exposedTestCookieString &&
|
|
17
17
|
!packIsPreviewMode &&
|
|
18
18
|
!exposedTestInfo) {
|
|
19
19
|
// Set exposedTest cookie used by server to determine if session has been exposed to test
|
|
20
20
|
const expires = new Date();
|
|
21
21
|
expires.setHours(expires.getHours() + 24);
|
|
22
|
-
Cookies.set("exposedTest", JSON.stringify(
|
|
22
|
+
Cookies.set("exposedTest", JSON.stringify(packTestInfo), {
|
|
23
23
|
expires,
|
|
24
24
|
});
|
|
25
|
-
setExposedTestInfo(
|
|
26
|
-
testExposureCallback?.(
|
|
25
|
+
setExposedTestInfo(packTestInfo);
|
|
26
|
+
testExposureCallback?.(packTestInfo);
|
|
27
27
|
// TODO: This results in flashing of UI driven by site settings data.
|
|
28
28
|
// Need non-flashing solution.
|
|
29
29
|
revalidator.revalidate();
|
|
30
30
|
}
|
|
31
|
-
}, [
|
|
31
|
+
}, [packTestInfo, testExposureCallback, exposedTestInfo]);
|
|
32
32
|
};
|
|
33
33
|
export const PackTestRoute = () => {
|
|
34
34
|
usePackLoaderData();
|