Docs
grovs.io Start for free

API reference

Every public type and method in the Grovs Web SDK 2.1.

Requires Web SDK 2.1.0

All methods are static on the default export, Grovs.

Imports

javascript
import Grovs, { GrovsError, SDK_VERSION } from "grovs";
ExportKindWhat it is
Grovs (default)classEvery method on this page
GrovsErrorenumSDK error codes
SDK_VERSIONconstantThe SDK version string
GrovsV1classThe deprecated 1.x API
GrovsConfigtypeOptions for configure
DeeplinkCallbacktypeThe onDeeplink callback
ErrorCallbacktypeThe onError callback
LogLeveltypeLog verbosity
CreateLinkParamstypeOptions for generateLink
CustomRedirectstypePer-platform link redirects
ScreenNameProvidertypeCustom screen name resolver
ScreenNameDecisiontypeWhat the resolver returns
CustomPurchasetypeInput for logCustomPurchase
TransactionTypetypePurchase event kind
InAppCallbackstypeIn-app message callbacks
SmartBannerLinkDatatypeLink for the smart banner
GrovsMessagetypeDeprecated inbox message
MessagesThemetypeDeprecated inbox theme

At a glance

AreaMemberKindWhat it does
SetupconfiguremethodCreates the client and authenticates
setEnabledmethodStops or restarts the SDK
grantConsentmethodStarts tracking after consent
resetmethodClears stored identity and queue
setDebugLevelmethodSets the minimum log level
isAuthenticatedmethodWhether the client is authenticated
Deep linkslastReceivedPayloadmethodMost recent deep link payload
allReceivedPayloadsSinceStartupmethodEvery payload since page load
UserssetUserIdentifiermethodSets your ID for the user
setUserAttributesmethodSets user attributes
userIdentifierpropertyCurrent user identifier
userAttributespropertyCurrent user attributes
LinksgenerateLinkmethodCreates a smart link
linkDetailsmethodDetails of a link by path
EventstrackmethodTracks a custom event
trackScreenViewmethodTracks a screen view
setGlobalTagsmethodTags added to every event
setScreenAliasesmethodRenames URL patterns for the dashboard
screenNameProviderpropertyCustom resolver for screen names
flushmethodSends queued events now
RevenuelogCustomPurchasemethodLogs a purchase
In-app messagesinApp.pausemethodHolds messages back
inApp.resumemethodLets messages show again
inApp.discardmethodDrops the waiting message
inApp.setExcludedScreensmethodScreens where no message shows
inApp.setCallbacksmethodSets in-app callbacks
inApp.setDebugmethodLogs why campaigns were skipped
Smart bannerssmartBanner.setLinkDatamethodSets the banner's link
smartBanner.hidemethodHides the banner on this page
smartBanner.refreshmethodRuns banner selection again
TypesGrovsConfiginterfaceOptions for configure
CreateLinkParamsinterfaceOptions for generateLink
CustomRedirectsinterfacePer-platform link redirects
CustomPurchaseinterfaceInput for logCustomPurchase
TransactionTypetypePurchase event kind
GrovsErrorenumSDK error codes
InAppCallbacksinterfaceIn-app message callbacks
SmartBannerLinkDatainterfaceLink for the smart banner
LogLeveltypeLog verbosity
ScreenNameProvidertypeCustom screen name resolver
DeeplinkCallbackcallbackGets each deep link payload
ErrorCallbackcallbackGets each SDK error
SDK_VERSIONpropertyThe SDK version string
DeprecatedMessages inbox methodsmethodDo nothing
GrovsMessagetypeInbox message
MessagesThemetypeInbox theme, ignored
GrovsV1classThe 1.x API

Setup

configure

method
typescript
Grovs.configure(config: GrovsConfig): Promise<boolean>

Creates the client and authenticates. Options: GrovsConfig.

Returns true when authenticated. The false cases: Configuration options.

  • Rejects if apiKey is missing.
  • Calling it again with the same settings on an authenticated client keeps the client and takes the new callbacks. There's no re-authentication or second smart banner view.
  • Different settings, or a client disabled with setEnabled(false), build a new client.

Calls made before configure:

