Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Latest
interface IVisitor
import { type IVisitor } from "https://deno.land/x/flagship_io_js_sdk@4.0.1/visitor/IVisitor.ts";

The Visitor class represents a unique user within your application. It aids in managing the visitor's data and fetching the corresponding flags for the visitor from the Flagship platform .

Properties

visitorId: string

The unique visitor identifier.

readonly
anonymousId: string | null

The anonymous visitor identifier.

readonly
context: Record<string, primitive>

The visitor context.

readonly
fetchStatus: FetchFlagsStatus

The fetch status of the flags.

readonly
config: IFlagshipConfig

The Flagship configuration.

readonly
hasConsented: boolean

Returns true or false if the visitor has consented for protected data usage.

Methods

setConsent(hasConsented: boolean): void

Sets whether the visitor has consented for protected data usage.

updateContext(context: Record<string, primitive>): void

Updates the visitor context values, matching the given keys, used for targeting. A new context value associated with this key will be created if there is no previous matching value.

updateContext(key: string, value: primitive): void

Updates the visitor context value for the given key, used for targeting. A new context value associated with this key will be created if there is no previous matching value.

clearContext(): void

Clears the actual visitor context.

getFlag(key: string): IFSFlag

Returns a Flag object by its key. If no flag matches the given key, an empty flag will be returned.

getFlags(): IFSFlagCollection

Returns a collection of all flags fetched for the visitor.

fetchFlags(): Promise<void>

Invokes the decision API or refers to the bucketing file to refresh all campaign flags based on the visitor's context.

sendHit(hit: HitAbstract | IHit): Promise<void>

Sends a Hit to Flagship servers for reporting.

sendHits(hits: Array<HitAbstract> | Array<IHit>): Promise<void>

Sends Hits to Flagship servers for reporting.

authenticate(visitorId: string): void

Authenticates an anonymous visitor.

unauthenticate(): void

Changes an authenticated visitor to an anonymous visitor.