Install the SDK
Pick one way to install. Both load the same code. You need the site key the Journeeze team sent you.
npm (bundled apps)
npm install @journeeze/sdk@0.1.0-rc.3 --save-exact
Pin an exact version. Release candidates (-rc.N) are on the rc tag. Stable releases are on latest.
React
import { JourneezeProvider, useJourneeze } from "@journeeze/sdk/react";
export function Root() {
return (
<JourneezeProvider
siteKey={config.journeezeSiteKey} // public, from runtime config
apiHost={config.journeezeApiHost} // staging and local only; see "Environments"
context={{ persona: "owner", journeyId: "billing", journeyStep: "route.billing.pay" }}
pagePath="none" // you pass route ids as journeyStep
>
<App />
</JourneezeProvider>
);
}
function HelpButton() {
const jz = useJourneeze();
return <button onClick={() => jz.enableHelp()}>Help</button>;
}
- While
siteKeyisundefined(config still loading) the provider renders with an inert handle. Every method does nothing and nothing is sent. The real handle starts with the first key. - Keep
contextin sync with your router. The provider applies every change. - With TypeScript’s
exactOptionalPropertyTypes, optional props do not acceptundefined. Pass them only when set:{...(config.journeezeApiHost ? { apiHost: config.journeezeApiHost } : {})}.
Without React
import { createJourneeze } from "@journeeze/sdk";
const jz = createJourneeze({ siteKey: "pk_...", apiHost: "https://app.staging.journeeze.dev" });
document.querySelector("#help")?.addEventListener("click", () => jz.enableHelp());
Script tag (no bundler)
<script type="module"
src="https://app.journeeze.dev/sdk/script.js"
data-journeeze-site-key="pk_..."
data-journeeze-help></script>
The tag creates window.Journeeze. It is a module script, so it runs after your inline scripts. Use it from a click, or after DOMContentLoaded. Never use it while the page is still loading:
<button id="suggest">Suggest an improvement</button>
<script>
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("suggest").addEventListener("click", () => window.Journeeze?.enable());
});
</script>
| Attribute | Effect |
|---|---|
data-journeeze-site-key | Required. Your site key. |
data-journeeze-api-host | The collector origin. Required outside production. See below. |
data-journeeze-api-path | Path prefix, only for a same-origin proxy. |
data-journeeze-help | Shows the help launcher at once. |
data-journeeze-chat | Help opens as a conversation instead of the guide panel. |
/sdk/script.js is always the SDK version the Journeeze service currently runs. To control the version yourself, install from npm and pin it.
Environments and apiHost
The SDK sends to production (https://app.journeeze.dev) unless you set apiHost. It does not follow where the script was loaded from. A staging or local site key sent to production is refused. Set apiHost next to the site key in each environment’s config:
| Environment | apiHost / data-journeeze-api-host |
|---|---|
| Production | leave it out |
| Staging | https://app.staging.journeeze.dev |
| Local Journeeze stack | http://localhost:8080 |
| Your own same-origin proxy | your origin, for example https://www.example.com |
The browser calls the collector directly with CORS, only from the origins you registered. Requests carry no cookies and are not cached.
A proxy is optional. It suits offices or CI where many users share one IP address, or a policy that allows no third-party requests. Ask the Journeeze team for the proxy guide. It covers the gateway key, the paths to forward, and reference Worker and server code.
Content Security Policy
If your site sends a CSP, add these. Use https://app.staging.journeeze.dev on staging.
script-src 'self' https://app.journeeze.dev;
connect-src 'self' https://app.journeeze.dev;
img-src 'self' blob: https://app.journeeze.dev;
media-src 'self' https://app.journeeze.dev;
style-src 'self' 'nonce-<your nonce>';
- Add
'wasm-unsafe-eval'toscript-srconly if you turn on signals. - Pass your nonce as the
nonceoption. The SDK puts it on the styles it injects. - With npm and a proxy,
script-srcandconnect-srcneed only'self'.
Turn help and feedback on
In-app help shows a launcher that opens guides built from your published journeys.
await jz.enableHelp(); // loads the help code and shows the launcher
jz.isHelpEnabled(); // true
jz.disableHelp(); // removes it
onHelpStatus(status)tells you whether help is available here:{ available: true }, or{ available: false, reason: "disabled" }(help is off for the site) or"audience"(help is for reviewers only and this visitor is not one). Hide your own Help button onfalse.- Set
journeyStepincontextto a stable id for where the user is (a route id such asroute.projects.hub). Never use a URL or record id. Guides and signals match on it.
The feedback mode asks for consent first:
await jz.enable(); // turns the feedback mode on (asks for consent first)
jz.disable();
jz.isEnabled();
- Invited reviewers arrive with
?jz_invite=<token>. The SDK reads it once, removes it from the URL and keeps it for the tab. onModeChange(enabled)reports every switch, including Esc and Exit inside the widget.- When
journeyStepchanges, the widget can ask about the step the reviewer just finished.
Signals (optional)
Aggregate behaviour signals: rage clicks, dead clicks, hesitation, abandoned journey steps and your own registered signals. They are computed in the browser. Only the derived signal is sent, with no URL, text, user id or session id.
createJourneeze({
siteKey,
signals: {
enabled: true,
tflo: () => import("tflo-browser-events"), // pass your copy if your app already uses it
},
});
- They run only after consent, while help or feedback is on, and while the site’s signals switch on the board is on. Turning that switch off stops them without a deploy.
- Only elements with a
data-tflow-idoutside masked regions are tracked. The SDK listens to clicks, hover, focus and change events. It never reads keystrokes, input values or pointer movement. - Without your own
tflo-browser-events(>=0.1.0 <1, optional peer dependency) the SDK loads its own copy. That needs'wasm-unsafe-eval'inscript-srcanddata:inconnect-src.
Next: connect GitHub.