CallsEffect
Grovs.inApp methods, smartBanner.setLinkData, smartBanner.hideApplied once configure runs
setUserIdentifier, setUserAttributesWork once configure is called, before it resolves
Methods returning a PromiseResolve an empty value of their type, such as null or false
isAuthenticated, payload getters, accessorsReturn defaults
Other action methodsNo-op. Log a warning, visible only if setDebugLevel raised the pre-configure level

setEnabled

method
typescript
Grovs.setEnabled(enabled: boolean): void

Stops or restarts the SDK. See Disabling the SDK.

grantConsent

methodSince 2.0
typescript
Grovs.grantConsent(): Promise<boolean>

Grants consent when configure was called with requireConsent: true. See Privacy & Consent.

  • Moves events tracked meanwhile into durable storage, then authenticates.

reset

methodSince 2.0
typescript
Grovs.reset(): void

Clears stored identifiers, the session and queued events. Stops tracking until the next configure.

setDebugLevel

method
typescript
Grovs.setDebugLevel(level: "info" | "warn" | "error"): void

Sets the configured client's minimum log level.

  • Before configure, it affects only pre-configure warnings. The client starts at the debugLevel option.
  • Any value other than "info", "warn" or "error" silences all output.

isAuthenticated

method
typescript
Grovs.isAuthenticated(): boolean

Whether the client is authenticated.

  • false until authentication succeeds, after reset(), and while a transient failure retries.
  • Turns true when the authenticate request succeeds, slightly before configure resolves.

Payloads also reach the onDeeplink callback. See Deep Linking.

lastReceivedPayload

method
typescript
Grovs.lastReceivedPayload(): Record<string, unknown> | null

Gets the most recent deep link payload, or null.

allReceivedPayloadsSinceStartup

method
typescript
Grovs.allReceivedPayloadsSinceStartup(): Record<string, unknown>[]

Gets every payload received since the page loaded.


Users

setUserIdentifier

method
typescript
Grovs.setUserIdentifier(identifier: string | null): void

Sets your identifier for the current user. Safe to call before configure resolves.

setUserAttributes

method
typescript
Grovs.setUserAttributes(attributes: Record<string, unknown> | null): void

Sets attributes describing the current user. Safe to call before configure resolves.

userIdentifier

property
typescript
Grovs.userIdentifier: string | null

The current user identifier.

  • Whichever of the local and server values was set wins. Otherwise the server's is adopted.

userAttributes

property
typescript
Grovs.userAttributes: Record<string, unknown> | null

The current user attributes, with the same precedence as userIdentifier.


method
typescript
Grovs.generateLink(params: CreateLinkParams): Promise<string | null>

Creates a smart link. Fields: CreateLinkParams. See Link Creation.

Returns the URL, or null on failure. The reason goes to onError.

linkDetails

methodSince 2.0
typescript
Grovs.linkDetails(path: string): Promise<Record<string, unknown> | null>

Gets details for a link generated in the current environment, by path.

Returns the details, or null when the path is unknown.


Events

See Events & Screen Tracking.

track

methodSince 2.0
typescript
Grovs.track(name: string, properties?: Record<string, unknown>, tags?: string[]): void

Tracks a custom event.

trackScreenView

methodSince 2.0
typescript
Grovs.trackScreenView(screenName: string, properties?: Record<string, unknown>): void

Tracks a screen view. Names are capped at 255 characters.

setGlobalTags

methodSince 2.0
typescript
Grovs.setGlobalTags(tags: string[] | null): void

Sets tags attached to every later event, including system events. Pass null to clear them.

setScreenAliases

methodSince 2.0
typescript
Grovs.setScreenAliases(aliases: Record<string, string>): void

Maps URL patterns to dashboard names. See Screen name aliases.

typescript
Grovs.setScreenAliases({ "/product/:id": "Product", "/docs/*": "Documentation" });

screenNameProvider

propertySince 2.0
typescript
Grovs.screenNameProvider: ((url: URL) => string | "suppress" | "automatic") | null

Resolver consulted first for automatically tracked screens. See Custom resolver.

flush

methodSince 2.0
typescript
Grovs.flush(): Promise<void>

Sends the event queue now, ignoring the interval and any server cooldown.

  • If a delivery is in progress, it joins that one.
  • Resolves immediately without sending before authentication, before attribution resolves, or while consent is pending.

Revenue

logCustomPurchase

methodSince 2.0
typescript
Grovs.logCustomPurchase(purchase: CustomPurchase): Promise<boolean>

