GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sdk-js/packages/epilot-sdk-v2/docs/presence.md at main · epilot-dev/sdk-js

Expand file tree

/

presence.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
209 lines (161 loc) · 4.14 KB
/

presence.md

Copy path

File metadata and controls

209 lines (161 loc) · 4.14 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Presence API

  • Base URL: https://presence.sls.epilot.io
  • Full API Docs: https://docs.epilot.io/api/presence

Usage

import { epilot } from '@epilot/sdk'

epilot.authorize(() => '<token>')
const { data } = await epilot.presence.heartbeatPresence(...)

Tree-shakeable import

import { getClient, authorize } from '@epilot/sdk/presence'

const presenceClient = getClient()
authorize(presenceClient, () => '<token>')
const { data } = await presenceClient.heartbeatPresence(...)

Operations

Presence

  • heartbeatPresence
  • leavePresence

Schemas

  • PresenceResourceType
  • PresenceState
  • SessionId
  • InstanceId
  • PresenceHeartbeat
  • PresenceLeave
  • PresenceMember
  • PresenceRoster
  • ErrorResponse

heartbeatPresence

Announces the caller on a resource, or refreshes their presence there, and returns everyone currently present.

POST /v1/presence/{resource_type}/{resource_id}/heartbeat

const { data } = await client.heartbeatPresence(
  {
    resource_type: 'example',
    resource_id: 'example',
    x-epilot-org-id: 'example',
  },
  {
    session_id: 'f7c1b2a0-3e4d-4c8e-9a1b-2d3e4f5a6b7c',
    instance_id: 'b1f0c2d3e4',
    state: 'editing'
  },
)
Response
{
  "members": [
    {
      "user_id": "123456",
      "user_org": "123",
      "state": "editing",
      "last_seen_at": "1970-01-01T00:00:00.000Z",
      "is_self": true
    }
  ],
  "ttl_seconds": 60,
  "heartbeat_interval_seconds": 20,
  "truncated": true
}

leavePresence

Removes the caller's session from the resource at once, for example when the tab closes or the user navigates away.

POST /v1/presence/{resource_type}/{resource_id}/leave

const { data } = await client.leavePresence(
  {
    resource_type: 'example',
    resource_id: 'example',
    x-epilot-org-id: 'example',
  },
  {
    session_id: 'f7c1b2a0-3e4d-4c8e-9a1b-2d3e4f5a6b7c',
    instance_id: 'b1f0c2d3e4'
  },
)

Schemas

PresenceResourceType

Kind of resource, and the permission needed to see who is present on it:

  • journey: entity:view on the journey. The resource ID is the journey's entity ID.
  • customer_portal: customer_portal:view on the portal
  • installer_portal: installer_portal:view on the portal
  • flow: `workflow:de
type PresenceResourceType = "journey" | "customer_portal" | "installer_portal" | "flow"

PresenceState

viewing: the resource is open. editing: it is open with unsaved changes.

type PresenceState = "viewing" | "editing"

SessionId

Generated by the client, one per browser tab. A user can be present with several tabs.

type SessionId = string

InstanceId

Optional. Generated by the client each time it starts sending heartbeats in a tab. A leave that carries it only takes effect while that instance sent the session's latest heartbeat, so a late leave from an earlier instance in the same tab cannot remove the session.

type InstanceId = string

PresenceHeartbeat

type PresenceHeartbeat = {
  session_id: string
  instance_id?: string
  state?: "viewing" | "editing"
}

PresenceLeave

type PresenceLeave = {
  session_id: string
  instance_id?: string
}

PresenceMember

A user present on the resource. Several tabs of the same user count as one member.

type PresenceMember = {
  user_id: string
  user_org?: string
  state: "viewing" | "editing"
  last_seen_at: string // date-time
  is_self: boolean
}

PresenceRoster

type PresenceRoster = {
  members: Array<{
    user_id: string
    user_org?: string
    state: "viewing" | "editing"
    last_seen_at: string // date-time
    is_self: boolean
  }>
  ttl_seconds: number
  heartbeat_interval_seconds: number
  truncated?: boolean
}

ErrorResponse

type ErrorResponse = {
  status?: number
  error?: string | object[]
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.