SDK installation & integration

Guidely ships one framework-independent runtime (@guidelytech/sdk-core, which renders through @guidelytech/guide-runtime) and thin adapters. All adapters share the same engine, state and API.

PackageUse when
@guidelytech/reactReact 18/19 apps (Vite, CRA, Remix)
@guidelytech/nextjsNext.js App Router or Pages Router (re-exports React + navigation bridge)
@guidelytech/svelteSvelte 4/5 apps
@guidelytech/sveltekitSvelteKit 2
@guidelytech/sdk-coreVanilla JavaScript / any other framework
@guidelytech/flagsFeature flags only: Node.js, edge functions, flags-only apps, the guidely-flags CLI
@guidelytech/react-nativeReact Native and Expo apps (native rendering) — see mobile.md
iOS SDK (SwiftPM / CocoaPods GuidelyTech)Native iOS apps (SwiftUI, UIKit) — see mobile.md
Android SDK (com.guidelytech:guidely-android)Native Android apps (Compose, Views) — see mobile.md
Flutter (guidely_flutter, preview)Flutter apps — see mobile.md
@guidelytech/electronElectron desktop apps (with sdk-core or an adapter) — see Electron
script tag (/sdk/guidely.js)Apps that cannot install npm packages
Guidely browser extensionThird-party web apps you can't change (Salesforce, Workday, ServiceNow) — see browser-extension.md
@guidelytech/node, Java, PHP server SDKsidentify / track / group from your backend — see server-sdks.md

Every integration needs the environment public key (pk_dev_… / pk_stg_… / pk_prod_…) from Settings → Environments, and your Guidely API URL (included in the install snippets). Public keys are not secrets: they only unlock published configuration for one environment, restricted by the allowed origins you configure. The dashboard's Settings → Environments page generates these snippets for you.

Every project has development, staging and production. You can rename them and add your own (QA, UAT…) in Settings → Environments & Install; each has its own public key (pk_qa_…). The SDKs read the environment from the key, so the environment option is only needed to override it; server-side SDKs pass the environment's key (production, qa).

React

npm install @guidelytech/react
"use client";
import { GuidelyProvider } from "@guidelytech/react";

export function AppProviders({ children }: { children: React.ReactNode }) {
  return (
    <GuidelyProvider
      projectId={process.env.NEXT_PUBLIC_GUIDELY_PROJECT_ID!}
      environment="development"
      apiUrl={process.env.NEXT_PUBLIC_GUIDELY_API_URL}
    >
      {children}
    </GuidelyProvider>
  );
}
import { useGuidely, useGuidelyIdentify, useGuidelyEvent, useGuidelyReady, useChecklistProgress, useGuideState } from "@guidelytech/react";

function App({ user }) {
  const guidely = useGuidely();                       // no-op proxy during SSR / before ready
  const ready = useGuidelyReady();
  useGuidelyIdentify(user.id, { email: user.email, firstName: user.firstName, lastName: user.lastName, role: user.role, plan: user.plan }, { id: user.orgId, traits: { name: user.orgName } });
  useGuidelyEvent("guide:complete", (guide) => console.log("completed", guide.key));
  const progress = useChecklistProgress("onboarding-checklist");
  const tourState = useGuideState("new-user-onboarding");  // { completed, dismissed, impressions }

  return (
    <>
      <button onClick={() => guidely.startGuide("getting-started")}>Start onboarding</button>
      <button onClick={() => guidely.track("contact_created", { source: "manual" })}>Track</button>
      <button onClick={() => guidely.openResourceCenter()}>Help</button>
      <button onClick={() => guidely.reset()}>Log out</button>
    </>
  );
}

Send firstName and lastName (or first_name / last_name, or a single name) in the traits to name the user in the dashboard: Guidely keeps them as the user's first and last name, titles the user with them and finds the user by either one in Users search. With only name, it is split at its first space.

The provider creates the client once (Strict-Mode safe), never touches window during server rendering, does not block rendering, and destroys the client on unmount. Route changes are detected automatically through the History API.

Next.js (App Router)

npm install @guidelytech/nextjs
// app/providers.tsx
"use client";
import { GuidelyProvider, GuidelyNavigationListener } from "@guidelytech/nextjs";

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <GuidelyProvider projectId={process.env.NEXT_PUBLIC_GUIDELY_PROJECT_ID!} environment="development" apiUrl={process.env.NEXT_PUBLIC_GUIDELY_API_URL}>
      <GuidelyNavigationListener />
      {children}
    </GuidelyProvider>
  );
}