Logs a purchase. Fields: CustomPurchase. See Revenue.

  • Requires a Grovs Enterprise backend.

In-app messages

See In-app messages. Every Grovs.inApp method works before configure and carries over to later configure calls.

inApp.pause

methodSince 2.1
typescript
Grovs.inApp.pause(): void

Holds messages back, during a checkout or video, say. The newest highest priority one waits.

inApp.resume

methodSince 2.1
typescript
Grovs.inApp.resume(): void

Lets messages show again, starting with the one that waited, if it still qualifies.

inApp.discard

methodSince 2.1
typescript
Grovs.inApp.discard(dismiss?: boolean): void   // default false

Drops the waiting message and stays paused. Pass true to also close the message on screen.

inApp.setExcludedScreens

methodSince 2.1
typescript
Grovs.inApp.setExcludedScreens(names: string[]): void

Sets screens where no message shows. Messages wait.

  • Use tracked screen names, from trackScreenView or automatic tracking.

inApp.setCallbacks

methodSince 2.1
typescript
Grovs.inApp.setCallbacks(callbacks: InAppCallbacks): void

Replaces the in-app callbacks. See InAppCallbacks.

inApp.setDebug

methodSince 2.1
typescript
Grovs.inApp.setDebug(enabled: boolean): void

Logs, at info level, each campaign considered for an event and why it was skipped.


Smart banners

See Smart banners.

smartBanner.setLinkData

methodSince 2.1
typescript
Grovs.smartBanner.setLinkData(data: SmartBannerLinkData): void

Sets the link the banner opens on the current page. Fields: SmartBannerLinkData.

  • A call before configure applies once it runs.
  • Data over a limit isn't sent, and the banner keeps its default link.

smartBanner.hide

methodSince 2.1
typescript
Grovs.smartBanner.hide(): void

Hides the banner on this page only. Not counted as a dismissal.

smartBanner.refresh

methodSince 2.1
typescript
Grovs.smartBanner.refresh(): Promise<void>

Runs banner selection again. Never rejects.


Types

GrovsConfig

interface
typescript
interface GrovsConfig {
  apiKey: string;
  testEnvironment?: boolean;       // default false
  baseURL?: string;                // default: Grovs cloud
  cookieDomain?: string;           // default: host-only
  autoTrackScreenViews?: boolean;  // default true
  requireConsent?: boolean;        // default false
  appVersion?: string;             // default: SDK version
  debugLevel?: LogLevel;           // default "error"
  messagesTheme?: MessagesTheme;   // deprecated, ignored
  onDeeplink?: (payload: Record<string, unknown>) => void;
  onError?: (code: GrovsError, message: string) => void;
  smartBanner?: boolean;           // default true
}

Options for configure. Descriptions: Configuration options.

CreateLinkParams

interface
typescript
interface CreateLinkParams {
  title?: string;
  subtitle?: string;
  imageURL?: string;
  data?: Record<string, unknown>;
  tags?: string[];
  customRedirects?: CustomRedirects;
  showPreviewiOS?: boolean;
  showPreviewAndroid?: boolean;
  copyToClipboardiOS?: boolean;
  copyToClipboardAndroid?: boolean;
  trackingCampaign?: string;
  trackingSource?: string;
  trackingMedium?: string;
}

Options for generateLink. Every field is optional.

NameTypeDescription
titlestringLink preview title.
subtitlestringLink preview subtitle.
imageURLstringLink preview image URL.
dataRecord<string, unknown>Custom payload delivered when the link is opened. Must be JSON-serializable.
tagsstring[]Tags for filtering and analytics.
customRedirectsCustomRedirectsPer-platform redirect overrides.
showPreviewiOSbooleanShow the preview page on iOS. Omit to use the project default.
showPreviewAndroidbooleanShow the preview page on Android. Omit to use the project default.
copyToClipboardiOSbooleanCopy the link on the iOS preview page, so the native SDK can match a fresh install. Omit to use the project setting.
copyToClipboardAndroidbooleanSame, for Android.
trackingCampaignstringUTM campaign, for example "BlackFriday2025".
trackingSourcestringUTM source, for example "newsletter".
trackingMediumstringUTM medium, for example "email".

CustomRedirects

