Class Visitor

Summary

Create an instance of Visitor class with a given id and optional attributes and session credentials.

Usage

await new Visitor(topia, id, urlSlug, { attributes: { moveTo: { x: 0, y: 0 } } });

Hierarchy

Implements

Constructors

Properties

credentials: undefined | InteractiveCredentials
dataObject?: null | object
id: number
jwt?: string
profile?: Record<string, any>
profileId?: null | string
requestOptions: object
topia: Topia
urlSlug: string
user?: User

Accessors

  • get adminWorlds(): {
        [key: string]: World;
    }
  • Returns {
        [key: string]: World;
    }

  • get assets(): {
        [key: string]: Asset;
    }
  • Returns {
        [key: string]: Asset;
    }

  • get scenes(): {
        [key: string]: Scene;
    }
  • Returns {
        [key: string]: Scene;
    }

  • get worlds(): {
        [key: string]: World;
    }
  • Returns {
        [key: string]: World;
    }

Methods

  • Summary

    Verify user has valid interactive credentials

    Usage

    await user.checkInteractiveCredentials();
    

    Returns Promise<void | ResponseType>

  • Summary

    Close an iframe for a visitor currently in a world.

    Usage

    await visitor.closeIframe("droppedAssetId");
    

    Parameters

    • droppedAssetId: string

    Returns Promise<void | ResponseType>

  • Parameters

    • __namedParameters: {
          error?: unknown;
          message?: string;
          params?: object;
          sdkMethod?: string;
      }
      • Optional error?: unknown
      • Optional message?: string
      • Optional params?: object
      • Optional sdkMethod?: string

    Returns {
        data: {};
        message: string;
        method: string;
        params: object;
        sdkMethod: undefined | string;
        stack: string;
        stackTrace: Error;
        status: number;
        success: boolean;
        url: string;
    }

    • data: {}
      • message: string
      • method: string
      • params: object
      • sdkMethod: undefined | string
      • stack: string
      • stackTrace: Error
      • status: number
      • success: boolean
      • url: string
    • Summary

      Retrieves all worlds a user with matching API Key is an admin in, creates a new World object for each, and creates new map of Worlds accessible via user.adminWorlds.

      Usage

      await user.fetchAdminWorldsByKey();
      const adminWorlds = user.adminWorlds;

      Returns Promise<void | ResponseType>

    • Summary

      Returns all assets owned by User when an email address is provided.

      Usage

      await user.fetchAssets();
      const userAssets = user.assets;

      Returns Promise<void | ResponseType>

    • Summary

      Retrieves ids of all dropped assets in all worlds with a matching interactivePublicKey.

      Usage

      await user.fetchInteractiveWorldsByKey("interactivePublicKeyExample");
      const interactiveWorlds = user.interactiveWorlds;

      Parameters

      • interactivePublicKey: string

      Returns Promise<object | ResponseType>

    • Summary

      Returns all platform assets.

      Usage

      const assets = await user.fetchPlatformAssets();
      

      Returns Promise<object | ResponseType>

    • Summary

      Returns all scenes owned by User.

      Usage

      await user.fetchScenes();
      const userScenes = user.scenes;

      Returns Promise<void | ResponseType>

    • Summary

      Get a single visitor from a world

      Usage

      await visitor.fetchVisitor();
      

      Result

      Returns details for a visitor in a world by id and urlSlug

      Returns Promise<void | ResponseType>

    • Summary

      Retrieves all worlds owned by user with matching API Key, creates a new World object for each, and creates new map of Worlds accessible via user.worlds.

      Usage

      await user.fetchWorldsByKey();
      const userWorlds = user.worlds;

      Result

      { urlSlug: new World({ apiKey, worldArgs, urlSlug }) }
      

      Returns Promise<void | ResponseType>

    • Summary

      Display a message via a toast to a visitor currently in a world.

      Usage

      await visitor.fireToast({
      groupId: "custom-message",
      title: "Hello World",
      text: "Thank you for participating!",
      });

      Parameters

      Returns Promise<void | ResponseType>

    • Summary

      Get all particles available

      Usage

      await visitor.getAllParticles();
      

      Returns Promise<object | ResponseType>

    • Summary

      Grant expression to a visitor by id or name.

      Usage

      await visitor.grantExpression({ name: "Eyes" });
      

      Parameters

      • __namedParameters: {
            id?: string;
            name?: string;
        }
        • Optional id?: string
        • Optional name?: string

      Returns Promise<object | ResponseType>

    • Summary

      Increments a specific value in the data object for a visitor by the amount specified. Must have valid interactive credentials from a visitor in the world.

      Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id

      Usage

      await visitor.incrementDataObjectValue(
      "path": "key",
      "amount": 1,
      );

      Parameters

      • path: string
      • amount: number
      • options: {
            analytics?: string[];
            lock?: {
                lockId: string;
                releaseLock?: boolean;
            };
        } = {}
        • Optional analytics?: string[]
        • Optional lock?: {
              lockId: string;
              releaseLock?: boolean;
          }
          • lockId: string
          • Optional releaseLock?: boolean

      Returns Promise<void | ResponseType>

    • Summary

      Teleport or walk a visitor currently in a world to a single set of coordinates.

      Usage

      await visitor.moveVisitor({
      shouldTeleportVisitor: true,
      x: 100,
      y: 100,
      });

      Result

      Updates each Visitor instance and world.visitors map.

      Parameters

      Returns Promise<void | ResponseType>

    • Summary

      Open an iframe in a drawer or modal for a visitor currently in a world.

      Usage

      await visitor.openIframe({
      droppedAssetId: "droppedAssetId",
      link: "https://topia.io",
      shouldOpenInDrawer: true,
      title: "Hello World",
      });

      Parameters

      Returns Promise<void | ResponseType>

    • Summary

      Reload an iframe for a visitor currently in a world.

      Usage

      await visitor.reloadIframe("droppedAssetId");
      

      Parameters

      • droppedAssetId: string

      Returns Promise<void | ResponseType>

    • Summary

      Sets the data object for a visitor.

      Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id

      Usage

      await visitor.setDataObject({
      "exampleKey": "exampleValue",
      });

      Parameters

      • dataObject: undefined | null | object
      • options: {
            analytics?: string[];
            lock?: {
                lockId: string;
                releaseLock?: boolean;
            };
        } = {}
        • Optional analytics?: string[]
        • Optional lock?: {
              lockId: string;
              releaseLock?: boolean;
          }
          • lockId: string
          • Optional releaseLock?: boolean

      Returns Promise<void | ResponseType>

    • Returns AxiosInstance

    • Summary

      Trigger a particle effect on a visitor

      Usage

      await visitor.triggerParticle({ name: "Flame" });
      

      Parameters

      • __namedParameters: {
            duration?: number;
            id?: string;
            name?: string;
        }
        • Optional duration?: number
        • Optional id?: string
        • Optional name?: string

      Returns Promise<object | ResponseType>

    • Summary

      Mute and turn video off for a visitor currently in a world.

      Usage

      await visitor.turnAVOff();
      

      Returns Promise<void | ResponseType>

    • Summary

      Updates the data object for a visitor.

      Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id

      Usage

      await visitor.updateDataObject({
      "exampleKey": "exampleValue",
      });

      Parameters

      • dataObject: object
      • options: {
            analytics?: string[];
            lock?: {
                lockId: string;
                releaseLock?: boolean;
            };
        } = {}
        • Optional analytics?: string[]
        • Optional lock?: {
              lockId: string;
              releaseLock?: boolean;
          }
          • lockId: string
          • Optional releaseLock?: boolean

      Returns Promise<void | ResponseType>