@@ -79,11 +79,34 @@ This repo includes a local mock backend and a simple UI to exercise key mParticl
7979### How to use with your local SDK build
8080
81811 . Build the SDK from the mParticle Web SDK repo: [ mParticle Web SDK on GitHub] ( https://github.com/mParticle/mparticle-web-sdk/ )
82- 2 . Replace the stub with your build:
83- - Put your bundle at ` client/public/mparticle.js ` (the app loads it from ` /mparticle.js ` ).
82+ 2 . Point the app at your local SDK bundle (recommended):
83+ - Run all commands from this folder: ` core-sdk-samples/mparticle-react-web-sample-app `
84+ - One-time setup inside this app directory:
85+
86+ a) Preferred: set the exact file path in ` .env.local ` :
87+
88+ ``` bash
89+ # path to the actual bundle file
90+ echo " LOCAL_MPARTICLE_SDK_PATH=/absolute/path/to/mparticle-web-sdk/dist/mparticle.js" > .env.local
91+ ```
92+
93+ Or fallback: set the SDK repo path (script will use dist if present, else auto-bundle from src):
94+
95+ ` ` ` bash
96+ echo " LOCAL_MPARTICLE_SDK_REPO=/absolute/path/to/mparticle-web-sdk" > .env.local
97+ ` ` `
98+
99+ b) Run the setup script (writes ` client/.env.local` with either ` VITE_MPARTICLE_SDK_PATH` or ` VITE_MPARTICLE_SDK_SOURCE_ENTRY` ):
100+
101+ ` ` ` bash
102+ npm run setup-local-sdk
103+ ` ` `
104+ This writes ` client/.env.local` for the dev server. No ` client/public/mparticle.js` is needed.
105+
106+ - Alternative: place the bundle at ` client/public/mparticle.js` and it will be served as ` /mparticle.js` .
841073. Set your API key in the UI:
85108 - Edit ` client/src/App.jsx` and set ` API_KEY` near the top (any string works for local testing).
86- 4 . Start both client and server from the repo root :
109+ 4. Start both client and server from this app directory :
87110
88111 ` ` ` bash
89112 npm install
@@ -94,7 +117,8 @@ This repo includes a local mock backend and a simple UI to exercise key mParticl
94117
95118Notes:
96119- If you previously opened the app, your browser may cache ` /mparticle.js` . Do a hard refresh.
97- - The app intentionally loads the SDK from ` client/public/mparticle.js ` so you can drop in a locally built bundle without publishing to npm.
120+ - ` .env.local` files are git-ignored and safe to keep local-only.
121+ - If ` client/.env.local` is not present, the app falls back to serving ` client/public/mparticle.js` if present.
98122
99123# ## Notes
100124
@@ -105,6 +129,8 @@ Notes:
105129
106130# ## Troubleshooting
107131
108- - "Failed to load mParticle SDK script": ensure your bundle is at ` client/public/mparticle.js ` and refresh without cache.
132+ - " Failed to load mParticle SDK script" :
133+ - If using ` .env.local` , verify ` client/.env.local` contains a valid absolute path and the file exists.
134+ - Otherwise, ensure your bundle is at ` client/public/mparticle.js` and refresh without cache.
109135- 404 or network error: ensure the server is running on port 4000 (` npm run dev` from the repo root starts both).
110136- Audiences show empty: make sure you' ve clicked Identify/Login first so an MPID is available before fetching.
0 commit comments