@elevateab/sdk 1.3.0 → 1.3.1
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/README.md +16 -0
- package/dist/vite.cjs +2 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +28 -0
- package/dist/vite.d.ts +28 -0
- package/dist/vite.js +2 -0
- package/dist/vite.js.map +1 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -18,6 +18,22 @@ npm install @elevateab/sdk
|
|
|
18
18
|
|
|
19
19
|
## Hydrogen Setup
|
|
20
20
|
|
|
21
|
+
### 1. Add the Vite Plugin
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// vite.config.ts
|
|
25
|
+
import {elevate} from '@elevateab/sdk/vite';
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
plugins: [hydrogen(), oxygen(), elevate(), reactRouter(), tsconfigPaths()],
|
|
29
|
+
// ...
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The `elevate()` plugin configures Vite's SSR bundling so the SDK works correctly with Hydrogen's analytics during development (HMR). **This is required for Hydrogen stores.**
|
|
34
|
+
|
|
35
|
+
### 2. Add the Provider
|
|
36
|
+
|
|
21
37
|
Hydrogen uses automatic analytics tracking via Shopify's `useAnalytics()` hook.
|
|
22
38
|
|
|
23
39
|
```tsx
|
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var s=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},v=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of o(e))!u.call(t,n)&&n!==r&&a(t,n,{get:()=>e[n],enumerable:!(i=l(e,n))||i.enumerable});return t};var f=t=>v(a({},"__esModule",{value:!0}),t);var m={};s(m,{elevate:()=>g});module.exports=f(m);function g(){return{name:"elevateab-sdk",config(){return{ssr:{noExternal:["@elevateab/sdk"]}}}}}0&&(module.exports={elevate});
|
|
2
|
+
//# sourceMappingURL=vite.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vite.ts"],"sourcesContent":["/**\n * Vite plugin for @elevateab/sdk\n *\n * Automatically configures Vite's SSR settings so the Elevate SDK\n * works correctly with Shopify Hydrogen (and other Vite-based SSR frameworks).\n *\n * Without this plugin, the SDK is externalized during SSR by default,\n * which causes \"Cannot redefine property: Shopify\" errors during HMR\n * in development. The plugin tells Vite to bundle the SDK into the\n * server build, giving Vite proper control over module evaluation\n * and hot-reload lifecycle.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { elevate } from '@elevateab/sdk/vite';\n *\n * export default defineConfig({\n * plugins: [hydrogen(), oxygen(), elevate(), reactRouter(), tsconfigPaths()],\n * });\n * ```\n */\n\nimport type { Plugin } from 'vite';\n\nexport function elevate(): Plugin {\n return {\n name: 'elevateab-sdk',\n config() {\n return {\n ssr: {\n noExternal: ['@elevateab/sdk'],\n },\n };\n },\n };\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAyBO,SAASE,GAAkB,CAChC,MAAO,CACL,KAAM,gBACN,QAAS,CACP,MAAO,CACL,IAAK,CACH,WAAY,CAAC,gBAAgB,CAC/B,CACF,CACF,CACF,CACF","names":["vite_exports","__export","elevate","__toCommonJS"]}
|
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin for @elevateab/sdk
|
|
5
|
+
*
|
|
6
|
+
* Automatically configures Vite's SSR settings so the Elevate SDK
|
|
7
|
+
* works correctly with Shopify Hydrogen (and other Vite-based SSR frameworks).
|
|
8
|
+
*
|
|
9
|
+
* Without this plugin, the SDK is externalized during SSR by default,
|
|
10
|
+
* which causes "Cannot redefine property: Shopify" errors during HMR
|
|
11
|
+
* in development. The plugin tells Vite to bundle the SDK into the
|
|
12
|
+
* server build, giving Vite proper control over module evaluation
|
|
13
|
+
* and hot-reload lifecycle.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // vite.config.ts
|
|
18
|
+
* import { elevate } from '@elevateab/sdk/vite';
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* plugins: [hydrogen(), oxygen(), elevate(), reactRouter(), tsconfigPaths()],
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
declare function elevate(): Plugin;
|
|
27
|
+
|
|
28
|
+
export { elevate };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin for @elevateab/sdk
|
|
5
|
+
*
|
|
6
|
+
* Automatically configures Vite's SSR settings so the Elevate SDK
|
|
7
|
+
* works correctly with Shopify Hydrogen (and other Vite-based SSR frameworks).
|
|
8
|
+
*
|
|
9
|
+
* Without this plugin, the SDK is externalized during SSR by default,
|
|
10
|
+
* which causes "Cannot redefine property: Shopify" errors during HMR
|
|
11
|
+
* in development. The plugin tells Vite to bundle the SDK into the
|
|
12
|
+
* server build, giving Vite proper control over module evaluation
|
|
13
|
+
* and hot-reload lifecycle.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // vite.config.ts
|
|
18
|
+
* import { elevate } from '@elevateab/sdk/vite';
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* plugins: [hydrogen(), oxygen(), elevate(), reactRouter(), tsconfigPaths()],
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
declare function elevate(): Plugin;
|
|
27
|
+
|
|
28
|
+
export { elevate };
|
package/dist/vite.js
ADDED
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vite.ts"],"sourcesContent":["/**\n * Vite plugin for @elevateab/sdk\n *\n * Automatically configures Vite's SSR settings so the Elevate SDK\n * works correctly with Shopify Hydrogen (and other Vite-based SSR frameworks).\n *\n * Without this plugin, the SDK is externalized during SSR by default,\n * which causes \"Cannot redefine property: Shopify\" errors during HMR\n * in development. The plugin tells Vite to bundle the SDK into the\n * server build, giving Vite proper control over module evaluation\n * and hot-reload lifecycle.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { elevate } from '@elevateab/sdk/vite';\n *\n * export default defineConfig({\n * plugins: [hydrogen(), oxygen(), elevate(), reactRouter(), tsconfigPaths()],\n * });\n * ```\n */\n\nimport type { Plugin } from 'vite';\n\nexport function elevate(): Plugin {\n return {\n name: 'elevateab-sdk',\n config() {\n return {\n ssr: {\n noExternal: ['@elevateab/sdk'],\n },\n };\n },\n };\n}\n"],"mappings":"AAyBO,SAASA,GAAkB,CAChC,MAAO,CACL,KAAM,gBACN,QAAS,CACP,MAAO,CACL,IAAK,CACH,WAAY,CAAC,gBAAgB,CAC/B,CACF,CACF,CACF,CACF","names":["elevate"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elevateab/sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Elevate AB Testing SDK for Hydrogen and Remix frameworks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"types": "./dist/next.d.ts",
|
|
22
22
|
"import": "./dist/next.js",
|
|
23
23
|
"require": "./dist/next.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./vite": {
|
|
26
|
+
"types": "./dist/vite.d.ts",
|
|
27
|
+
"import": "./dist/vite.js",
|
|
28
|
+
"require": "./dist/vite.cjs"
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"files": [
|
|
@@ -75,6 +80,7 @@
|
|
|
75
80
|
"@types/ua-parser-js": "^0.7.39",
|
|
76
81
|
"next": "^14.2.0",
|
|
77
82
|
"tsup": "^8.5.1",
|
|
78
|
-
"typescript": "^5.9.3"
|
|
83
|
+
"typescript": "^5.9.3",
|
|
84
|
+
"vite": "^7.3.1"
|
|
79
85
|
}
|
|
80
86
|
}
|