@cascayd/experiment 0.3.2 → 0.3.4
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/client.js +13 -1
- package/dist/shopify-handler.js +2 -2
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getOrCreateSession, readVariantChoice } from './cookies';
|
|
1
|
+
import { getOrCreateSession, readVariantChoice } from './cookies.js';
|
|
2
2
|
let API_KEY = '';
|
|
3
3
|
let BASE_URL = 'https://ab-mvp-backend.onrender.com';
|
|
4
4
|
const SDK_VERSION = '0.2.0-dev';
|
|
@@ -101,3 +101,15 @@ export async function record(type, opts = {}) {
|
|
|
101
101
|
if (!res.ok)
|
|
102
102
|
throw new Error(`Record failed: ${res.status}`);
|
|
103
103
|
}
|
|
104
|
+
// Expose functions to window for browser/Shopify theme compatibility
|
|
105
|
+
if (typeof window !== 'undefined') {
|
|
106
|
+
;
|
|
107
|
+
window.initCascayd = initCascayd;
|
|
108
|
+
window.assignVariant = assignVariant;
|
|
109
|
+
window.record = record;
|
|
110
|
+
window.Cascayd = {
|
|
111
|
+
initCascayd,
|
|
112
|
+
assignVariant,
|
|
113
|
+
record,
|
|
114
|
+
};
|
|
115
|
+
}
|
package/dist/shopify-handler.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* Expects the Cascayd SDK to be loaded first via:
|
|
7
7
|
* <script src="https://cdn.jsdelivr.net/npm/@cascayd/experiment@latest/dist/client.js"></script>
|
|
8
8
|
*/
|
|
9
|
-
import { assignVariant, record } from './client';
|
|
10
|
-
import { readVariantChoice, persistVariantChoice } from './cookies';
|
|
9
|
+
import { assignVariant, record } from './client.js';
|
|
10
|
+
import { readVariantChoice, persistVariantChoice } from './cookies.js';
|
|
11
11
|
// Wait for SDK to be available
|
|
12
12
|
function waitForSDK(maxAttempts = 50, interval = 100) {
|
|
13
13
|
return new Promise((resolve, reject) => {
|