interface
typescript
interface CustomRedirects {
  ios?: { link?: string; openAppIfInstalled?: boolean };
  android?: { link?: string; openAppIfInstalled?: boolean };
  desktop?: { link?: string };
}

Per-platform redirect overrides for generateLink.

CustomPurchase

interfaceSince 2.0
typescript
interface CustomPurchase {
  type: TransactionType;
  priceInCents: number;
  currency: string;
  productID: string;
  startDate?: Date;
  transactionID?: string;
}

Input for logCustomPurchase.

TransactionType

typeSince 2.0
typescript
type TransactionType = "buy" | "cancel" | "refund" | "refund_reversed";

The kind of purchase event in CustomPurchase.

GrovsError

enum
typescript
enum GrovsError {
  authenticationFailed = 1,
  networkRequestFailed = 2,
  eventDispatchFailed = 3,
  linkGenerationFailed = 4,
  inAppDisplayFailed = 5,
}

Failure categories passed to onError. See Handling SDK errors.

  • inAppDisplayFailed (new in 2.1): an in-app message couldn't be drawn, for example HTML blocked by the page's Content-Security-Policy.
  • Numeric values match the iOS SDK's GrovsError and are stable.

InAppCallbacks

interfaceSince 2.1
typescript
interface InAppCallbacks {
  beforeShow?: (campaignId: string) => boolean;
  onShown?: (campaignId: string) => void;
  onClicked?: (campaignId: string, buttonId: string | null, payload: Record<string, unknown> | null) => void;
  onDismissed?: (campaignId: string, reason: string) => void;
  onAnswered?: (campaignId: string, value: number | string, comment: string | null) => void;
}

Passed to inApp.setCallbacks.

CallbackCalled when
beforeShowA message is about to show. Return false to stop it. It gains no view and nothing else shows for that event.
onShownA message is on screen.
onClickedThe user clicks the message or a button.
onDismissedA message closes.
onAnsweredAn answered message has closed. value is a number for stars or the option's ID for a choice.

SmartBannerLinkData

interfaceSince 2.1
typescript
interface SmartBannerLinkData {
  page_path?: string;                  // defaults to the current page's path
  data?: Record<string, unknown>;      // flat: string, number or boolean values
}

Passed to smartBanner.setLinkData.

LogLevel

type
typescript
type LogLevel = "info" | "warn" | "error";

The debugLevel option of GrovsConfig.

ScreenNameProvider (type)

typeSince 2.0
typescript
type ScreenNameDecision = string | "suppress" | "automatic";
type ScreenNameProvider = (url: URL) => ScreenNameDecision;

The type of screenNameProvider.

DeeplinkCallback

callback
typescript
type DeeplinkCallback = (payload: Record<string, unknown>) => void;

The onDeeplink option of GrovsConfig.

ErrorCallback

callback
typescript
type ErrorCallback = (code: GrovsError, message: string) => void;

The onError option of GrovsConfig.

SDK_VERSION

property
typescript
const SDK_VERSION: string   // "2.1"

Sent as the SDK-VERSION header on every request.


Deprecated

Messages inbox methods

methodDeprecated in 2.1
typescript
Grovs.showMessagesList(): Promise<void>
Grovs.displayAutomaticMessages(): Promise<void>
Grovs.getMessages(page: number): Promise<GrovsMessage[]>
Grovs.numberOfUnreadMessages(): Promise<number>
Grovs.markMessageAsRead(id: number): Promise<boolean>

The messages inbox was removed in 2.1. These methods remain so existing pages keep working. None makes a request. Use in-app messages.

MethodNow
showMessagesListDoes nothing
displayAutomaticMessagesDoes nothing
getMessagesResolves []
numberOfUnreadMessagesResolves 0
markMessageAsReadResolves true

GrovsMessage

typeDeprecated in 2.1
typescript
import type { GrovsMessage } from "grovs";

An inbox message. Kept for existing imports.

MessagesTheme

typeDeprecated in 2.1
typescript
import type { MessagesTheme } from "grovs";

configure accepts and ignores it since the inbox was removed. Kept for existing imports.

GrovsV1

classDeprecated in 2.0
typescript
import { GrovsV1 } from "grovs";

The 1.x class, also reachable as Grovs.V1 and by constructing the default export. See Upgrading to 2.0.

Last updated 2026-10-27
Was this page helpful?