/** * Samelogic SDK contains the client that is required to run your Samelogic Projects in your product. * * The main entry point to samelogic.js is the {@link @samelogic/samelogic-js#Samelogic} class, which when instantiated with an appId, * will return an object that is ready to use. This object requires an init() method to be called for the client to start. * * @packageDocumentation */ /** * The shape of the payload for the ElementClick and ElementMouseOver events. * @public */ export declare interface ElementEventProps extends TriggerEventProps { event: 'ElementClick' | 'ElementMouseOver'; /** * The CSS Selector of the element that was clicked or hovered over. */ cssSelector: string; preventDefault?: boolean; /** * If the element had a default behavior, it will be delayed until the workflow is completed. */ delayDefaultBehavior?: boolean; } /** * The configuration of the source of identity variables * * @public */ export declare interface IdentityPropertySource { name: string; variable: string; } /** * * @public */ export declare interface IdentitySourceConfig { identity?: string; email?: string; properties?: IdentityPropertySource[]; } /** * Taken from: https://stackoverflow.com/a/53215240/400861 * * @internal */ export declare type LogicalOperator = 'AND' | 'OR'; /** * The options to pass into {@link @samelogic/samelogic-js#Samelogic} initialization. * * @public */ export declare interface Options { /** * The `ENV_ID` provided, which you have received for creating a project on the Samelogic platform. */ envId: string; baseUrl?: string; /** * The list of currently **active** workflows. Worklows must be published to be active. */ workflows: WorkflowConfig[]; user?: SLUser; } /** * The shape of the payload for the PageView event. * @public */ export declare interface PageEventProps extends TriggerEventProps { event: 'PageView'; /** * A URL that can contain wildcards. * @remarks * For example, `https://samelogic.com/*\/docs` matches all URLs that contain `samelogic.com` and end with `/docs`. */ urlPattern: string; } /** * Samelogic Client SDK API. The Samelogic class handles the creation of a client instance. * * @public */ declare class Samelogic { private readonly options; private readonly config; private readonly logger; private readonly sessionManager; private readonly projectsRepository; private readonly remotePackageRepository; private readonly packageMemoryCache; /** * The current version of the library */ readonly version: string; private workflowManagers; /** * Samelogic Client SDK API - instance constructor. The Samelogic class handles the creation and configuration * of a client instance. * * @param options - the configuration options for the client instance. * * @public */ constructor(options: Options); /** * Initializes the client instance. This will start the client to begin listening for triggers and executing worklows. * * @public */ init(): Promise; private initSession; private hotLoadPackages; /** * Creates an instance of the client and then initializes it. This is a static method and is a convenience method * for initializing through a single API call from the window object. This allows tools like Google Tag Manager * to initialize the client instance without the `new` keyword being available. * * @public */ static init(options: Options): Promise; /** * This method is used to uniquelly identify the user for maintaining an association across sessions. * * @param identity - this is a unique identifier for the user, such as an email address or a user ID. * @param properties - this is a set of key/value pairs that can be used to enrich the user's profile. */ identify(identity: string, properties?: Record): void; /** * This method is used to reset the user session and identity. This can be used when the user logs out. */ resetIdentity(): void; } export { Samelogic } export default Samelogic; /** * A Samelogic user object. * * Maps 1:1 to LaunchDarkly user object. * https://launchdarkly.github.io/node-client-sdk/interfaces/_launchdarkly_node_client_sdk_.lduser.html * * @public */ export declare interface SLUser { key?: string; email?: string; name?: string; } /** * * @public */ export declare interface StepConfig { /** * Can be the url of the package */ uses: string; name: string; props?: Record; needs?: StepNeeds; } /** * * @public */ export declare interface StepNeeds { /** * name of the trigger or step */ name: string; /** * if the dependency is a step, it should have an event */ event?: string; } /** * The configuration of a trigger. * * @public */ export declare type TriggerConfig = TriggerEvents; /** * * * @internal */ export declare type TriggerEventConditions = TriggerEvents | LogicalOperator; /** * The properties of an event. * @public */ export declare interface TriggerEventProps { /** * The identifier of the trigger event for referencing event data published from the event. */ id?: string; /** * The event that determines what the rest of properties of this object should be. */ event: TriggerEventType; } /** * The different trigger events that are supported. * The properties of this object is dependent on the {@link @samelogic/samelogic-js#TriggerEventProps.event} property. * * @public * * @remarks * * When `event` is `ElementClick` or `ElementMouseOver`, the following properties are required:`{@link @samelogic/samelogic-js#ElementEventProps.cssSelector}` * * When `event` is `PageView`, the following properties are required:`{@link @samelogic/samelogic-js#PageEventProps.urlPattern}` * * See the references of each type for more details. * */ export declare type TriggerEvents = ElementEventProps | PageEventProps; /** * The type of event. This will determine what properties of {@link @samelogic/samelogic-js#TriggerEvents} are required. * * @public * * @remarks * * `ElementClick` refers to the click event on a DOM element, see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event}. * * `ElementMouseOver` refers to the mouseover event on a DOM element, see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event}. * note: This mouseover event will fire and bubble the event up the DOM, see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseenter_event} * * `PageView` matching occurs when the page is loaded or the url has changed. */ export declare type TriggerEventType = 'ElementClick' | 'ElementMouseOver' | 'PageView'; /** * This is the configuration of a workflow. Workflows are made up of steps and triggers. * Triggers are events used to trigger the execution of steps. * * @public * * @remarks * When the Samelogic SDK is initialized, the workflow configuration is loaded and executed immediately. * This means that the trigger will be setup to listen for the configured events. When all of the event conditions are met, * the workflow will execute the configured steps. */ export declare interface WorkflowConfig { /** * The name given to the workflow. */ name: string; /** * Optional for identification */ id?: string; /** * Endpoint where all triggers and events will be logged to */ logEndpoint?: string; /** * A list of events or conditions that needs to be met to trigger the execution of the steps. * If this is not specified, the trigger will be executed immediately. The order of the trigger is not * taken into account. */ triggers?: TriggerConfig[]; /** * The configuration of all the steps to be executed when the trigger is fired. */ steps: StepConfig[]; identitySource?: IdentitySourceConfig; } export { }