window.peeve
The running widget, lowercase. Available once
widget.js has booted.
This is what the script tag gives you.Peeve
The npm package export, capital.
import { Peeve } from "@peeve/sdk".
It boots the widget and forwards calls to it.Peeve —
it queues calls made before the widget has loaded, which window.peeve cannot
do because it does not exist yet.
window.peeve
identify(user)
Record who the signed-in user is.
Extra keys are accepted, but business context belongs in
setContext, which is
built for it.
Returns the widget, so calls chain.
setContext(ctx)
Attach any business context to the current user, as open key/value.
open()
Open the ask panel programmatically, for your own “Get help” button.
init(options)
Mount the widget manually. You do not normally need this — the script tag
auto-boots — but it lets you pass options that have no script attribute.
init() keeps both.
Useful options:
state
A read-only snapshot, useful when debugging.
destroy()
Tear the widget down and remove it from the page.
Peeve (npm package)
Peeve.init({ publishableKey, name? })
Boot the widget. Throws if publishableKey is missing. No-op during SSR.
Peeve.identify(userIdOrTraits, traits?)
Two call shapes, both equivalent:
userId here, where the widget’s own identify uses id.
The package maps between them.
Accepts userId, email, name, company, phone, plan, createdAt.
createdAt may be an ISO string or epoch milliseconds — it is normalised for
you.
Calls made before the widget has loaded are queued and flushed when it appears
(the package polls for about 20 seconds, then gives up).
Peeve.setContext(ctx)
Peeve.reset()
Clear the identity and context. Call this on logout — otherwise the next
person to use that browser inherits the previous user’s identity.
window.peeve has no reset(). From the raw widget, clear identity by
calling the underlying identify(null); if you are managing sessions, use the
package, where reset() is the supported path.