import { Context } from '../../core/context' import { Plugin } from '../../core/plugin' import { logger } from '../logger' const anonymizeContext = (ctx: Context): Context => { const evtCtx = ctx.event.context! evtCtx.locale = '' evtCtx.timezone = '' evtCtx.userAgent = '' return ctx } // NB: Removing anonymous and user id happen in `normalize.ts` in Segment plugin // as it would otherwise be added back in there export const ddAnonymizeContextPlugin = (): Plugin => { return { name: 'Anonymous Context', type: 'enrichment', version: '0.0.1', isLoaded: () => true, load: () => { logger.debug('Enabling Anonymous Context plugin') return Promise.resolve() }, track: anonymizeContext, identify: anonymizeContext, page: anonymizeContext, group: anonymizeContext, alias: anonymizeContext, screen: anonymizeContext, } }