Skip to main content

checkEventExists

Upgather Analytics


Upgather Analytics / checkEventExists

Function: checkEventExists()

checkEventExists(client, eventId): Promise<boolean>

Check if an event ID exists in the event registry.

Parameters

client

ApiClient

The API client to use for the request

eventId

string

The event ID to check

Returns

Promise<boolean>

Promise resolving to true if the event exists, false otherwise

Remarks

This function checks if an event ID exists in the event registry by making a request to the events endpoint. It returns true if the event exists, false if it doesn't exist (404 response), and throws an error for any other error response.

This function is used by the SdkEventValidator to validate event IDs before tracking.

Example

import { apiClientFactory, checkEventExists } from '@upgather/analytics';

const apiClient = apiClientFactory({ validationEndpoint: 'https://ems.prod.upgather.com/api' });
const exists = await checkEventExists(apiClient, 'homepage-visit');
console.log(`Event exists: ${exists}`);