Put NEXT_PUBLIC_GUIDELY_PROJECT_ID, NEXT_PUBLIC_GUIDELY_ENV and NEXT_PUBLIC_GUIDELY_API_URL in .env.local. NEXT_PUBLIC_ variables are inlined into the browser bundle, which is fine because public keys are not secrets. GuidelyNavigationListener calls page() on every App Router navigation (the History patch covers it too; the listener is the explicit bridge).

Svelte

npm install @guidelytech/svelte
<script lang="ts">
  import { onMount } from "svelte";
  import { createGuidely, guideTrigger } from "@guidelytech/svelte";

  let guidely: ReturnType<typeof createGuidely> | undefined;
  onMount(() => {
    guidely = createGuidely({
      projectId: import.meta.env.VITE_GUIDELY_PROJECT_ID,
      environment: "development",
      apiUrl: import.meta.env.VITE_GUIDELY_API_URL,
    });
    guidely.identify("user_123", { plan: "pro" });
    return () => guidely?.destroy();
  });
</script>

<button onclick={() => guidely?.startGuide("getting-started")}>Start onboarding</button>
<button use:guideTrigger={"feature-discovery"}>What's new?</button>

Stores: guidely (client), guidelyReady, activeGuide, checklistProgress(key), guideCompleted(key); syncGuidelyUser(user | null) (see SvelteKit below); context helpers setGuidelyContext / getGuidelyContext; actions use:guideTrigger={"key"} and use:guidelyTarget. createGuidely throws a descriptive error when called during SSR — call it inside onMount.

SvelteKit

npm install @guidelytech/sveltekit
<!-- src/routes/+layout.svelte -->
<script lang="ts">
  import { env } from "$env/dynamic/public";
  import { initGuidely, guidelyEnv, syncGuidelyUser } from "@guidelytech/sveltekit";

  let { data, children } = $props();
  initGuidely(guidelyEnv(env)); // PUBLIC_GUIDELY_PROJECT_ID, PUBLIC_GUIDELY_ENV, PUBLIC_GUIDELY_API_URL

  // `data.user` comes from +layout.server.ts; null when signed out.
  $effect(() => {
    syncGuidelyUser(data.user ? { id: data.user.id, traits: { role: data.user.role }, account: { id: data.user.tenantId } } : null);
  });
</script>
{@render children()}

initGuidely is a no-op on the server ($app/environment.browser), calls page() from afterNavigate (one page_view per client-side navigation), and tears the client down when the layout is destroyed. guidelyEnv accepts $env/static/public, $env/dynamic/public or import.meta.env (VITE_GUIDELY_*).

Page views are automatic; users are not. Until you identify, activity is anonymous. syncGuidelyUser(user) mirrors your session into Guidely: it identifies when the id, traits or account change, does nothing when they don't, and calls reset() on sign-out (null). That includes an identity the SDK restored from localStorage after the server session ended. Pass undefined while the user is still loading. On Svelte 4 use $: syncGuidelyUser(...).

Vanilla JavaScript / script tag

<script>
  !function(w){if(w.Guidely)return;var g=w.Guidely={_q:[]},c=g._c={};function q(o,k){o[k]=function(){g._q.push([o===c?1:0,k,[].slice.call(arguments)])}}q(g,"init");"identify track page reset setAccount updateTraits setConsent setLocale startGuide stopGuide dismissGuide openMessenger closeMessenger showNewMessage openResourceCenter closeResourceCenter openChecklist closeChecklist completeChecklistTask openComplaint openIdeas captureException on".split(" ").forEach(function(k){q(c,k)});c.isFeatureEnabled=function(k,f){return!!f};c.getFeatureValue=function(k,f){return f};g.get=function(){return c}}(window);
  Guidely.init({ projectId: "pk_prod_xxx", environment: "production", apiUrl: "https://YOUR-GUIDELY-HOST" });
</script>
<script src="https://YOUR-GUIDELY-CDN/sdk/guidely.js" async></script>

