MiteSDK

Mite Instance API

Every namespace, method, and property on the Mite class.

The Mite class is the imperative surface under every hook and component. Reach it with useMite() inside the provider, or keep a reference to the instance you constructed.

import { Mite } from '@usemite/sdk'

const mite = new Mite({ apiKey: process.env.EXPO_PUBLIC_MITE_API_KEY })
mite.init()

Each area has its own namespace, so mite. autocompletes to feedback, features, errors, user, releases, announcements, and storeReview.

These methods throw [Mite] API key is required to … when apiKey is not configured: feedback.send, every features method, user.identify, releases.list, and announcements.list. The rest work without one. errors.capture does not throw, but sends nothing without a key.

Lifecycle

init(): void

Sets up the offline queue, starts a background identity sync, sends errors a previous launch left behind, and flushes errors when the app moves to the background. Call it once after constructing the instance. Calling it again logs [Mite] SDK already initialized and returns.

Also warns when no persistent identityStorage is configured.

destroy(): void

Stops the offline queue flush timer, discards anything pending, removes the error handlers, and marks the instance uninitialized. init() can be called again afterward.

mite.feedback

See Feedback.

feedback.send(input: SendFeedbackInput): Promise<SendFeedbackResult>

Send a bug, question, idea, or other message. message is required and type defaults to 'other'. The SDK adds identity, device info, the build, and the navigation trail, uploads any attachments, and posts to /api/v1/feedback.

Check result.ok before you read result.report. false means the account is over a plan limit and Mite created nothing. A quota refusal does not throw. A network fault does. With the queue on, the message is queued and the error is still thrown.

mite.features

See Feature Requests.

features.list(): Promise<FeatureRequest[]>

Fetch the public board.

features.request(input: RequestFeatureInput): Promise<CreateFeatureRequestResponse>

Post a request to the board. author.email is required so the team can follow up. The SDK lowercases and trims it.

features.vote(id: string): Promise<VoteFeatureRequestResponse>

Toggle the current user's vote on a request.

features.myVotes(): Promise<string[]>

IDs of the requests the current user voted for.

mite.errors

See Error Tracking.

errors.capture(error: unknown, options?: CaptureOptions): void

Send an error your code caught. Never throws and never waits, so it is safe inside a catch block. Uncaught errors and unhandled rejections are sent for you.

errors.flush(): Promise<void>

Send captured errors now in place of the next batch.

mite.user

See Identity Management.

user.identify(id: string, options?: IdentifyOptions): Promise<IdentifyUserResponse>

Tie this device's activity to your user ID. Call it after sign-in. options takes email, name, isPaying, and traits.

user.reset(): Promise<void>

Forget the identified user and keep the anonymous ID. Call it on sign-out.

user.optOut(): Promise<void> and user.optIn(): Promise<void>

Turn anonymous-only mode on or off. Opting out clears the stored user ID.

User properties

PropertyTypeDescription
user.idstring | undefinedThe identified user, when there is one
user.anonymousIdstringThe anonymous identifier
user.isOptedOutbooleanWhether anonymous-only mode is on

All three are read-only.

whenIdentityReady(): Promise<void>

Resolves once persisted identity has been restored from storage. Await it before you read the user properties on startup. Every network method already awaits it.

mite.releases

See Releases.

releases.list(options?: GetReleasesOptions): Promise<Release[]>

Fetch published releases. platform and limit are optional. Omitted options are left out of the query string.

releases.lastSeen(): Promise<string | null>

The version the What's New sheet last showed. Resolves to null when nothing has been seen or storage fails.

releases.markSeen(version: string): Promise<void>

Record a version as seen. Logs a [Mite] warning on failure and does not throw.

mite.announcements

See Announcements.

announcements.list(options?: GetAnnouncementsOptions): Promise<Announcement[]>

Fetch the active announcements, newest first. platform and limit are optional.

announcements.markSeen(id: string): Promise<void>

Record an announcement as seen. Logs a [Mite] warning on failure and does not throw. The stored list keeps the 100 most recent IDs.

announcements.seenIds(): Promise<string[]>

IDs of announcements this device has dismissed. Resolves to an empty list when nothing has been seen or storage fails.

announcements.clearSeen(): Promise<void>

Forget every seen announcement, so active announcements show again.

mite.storeReview

See Store Review Prompt.

storeReview.isAvailable(): Promise<boolean>

Whether the native review dialog can be requested. false when expo-store-review is missing.

storeReview.request(): Promise<boolean>

Request the native review dialog. Resolves to true when the request was made and false when it is unavailable. Never throws.

Offline queue

See Offline Queue.

flushOfflineQueue(): Promise<void>

Retry queued requests now. Never rejects. Concurrent calls share one flush.

pendingRequestCount: number

Number of requests waiting in the queue. 0 when the queue is disabled.

Deprecated 1.0 methods

Every 1.0 method still works. Each one is marked @deprecated, so your editor strikes it through and names the replacement. They are removed in 2.0.

1.0Now
submitBug({ title, description })feedback.send({ type: 'bug', message })
createFeatureRequest({ title, author_email })features.request({ title, author: { email } })
voteFeatureRequest({ feature_request_id })features.vote(id)
getFeatureRequests()features.list()
getFeatureRequestVotes()features.myVotes()
recordError(e), captureError(e)errors.capture(e)
flushErrors()errors.flush()
identify({ user_identifier, ... })user.identify(id, { ... })
logout()user.reset()
setIdentificationOptOut(true) / (false)user.optOut() / user.optIn()
anonymousIduser.anonymousId
userIdentifieruser.id
isIdentificationOptedOutuser.isOptedOut
getReleases()releases.list()
getLastSeenReleaseVersion()releases.lastSeen()
setLastSeenReleaseVersion(v)releases.markSeen(v)
getAnnouncements()announcements.list()
markAnnouncementSeen(id)announcements.markSeen(id)
getSeenAnnouncementIds()announcements.seenIds()
clearSeenAnnouncements()announcements.clearSeen()
isStoreReviewAvailable()storeReview.isAvailable()
requestStoreReview()storeReview.request()
<MiteProvider miteInstance={mite}><MiteProvider client={mite}>

submitBug keeps posting to /api/v1/bug-reports. feedback.send posts to /api/v1/feedback.

On this page