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.

23 lines (18 loc) 836 B
import type { CorePlugin } from '@segment/analytics-core' import type { DestinationMiddlewareFunction } from '../../plugins/middleware' import type { Analytics } from '../analytics' import type { Context } from '../context' export interface Plugin extends CorePlugin<Context, Analytics> {} export interface InternalPluginWithAddMiddleware extends Plugin { addMiddleware: (...fns: DestinationMiddlewareFunction[]) => void } export interface InternalDestinationPluginWithAddMiddleware extends InternalPluginWithAddMiddleware { type: 'destination' } export const isDestinationPluginWithAddMiddleware = ( plugin: Plugin ): plugin is InternalDestinationPluginWithAddMiddleware => { // FYI: segment's plugin does not currently have an 'addMiddleware' method return 'addMiddleware' in plugin && plugin.type === 'destination' }