The first line is a stub: it defines Guidely before the SDK has loaded, so Guidely.init(…), Guidely.get().identify(…), track(…) and the rest can be called straight away. Calls are queued and run in order once the SDK arrives; isFeatureEnabled / getFeatureValue answer their fallback until then. If the SDK can't load at all (Guidely unreachable, blocked by an extension), the calls do nothing and your page carries on. Copy the snippet from your project's install page: it fills in your key and URLs (YOUR-GUIDELY-CDN is the CDN in front of /sdk/*, or your Guidely host).

or declaratively: <script src="/sdk/guidely.js" data-project-id="pk_…" data-api-url="https://…"></script>. To track by version, pass your app's version too: Guidely.init({ …, appVersion: "2.4.1" }) or data-app-version="2.4.1" on the script tag (see App versions). Guidely.get() returns the active client; the API is identical to createGuidely() from @guidelytech/sdk-core (npm install @guidelytech/sdk-core for bundled apps).

Identify users

guidely.identify(userId, traits?, account?)
guidely.setAccount({ id, traits })
guidely.updateTraits({ plan: "enterprise" })
guidely.reset()   // on logout: new anonymous id, server state cleared

Traits are what targeting rules see (user.attribute, user.role, user.plan, account.attribute). The user id is what makes a visitor "logged in" for guides set to show to logged-in users or anonymous visitors only (user.identified). Only send what you need; keys like password, token, card are dropped. Anonymous activity before identify is merged into the identified profile. Parent accounts: an account trait parentAccountId (the parent account's id) files the account under that parent, so Accounts and reports can roll child accounts up into it: guidely.setAccount({ id: "acme-emea", traits: { name: "Acme EMEA", parentAccountId: "acme" } }). Support by client: messenger conversations are filed under the account the person is working in when they start one, for Reports → Clients. Pass the account on every login and call setAccount() when someone switches account, or their conversations count as "not tied to a client".

Track events

guidely.track("deal_created", { value: 1200 })

Custom events drive event triggers, advanceOn: "event" steps, checklist task completion (completion: "event") and appear in the Events explorer. page() is automatic.

Agent analytics (your own AI agents)

Send each turn of a conversation with your own AI agent or chatbot to Agent Analytics:

guidely.agentConversation({
  conversationId: thread.id,       // your conversation id
  agentId: "support-bot",          // the agent is created on its first turn
  agentName: "Support bot",
  role: "user",                    // user | assistant | tool | system
  text: message,
});

guidely.agentConversation({
  conversationId: thread.id,
  agentId: "support-bot",
  role: "assistant",
  text: reply.text,
  latencyMs: reply.latencyMs,
  toolCalls: [{ name: "lookup_order", status: "ok", latencyMs: 180 }], // names only: arguments are never sent
  outcome: "success",              // when it ends: success | failure | escalated | abandoned
  taskSuccess: true,               // optional; otherwise the AI classifier judges it
});

trackAgentTurn() is an alias; both also take an array of turns and return false when nothing was queued. The SDK fills in anonymousId, userId, accountId (from identify()) and sessionId (so a turn links to its session replay), a turnId and occurredAt. Turns are kept in their own persisted outbox (localStorage key guidely:agents:<key>, at most 20 requests for a day) and retried with backoff until the server accepts them; the server ignores turns it already has. With consent: "pending" turns wait in memory until consent is granted; denied or analytics: false sends nothing.

To change or drop turns before they leave the browser, pass agents.redact in the init options. It gets a copy of each turn and returns the turn to send, or null to drop it (an exception drops the turn too). It can't change which conversation, agent, turn or role it is:

createGuidely({
  projectId: "pk_prod_…",
  agents: { redact: (turn) => ({ ...turn, text: turn.text?.replace(/\bORD-\d+\b/g, "[order]") }) },
});

Guidely also redacts on the server per agent (Agent analytics → Agents → Redaction). From your servers, send turns with the REST endpoint instead (api.md). In React, useGuidely().agentConversation(…); with the script tag, Guidely.get().agentConversation(…) (calls made before the SDK loads are queued).

Feature flags

Every SDK above includes feature flags with the same public key — nothing else to configure. Flags are evaluated locally against attributes the SDK maintains (id = user id or anonymous id, identify traits, account, $audiences, page or screen, device, locale, environment, platform); experiment exposures are tracked as experiment_viewed events. Getters take a fallback, return it until flags load (or if Guidely is unreachable), and never throw.

// sdk-core / script tag (Guidely.get())
guidely.isFeatureEnabled("new-checkout");                   // boolean flags
guidely.getFeatureValue("checkout-button-color", "blue");   // string, number, JSON
guidely.onFlagsChange(() => rerender());
guidely.flags.updateAttributes({ cohort: "beta" });         // extra attributes
// React, Next.js, React Native
import { Feature, useFeatureValue, useFlag } from "@guidelytech/react"; // or /nextjs, /react-native
const on = useFlag("new-checkout");
const color = useFeatureValue("checkout-button-color", "blue");
<Feature flag="new-dashboard-banner" fallback={<Old />}><New /></Feature>
// Next.js server: RSC, route handlers, server actions, middleware
import { getFlags, getFlagsBootstrap } from "@guidelytech/nextjs/server";
const flags = await getFlags({ id: user.id, plan: user.plan });
flags.isEnabled("new-checkout");
// root layout: <Providers flagsPayload={await getFlagsBootstrap()}> → <GuidelyProvider flagsPayload={…}>
<!-- Svelte / SvelteKit -->
<script>
  import { flag, featureValue } from "@guidelytech/sveltekit"; // or @guidelytech/svelte
  const on = flag("new-checkout");
  const color = featureValue("checkout-button-color", "blue");
</script>
{#if $on}…{/if}

SvelteKit server: event.locals.flags = createServerFlags().forUser({ id }) in hooks.server.ts, flags: await loadFlags(event) in +layout.server.ts, and initGuidely({ …, flags: data.flags }) (all from @guidelytech/sveltekit/server / @guidelytech/sveltekit).

Servers, edge functions and flags-only apps use @guidelytech/flags directly (createFlagsClient({ sdkKey }), client.forUser(attrs) per request), or a server-only gly_sk_ key with environment for server-only flags. Pass flags: false to any SDK to turn flags off. Package READMEs list every hook, store and option; how flags are evaluated is described in feature-flags.md.

Replays, page analytics and errors

Page views (including the first one), page leave, clicks, rage clicks, heatmap click positions and uncaught errors are captured automatically, and session replay records sessions once an admin enables it in Settings → Privacy & data. No code is needed. See product-analytics.md.

guidely.captureException(error, { area: "checkout" })  // report a handled error (works with captureErrors: false; not when the project turns error tracking off)
guidely.captureFeedback({ message: "Export never finishes", email })  // a bug report for Monitor → User feedback, linked to the last error and this session
guidely.showBugReport()                     // the built-in "Report a bug" dialog
guidely.captureException(error, { tags: { area: "checkout" }, extra: { cartId }, level: "warning", fingerprint: ["{{ default }}", "checkout"] })
guidely.captureMessage("Checkout took 9 s", "warning")
guidely.setTag("plan", "pro"); guidely.setContext("cart", { items: 3 }); guidely.setUser({ id: "u_42", email })
guidely.addBreadcrumb({ category: "auth", message: "signed in" })
guidely.startSessionRecording()   // record this session even if it was not sampled
guidely.stopSessionRecording()
guidely.isRecording()
guidely.getSessionId()            // the id shared by events and the recording

Errors work like Sentry's browser SDK: each one carries the last 100 breadcrumbs (clicks, navigation, console.warn/error, fetch/XHR, guide events), browser/OS/device contexts, your tags and extra data, and its error.cause chain. Filter and edit them with createGuidely({ errors: { sampleRate, ignoreErrors, denyUrls, allowUrls, beforeSend, beforeBreadcrumb, breadcrumbs } }). Framework helpers: React <GuidelyErrorBoundary fallback={…}> and guidelyReactErrorHandler() (React 19 createRoot error options), Next.js onRequestError (instrumentation), withGuidely (route handlers), withServerActionGuidely and GuidelyGlobalError, SvelteKit handleErrorWithGuidely, Electron setupGuidelyMain({ errors: true }). See error-monitoring/sdks.md.

Mark up your markup for privacy: data-guidely-mask (text masked in recordings and click autocapture), data-guidely-block (not recorded at all), data-guidely-ignore (clicks not autocaptured), data-guidely-track (autocapture clicks on a custom element).

Guides, checklists, surveys, resource center

startGuide(key, { stepId? }), stopGuide(), dismissGuide(), getActiveGuide(), getGuides(), isGuideCompleted(key), getChecklistProgress(key), completeChecklistTask(key, taskId), openChecklist(key) / closeChecklist(key), openResourceCenter() / closeResourceCenter(), openArticle(articleId), refresh(), on(event, cb) / off, destroy(). A link to #guidely-article:<articleId> (what the guide editor's Link → Help article inserts) opens that article in the resource center, or in Scout's Help tab when the messenger is on; a modal or spotlight step closes to make way for it, a tooltip or banner stays. Events: ready, config, guide:start, guide:step, guide:complete, guide:dismiss, guide:skip, checklist:task, checklist:complete, survey:submit, resource-center:open, messenger:open, conversation:message, authoring, capture, error. Full reference: the @guidelytech/sdk-core package README.

Languages. Guides and the resource center show their translation for the visitor's language: the locale option or setLocale("fr") (pass null to go back to automatic), else the user's language / locale trait, else navigator.languages; exact tag first, then the base language, else the project's default language. Guide events carry properties.locale.

What the SDK enforces for you (no code needed): guide schedules (start/end window on any guide), project guide throttling (automatic launches only; startGuide() is never throttled), A/B tests (the variant ranges arrive folded into targeting; the SDK records experiment_viewed exposures, including for control groups that see nothing), scoped custom CSS, code-block steps (only served while your workspace allows them; blocked by a CSP without unsafe-eval), and the resource center's What's new (unread badge on the launcher, kept per device) and ordered, targeted sections. All of these are additive: older SDKs ignore what they don't know (an older SDK shows no A/B-tested guide while a test runs, and translations fall back to the default language).

Prototype tests (Validate): a guide or checklist button whose URL is a Guidely prototype test on the SDK's API origin (<apiUrl>/validate/<token>) opens the test in a full-screen overlay over your app instead of navigating or opening a tab. The overlay is a modal dialog (focus stays in it, Escape or the close button closes it) and closes itself when the tester finishes. The SDK passes the environment public key, anonymous id and identify() user id in the URL fragment, which never reaches a server log, so the results are attributed to that end user. openPrototypeTest(urlOrToken) opens a test from your own code and returns false, doing nothing, for any other URL. Older SDKs open the test page like any other link (it works there too, unattributed).

Scout messenger

When a project turns on Scout, every SDK shows the chat bubble automatically — no code changes. Optional controls: openMessenger(tab?) ("home", "messages", "help"), closeMessenger(), showNewMessage(text?), and the conversation:message event. With the messenger on, openResourceCenter() opens its Help tab. Call reset() on logout so the next user doesn't see the previous user's conversations.

How-tos your team makes available in the app (see how-tos.md) show in the messenger from @guidelytech/* 0.6.1 and later: among the page's suggestions on Home and in Help, in Help search, and as how-to cards under Scout's replies. They open inside the messenger with numbered steps and screenshots, plus Show me when the tour made from the how-to is live. To match the page, the SDK sends the page's path (no origin or query) to GET /sdk/how-tos, and the current page with each message, only while the project collects URLs (Settings → Privacy & data). Older SDKs ignore how-tos.

Guides (SDK 0.11.0): translations (locale option, setLocale()), A/B test exposures and control groups, guide throttling, schedules on every guide, custom CSS, code blocks, the resource center's What's new and ordered sections, and keyboard and screen-reader improvements. Script-tag installs get this without an upgrade; npm installs need 0.11.0 (older SDKs keep working but show no A/B-tested guide while a test runs and show guides in the default language).

Agent analytics and prototype tests (SDK 0.11.0): agentConversation() (alias trackAgentTurn()) sends your own AI agent's conversation turns to Agent Analytics, and a guide button linking to a Guidely prototype test opens it in a full-screen overlay (Validate). Script-tag installs get both without an upgrade.

Outages (SDK 0.10.0): the SDK keeps working while Guidely is unreachable. Guides start from the cached config, and events, survey answers and checklist progress wait in the browser until the server takes them. Background traffic backs off while the API is down. See Resilience. Script-tag installs get this without an upgrade.

Ideas (next SDK release): when the project turns on Ideas in the messenger, the messenger gets an Ideas tab (browse, search, vote with a priority, follow, comment and share ideas), Scout replies can carry a "Vote for …" / "Suggest this idea" button, and openIdeas(requestId?) opens the tab or one idea from your own buttons. Older SDKs ignore ideas; the hosted portal works without an upgrade.

Complaints (SDK 0.9.0): when the project takes complaints, the messenger home offers "File a complaint", Scout can offer the form in a reply, and openComplaint(categoryId?) opens it from your own buttons. Visitors you haven't identified only see it when the project allows anonymous complaints. Older SDKs ignore complaints.

Show me from Help (SDK 0.9.0): Help search results get a ▶ Show me button for how-tos whose tour is live and for articles with a Show me prompt, how-tos play their video, and Show me prompts inside article bodies (<p class="gd-show-me"><a href="#guidely-show-me:<guide key>">…</a></p>) become buttons that start the guide, or disappear where it isn't live. Guides started this way (and with startGuide()) offer Take me there when a step is on another page, and resume on the right step after a full page load. Tooltip steps set to advance on a click with no selector now advance when the highlighted element itself is clicked. Older SDKs show the prompt as a plain link that does nothing.

How-to capture

How-tos are step-by-step guides with screenshots that you record by clicking through your own app. In the dashboard, Record opens your app in a new tab with ?guidely_capture=<token>; the SDK sees the parameter, removes it from the URL and shows a recorder toolbar at the bottom centre (Start recording, Record without screenshots, then Pause, Done and Cancel). While recording it shrinks to a small pill with the step count, so it barely shows in screenshots; hover it (or tab to it) for the buttons. Each click, typed value, dropdown choice and page change becomes a step with its screenshot, a highlight of the element and selectors (so a step can later become a tour step). Your app keeps working normally while you record: Guidely never blocks or changes your clicks. Guides, widgets, the messenger, session replay and autocapture pause for that tab while recording.

  • SDK version: capture needs @guidelytech/* 0.6.1 or later (or the current script-tag build). Older SDKs ignore the parameter. Script-tag installs load the recorder from guidely-capture.js next to guidely.js, only in a capture session; allow it in a strict CSP like guidely-recorder.js.
  • Sharing the tab: Start recording asks the browser to share the screen. Choose this tab. Chrome and Edge suggest the current tab; in Safari and Firefox pick the tab yourself. If you share a window or the whole screen, the recorder asks you to share the tab instead, or to record without screenshots.
  • Page loads: browsers end screen sharing on a full page load (not on in-app navigation in a single-page app). Recording continues after the reload, but screenshots pause until you press Screenshots paused — Resume and share the tab again. A step whose screenshot was still uploading when the page unloaded is uploaded from the next page.
  • Automatic redaction: screenshots are redacted in the browser before upload, so the hidden pixels never leave it. Blurred are: password fields and other sensitive fields (payment and one-time-code autocomplete values; name/id containing pass, card, cvv, cvc, ssn, secret, token or otp), elements matching your mask selectors (data-guidely-mask, maskSelectors, the project setting) or data-guidely-redact, and visible text or field values that look like email addresses, card numbers, US Social Security numbers or phone numbers. Typed values are not recorded for sensitive fields or when they look like a card or SSN number, and masked elements are described without their text.
  • Redact more: add data-guidely-redact to anything that should be blurred in how-to screenshots (it also keeps the element's text out of step descriptions):
<section data-guidely-redact>…customer billing details…</section>

Electron and desktop apps

The web SDK (any adapter, or the script tag) runs in an Electron renderer like in a browser. Two things differ on the desktop, and the SDK handles both:

  • Page URLs. Desktop apps load file:///…/index.html#/settings or a custom protocol such as app://bundle/index.html. The SDK maps every non-http(s) URL to a stable, app-relative one (normalizeAppUrl): the hash route when there is one, otherwise the page file (settings.html → /settings, index.html → /) or the custom protocol's path. So file:///C:/Program Files/Acme/resources/app.asar/index.html#/deals/42 is the page file://app/deals/42, and guide URL patterns are written as on the web (/deals/*). Pass pageUrl: (href) => string to map URLs yourself.
  • App metadata. @guidelytech/electron reads the app version, OS, architecture and Electron version in the main process and hands them to the renderer through a preload bridge:
// main.ts
import { app, ipcMain } from "electron";
import { setupGuidelyMain } from "@guidelytech/electron/main";
app.whenReady().then(() => setupGuidelyMain({ app, ipcMain }));

// preload.ts (bundle it, or inline: contextBridge.exposeInMainWorld("guidelyElectron", { getAppInfo: () => ipcRenderer.invoke("guidely:app-info") }))
import { contextBridge, ipcRenderer } from "electron";
import { exposeGuidely } from "@guidelytech/electron/preload";
exposeGuidely({ contextBridge, ipcRenderer });

// renderer
import { createGuidelyElectron } from "@guidelytech/electron";
const guidely = await createGuidelyElectron({ projectId: "pk_prod_…", user: { id: me.id, traits: { plan: me.plan } } });
// React: <GuidelyProvider projectId="pk_prod_…" {...electronOptions(await getElectronAppInfo())}>

The app version feeds App version targeting rules, the appVersion flag attribute and release (source-mapped errors); desktopTraits(info) adds desktopOs, desktopOsVersion, desktopArch, electronVersion and appVersion to the user's traits. The browser is reported as electron. The offline queue, cached config and replay work unchanged (localStorage persists across launches). For file:// pages (Origin: null) or a custom protocol, leave the environment's allowed origins empty or add that origin; custom protocols must be registered with standard, secure and supportFetchAPI privileges. Guides use the Web platform. Details: packages/electron/README.md.

Options

projectId, environment, apiUrl, debug, locale (language for guides and the resource center), analytics (false = guides without analytics), consent (granted | pending | denied), storage (local | session | memory), pollIntervalMs, configRefreshMs, maskSelectors, onError, theme, user, disableAuthoring (also turns off how-to capture), autocapture (false or { pageviews?, pageLeave?, clicks?, rageClicks?, heatmaps?, mouseMovement? }), captureErrors, errors ({ sampleRate?, ignoreErrors?, denyUrls?, allowUrls?, beforeSend?, beforeBreadcrumb?, breadcrumbs?, maxBreadcrumbs? }, error monitoring), sessionReplay (false or { maskAllText?, blockSelectors?, recordNetwork?, recordNetworkPayloads?, maskNetworkRequest? }), release (your app version or commit, matched against uploaded source maps). These three can only switch off what the project settings switch on. appVersion (your app's version: sent with every event and recording so analytics, errors and replays can be filtered and broken down by version, see App versions; also used by App version rules and the appVersion flag attribute), pageUrl ((href) => string, maps the browser URL to the page URL Guidely uses; the default only rewrites file: and custom-protocol URLs, see Electron). flags (false, or feature-flag client options such as { payload, attributes, remoteEval, pollingMode }). agents ({ redact } for agent analytics turns).

Resilience

Guidely is not a single point of failure for your app:

  • The script: the install snippet's stub accepts every call even if guidely.js can't load, and the script-tag SDK is served from a CDN that keeps serving its cached copy while Guidely is down.
  • Guides, flags, messenger: configuration and flags are cached in localStorage with an ETag. If the server is slow or unreachable, a returning visitor's guides start from the cache within about 1.5 s and the fresh configuration is applied when it arrives.
  • Data: events (up to 500), survey answers and guide/checklist progress are kept in the browser, across page loads, until the server accepts them; the server drops duplicates. Session recordings are held in the tab (up to 1 MB) when the page is left during an outage.
  • Backing off: after repeated failures the SDK pauses background traffic (5 s up to 5 min, or as long as Retry-After asks) and resumes as soon as a request gets through or the browser comes back online, so a recovering server isn't flooded.

The iOS, Android and React Native SDKs behave the same way (see mobile.md), and the Java and PHP flag SDKs never block a request on an unreachable API (feature flag spec, §4 Client behaviour).

The SDK never throws into your application: errors surface via onError / the error event. Everything renders inside a Shadow DOM host (#guidely-root) with isolated styles.

Bundle size

~61 kB min+gzip for the npm runtime (sdk-core + runtime + floating-ui, including autocapture, error tracking and feature flags — flags are ~13 kB of that). Sentry-style error monitoring (breadcrumbs, scope, cause chains, fetch/XHR/console instrumentation) adds about 3 kB min+gzip. Two parts are separate chunks that load only when needed:

  • The Scout messenger (~12 kB, including the how-to view), when a project enables it.
  • The session-replay recorder (~27 kB: rrweb, its console plugin and the upload controller), only for sessions that are recorded.
  • The how-to capture recorder (toolbar, screenshots, redaction and uploads), only in a capture session.

The script-tag build (guidely.js, ~79 kB) inlines everything except the two recorders, which it loads from guidely-recorder.js and guidely-capture.js in the same directory.