Skip to content

About

MicroSurveys Web SDK: in-app surveys for React apps, triggered by the analytics events you already track.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

MicroSurveys Web SDK

In-app micro-surveys for the web — the browser counterpart to the MicroSurveys iOS SDK. Drop it into your React app, fire events, and targeted surveys present themselves; AI reads the responses back for you in the dashboard.

This repository holds the web/JS packages: one package per framework, all sharing a single framework-agnostic runtime.

Packages

Package What it is
@microsurveysai/web-core Framework-agnostic browser runtime — on-device trigger evaluation, deterministic sampling, config cache, offline ingest. No UI.
@microsurveysai/react React SDK — provider, hooks, auto-triggered overlay surveys, and inline <MicroSurvey>.

Planned: @microsurveysai/js (script-tag embed), @microsurveysai/vue, @microsurveysai/svelte — all reusing web-core unchanged.

Quick start (React)

npm install @microsurveysai/react
import { MicroSurveysProvider, useMicroSurveys } from "@microsurveysai/react";

function App() {
  return (
    <MicroSurveysProvider apiKey="ms_live_…">
      <YourApp />
    </MicroSurveysProvider>
  );
}

function Checkout() {
  const { track } = useMicroSurveys();
  // Fire an event; an eligible survey presents itself after its configured delay.
  return <button onClick={() => track("checkout_completed", { plan: "pro" })}>Buy</button>;
}

Embed a specific survey inline (e.g. in a settings page):

import { MicroSurvey } from "@microsurveysai/react";

<MicroSurvey surveyId="svy_abc" onComplete={(r) => console.log(r)} />;

Your API key is the browser-embeddable project key from the dashboard (same key type the iOS SDK ships). Surveys, triggers, targeting, and theme are configured in the dashboard and evaluated on-device — no server round-trip to decide what to show.

Surveys can also trigger on events your backend sends to Amplitude (set up under server events in the dashboard). The SDK picks them up for the signed-in user when the page opens, when the tab comes back into view, and every few minutes while it's open, so call identify(userId) with the same user id your backend sends to Amplitude.

Development

pnpm install
pnpm build       # tsup → ESM + CJS + d.ts
pnpm test        # vitest (web-core runtime)
pnpm typecheck

Releases are published to npm and tagged here, with notes on the Releases page. This repository doesn't take pull requests; found a bug or need something? Open an issue.

License

MIT

About

MicroSurveys Web SDK: in-app surveys for React apps, triggered by the analytics events you already track.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages