UNPKG

@segment/analytics-next

Version:

Analytics Next (aka Analytics 2.0) is the latest version of Segment’s JavaScript SDK - enabling you to send your data to any tool without having to learn, test, or use a new API every time.

21 lines (18 loc) 656 B
import { PlanEvent, TrackPlan } from '../core/events/interfaces' /** * Determines whether a track event is allowed to be sent based on the * user's tracking plan. * If the user does not have a tracking plan or the event is allowed based * on the tracking plan configuration, returns true. */ export function isPlanEventEnabled( plan: TrackPlan | undefined, planEvent: PlanEvent | undefined ): boolean { // Always prioritize the event's `enabled` status if (typeof planEvent?.enabled === 'boolean') { return planEvent.enabled } // Assume absence of a tracking plan means events are enabled return plan?.__default?.enabled ?? true }