API reference
Every public type and method in the Grovs Web SDK 2.1.
All methods are static on the default export, Grovs.
Imports
import Grovs, { GrovsError, SDK_VERSION } from "grovs";| Export | Kind | What it is |
|---|---|---|
Grovs (default) | class | Every method on this page |
GrovsError | enum | SDK error codes |
SDK_VERSION | constant | The SDK version string |
GrovsV1 | class | The deprecated 1.x API |
GrovsConfig | type | Options for configure |
DeeplinkCallback | type | The onDeeplink callback |
ErrorCallback | type | The onError callback |
LogLevel | type | Log verbosity |
CreateLinkParams | type | Options for generateLink |
CustomRedirects | type | Per-platform link redirects |
ScreenNameProvider | type | Custom screen name resolver |
ScreenNameDecision | type | What the resolver returns |
CustomPurchase | type | Input for logCustomPurchase |
TransactionType | type | Purchase event kind |
InAppCallbacks | type | In-app message callbacks |
SmartBannerLinkData | type | Link for the smart banner |
GrovsMessage | type | Deprecated inbox message |
MessagesTheme | type | Deprecated inbox theme |
At a glance
| Area | Member | Kind | What it does |
|---|---|---|---|
| Setup | configure | method | Creates the client and authenticates |
setEnabled | method | Stops or restarts the SDK | |
grantConsent | method | Starts tracking after consent | |
reset | method | Clears stored identity and queue | |
setDebugLevel | method | Sets the minimum log level | |
isAuthenticated | method | Whether the client is authenticated | |
| Deep links | lastReceivedPayload | method | Most recent deep link payload |
allReceivedPayloadsSinceStartup | method | Every payload since page load | |
| Users | setUserIdentifier | method | Sets your ID for the user |
setUserAttributes | method | Sets user attributes | |
userIdentifier | property | Current user identifier | |
userAttributes | property | Current user attributes | |
| Links | generateLink | method | Creates a smart link |
linkDetails | method | Details of a link by path | |
| Events | track | method | Tracks a custom event |
trackScreenView | method | Tracks a screen view | |
setGlobalTags | method | Tags added to every event | |
setScreenAliases | method | Renames URL patterns for the dashboard | |
screenNameProvider | property | Custom resolver for screen names | |
flush | method | Sends queued events now | |
| Revenue | logCustomPurchase | method | Logs a purchase |
| In-app messages | inApp.pause | method | Holds messages back |
inApp.resume | method | Lets messages show again | |
inApp.discard | method | Drops the waiting message | |
inApp.setExcludedScreens | method | Screens where no message shows | |
inApp.setCallbacks | method | Sets in-app callbacks | |
inApp.setDebug | method | Logs why campaigns were skipped | |
| Smart banners | smartBanner.setLinkData | method | Sets the banner's link |
smartBanner.hide | method | Hides the banner on this page | |
smartBanner.refresh | method | Runs banner selection again | |
| Types | GrovsConfig | interface | Options for configure |
CreateLinkParams | interface | Options for generateLink | |
CustomRedirects | interface | Per-platform link redirects | |
CustomPurchase | interface | Input for logCustomPurchase | |
TransactionType | type | Purchase event kind | |
GrovsError | enum | SDK error codes | |
InAppCallbacks | interface | In-app message callbacks | |
SmartBannerLinkData | interface | Link for the smart banner | |
LogLevel | type | Log verbosity | |
ScreenNameProvider | type | Custom screen name resolver | |
DeeplinkCallback | callback | Gets each deep link payload | |
ErrorCallback | callback | Gets each SDK error | |
SDK_VERSION | property | The SDK version string | |
| Deprecated | Messages inbox methods | method | Do nothing |
GrovsMessage | type | Inbox message | |
MessagesTheme | type | Inbox theme, ignored | |
GrovsV1 | class | The 1.x API |
Setup
configure
Grovs.configure(config: GrovsConfig): Promise<boolean>Creates the client and authenticates. Options: GrovsConfig.
Returns true when authenticated. The false cases: Configuration options.
- Rejects if
apiKeyis 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:
| Calls | Effect |
|---|---|
Grovs.inApp methods, smartBanner.setLinkData, smartBanner.hide | Applied once configure runs |
setUserIdentifier, setUserAttributes | Work once configure is called, before it resolves |
| Methods returning a Promise | Resolve an empty value of their type, such as null or false |
isAuthenticated, payload getters, accessors | Return defaults |
| Other action methods | No-op. Log a warning, visible only if setDebugLevel raised the pre-configure level |
setEnabled
Grovs.setEnabled(enabled: boolean): voidStops or restarts the SDK. See Disabling the SDK.
grantConsent
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
Grovs.reset(): voidClears stored identifiers, the session and queued events. Stops tracking until the next configure.
setDebugLevel
Grovs.setDebugLevel(level: "info" | "warn" | "error"): voidSets the configured client's minimum log level.
- Before
configure, it affects only pre-configure warnings. The client starts at thedebugLeveloption. - Any value other than
"info","warn"or"error"silences all output.
isAuthenticated
Grovs.isAuthenticated(): booleanWhether the client is authenticated.
falseuntil authentication succeeds, afterreset(), and while a transient failure retries.- Turns
truewhen the authenticate request succeeds, slightly beforeconfigureresolves.
Deep links
Payloads also reach the onDeeplink callback. See Deep Linking.
lastReceivedPayload
Grovs.lastReceivedPayload(): Record<string, unknown> | nullGets the most recent deep link payload, or null.
allReceivedPayloadsSinceStartup
Grovs.allReceivedPayloadsSinceStartup(): Record<string, unknown>[]Gets every payload received since the page loaded.
Users
setUserIdentifier
Grovs.setUserIdentifier(identifier: string | null): voidSets your identifier for the current user. Safe to call before configure resolves.
setUserAttributes
Grovs.setUserAttributes(attributes: Record<string, unknown> | null): voidSets attributes describing the current user. Safe to call before configure resolves.
userIdentifier
Grovs.userIdentifier: string | nullThe current user identifier.
- Whichever of the local and server values was set wins. Otherwise the server's is adopted.
userAttributes
Grovs.userAttributes: Record<string, unknown> | nullThe current user attributes, with the same precedence as userIdentifier.
Links
generateLink
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
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
track
Grovs.track(name: string, properties?: Record<string, unknown>, tags?: string[]): voidTracks a custom event.
- Refuses reserved names.
- Events can trigger in-app messages.
- Sanitization and limits: Tracking custom events.
trackScreenView
Grovs.trackScreenView(screenName: string, properties?: Record<string, unknown>): voidTracks a screen view. Names are capped at 255 characters.
setGlobalTags
Grovs.setGlobalTags(tags: string[] | null): voidSets tags attached to every later event, including system events. Pass null to clear them.
setScreenAliases
Grovs.setScreenAliases(aliases: Record<string, string>): voidMaps URL patterns to dashboard names. See Screen name aliases.
Grovs.setScreenAliases({ "/product/:id": "Product", "/docs/*": "Documentation" });screenNameProvider
Grovs.screenNameProvider: ((url: URL) => string | "suppress" | "automatic") | nullResolver consulted first for automatically tracked screens. See Custom resolver.
flush
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
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
Grovs.inApp.pause(): voidHolds messages back, during a checkout or video, say. The newest highest priority one waits.
inApp.resume
Grovs.inApp.resume(): voidLets messages show again, starting with the one that waited, if it still qualifies.
inApp.discard
Grovs.inApp.discard(dismiss?: boolean): void // default falseDrops the waiting message and stays paused. Pass true to also close the message on screen.
inApp.setExcludedScreens
Grovs.inApp.setExcludedScreens(names: string[]): voidSets screens where no message shows. Messages wait.
- Use tracked screen names, from
trackScreenViewor automatic tracking.
inApp.setCallbacks
Grovs.inApp.setCallbacks(callbacks: InAppCallbacks): voidReplaces the in-app callbacks. See InAppCallbacks.
inApp.setDebug
Grovs.inApp.setDebug(enabled: boolean): voidLogs, at info level, each campaign considered for an event and why it was skipped.
Smart banners
See Smart banners.
smartBanner.setLinkData
Grovs.smartBanner.setLinkData(data: SmartBannerLinkData): voidSets the link the banner opens on the current page. Fields: SmartBannerLinkData.
- A call before
configureapplies once it runs. - Data over a limit isn't sent, and the banner keeps its default link.
smartBanner.hide
Grovs.smartBanner.hide(): voidHides the banner on this page only. Not counted as a dismissal.
smartBanner.refresh
Grovs.smartBanner.refresh(): Promise<void>Runs banner selection again. Never rejects.
Types
GrovsConfig
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 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.
| Name | Type | Description |
|---|---|---|
title | string | Link preview title. |
subtitle | string | Link preview subtitle. |
imageURL | string | Link preview image URL. |
data | Record<string, unknown> | Custom payload delivered when the link is opened. Must be JSON-serializable. |
tags | string[] | Tags for filtering and analytics. |
customRedirects | CustomRedirects | Per-platform redirect overrides. |
showPreviewiOS | boolean | Show the preview page on iOS. Omit to use the project default. |
showPreviewAndroid | boolean | Show the preview page on Android. Omit to use the project default. |
copyToClipboardiOS | boolean | Copy the link on the iOS preview page, so the native SDK can match a fresh install. Omit to use the project setting. |
copyToClipboardAndroid | boolean | Same, for Android. |
trackingCampaign | string | UTM campaign, for example "BlackFriday2025". |
trackingSource | string | UTM source, for example "newsletter". |
trackingMedium | string | UTM medium, for example "email". |
CustomRedirects
interface CustomRedirects {
ios?: { link?: string; openAppIfInstalled?: boolean };
android?: { link?: string; openAppIfInstalled?: boolean };
desktop?: { link?: string };
}Per-platform redirect overrides for generateLink.
CustomPurchase
interface CustomPurchase {
type: TransactionType;
priceInCents: number;
currency: string;
productID: string;
startDate?: Date;
transactionID?: string;
}Input for logCustomPurchase.
TransactionType
type TransactionType = "buy" | "cancel" | "refund" | "refund_reversed";The kind of purchase event in CustomPurchase.
GrovsError
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
GrovsErrorand are stable.
InAppCallbacks
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.
| Callback | Called when |
|---|---|
beforeShow | A message is about to show. Return false to stop it. It gains no view and nothing else shows for that event. |
onShown | A message is on screen. |
onClicked | The user clicks the message or a button. |
onDismissed | A message closes. |
onAnswered | An answered message has closed. value is a number for stars or the option's ID for a choice. |
SmartBannerLinkData
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 LogLevel = "info" | "warn" | "error";The debugLevel option of GrovsConfig.
ScreenNameProvider (type)
type ScreenNameDecision = string | "suppress" | "automatic";
type ScreenNameProvider = (url: URL) => ScreenNameDecision;The type of screenNameProvider.
DeeplinkCallback
type DeeplinkCallback = (payload: Record<string, unknown>) => void;The onDeeplink option of GrovsConfig.
ErrorCallback
type ErrorCallback = (code: GrovsError, message: string) => void;The onError option of GrovsConfig.
SDK_VERSION
const SDK_VERSION: string // "2.1"Sent as the SDK-VERSION header on every request.
Deprecated
Messages inbox methods
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.
| Method | Now |
|---|---|
showMessagesList | Does nothing |
displayAutomaticMessages | Does nothing |
getMessages | Resolves [] |
numberOfUnreadMessages | Resolves 0 |
markMessageAsRead | Resolves true |
GrovsMessage
import type { GrovsMessage } from "grovs";An inbox message. Kept for existing imports.
MessagesTheme
import type { MessagesTheme } from "grovs";configure accepts and ignores it since the inbox was removed. Kept for existing imports.
GrovsV1
import { GrovsV1 } from "grovs";The 1.x class, also reachable as Grovs.V1 and by constructing the default export. See Upgrading to 2.0.