import { Plugin , PluginType } from '@segment/analytics-react-native' ; import type { SegmentClient } from '../../../core/src/analytics' ; import { IdfaEvents } from './IdfaEvents' ; import type { IdfaData } from './types' ; import { AnalyticsReactNativePluginIdfa } from './AnalyticsReactNativePluginIdfa' ; const { getTrackingAuthorizationStatus } = AnalyticsReactNativePluginIdfa ; export class IdfaPlugin extends Plugin { type = PluginType . enrichment ; configure ( analytics ) { this . analytics = analytics ; this . getTrackingStatus ( ) ; IdfaEvents . addListener ( 'IDFAQuery' , ( res ) => { this . getTrackingStatus ( ) ; this . analytics ?. track ( 'IDFAQuery' , res ) ; } ) ; } getTrackingStatus ( ) { getTrackingAuthorizationStatus ( ) . then ( ( idfa ) => { this . analytics ?. context . set ( { device : { ... idfa } } ) ; } ) ; } }