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C,eAAe,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\nimport { Platform } from 'react-native';\n\nimport ExponentSegment from './ExponentSegment';\n\nexport type InitializeOptions = {\n androidWriteKey?: string;\n iosWriteKey?: string;\n};\n\nexport type CommonOptions = { [key: string]: any } | null;\n\nexport function initialize(options: InitializeOptions): void {\n if (!ExponentSegment.initialize) {\n throw new UnavailabilityError('expo-analytics-segment', 'initialize');\n }\n const platformWriteKey = Platform.select({\n ios: options.iosWriteKey,\n android: options.androidWriteKey,\n });\n if (platformWriteKey) {\n ExponentSegment.initialize(platformWriteKey);\n } else {\n throw new Error('You must provide a platform-specific write key to initialize Segment.');\n }\n}\n\nexport function identify(userId: string): void {\n if (!ExponentSegment.identify) {\n throw new UnavailabilityError('expo-analytics-segment', 'identify');\n }\n ExponentSegment.identify(userId);\n}\n\nexport function identifyWithTraits(\n userId: string,\n traits: { [key: string]: any },\n options: CommonOptions = null\n): void {\n if (!ExponentSegment.identifyWithTraits) {\n throw new UnavailabilityError('expo-analytics-segment', 'identifyWithTraits');\n }\n ExponentSegment.identifyWithTraits(userId, traits, options);\n}\n\nexport function group(groupId: string): void {\n if (!ExponentSegment.group) {\n throw new UnavailabilityError('expo-analytics-segment', 'group');\n }\n ExponentSegment.group(groupId);\n}\n\nexport function groupWithTraits(\n groupId: string,\n traits: { [key: string]: any },\n options: CommonOptions = null\n): void {\n if (!ExponentSegment.groupWithTraits) {\n throw new UnavailabilityError('expo-analytics-segment', 'groupWithTraits');\n }\n ExponentSegment.groupWithTraits(groupId, traits, options);\n}\n\nexport async function alias(newId: string, options: CommonOptions = null): Promise<boolean> {\n if (!ExponentSegment.alias) {\n throw new UnavailabilityError('expo-analytics-segment', 'alias');\n }\n return await ExponentSegment.alias(newId, options);\n}\n\nexport function reset(): void {\n if (!ExponentSegment.reset) {\n throw new UnavailabilityError('expo-analytics-segment', 'reset');\n }\n ExponentSegment.reset();\n}\n\nexport function track(event: string): void {\n if (!ExponentSegment.track) {\n throw new UnavailabilityError('expo-analytics-segment', 'track');\n }\n ExponentSegment.track(event);\n}\n\nexport function trackWithProperties(\n event: string,\n properties: { [key: string]: any },\n options: CommonOptions = null\n): void {\n if (!ExponentSegment.trackWithProperties) {\n throw new UnavailabilityError('expo-analytics-segment', 'trackWithProperties');\n }\n ExponentSegment.trackWithProperties(event, properties, options);\n}\n\nexport function screen(screenName: string): void {\n if (!ExponentSegment.screen) {\n throw new UnavailabilityError('expo-analytics-segment', 'screen');\n }\n ExponentSegment.screen(screenName);\n}\n\nexport function screenWithProperties(\n event: string,\n properties: { [key: string]: any },\n options: CommonOptions = null\n): void {\n if (!ExponentSegment.screenWithProperties) {\n throw new UnavailabilityError('expo-analytics-segment', 'screenWithProperties');\n }\n ExponentSegment.screenWithProperties(event, properties, options);\n}\n\nexport function flush(): void {\n if (!ExponentSegment.flush) {\n throw new UnavailabilityError('expo-analytics-segment', 'flush');\n }\n ExponentSegment.flush();\n}\n\nexport async function getEnabledAsync(): Promise<boolean> {\n if (!ExponentSegment.getEnabledAsync) {\n throw new UnavailabilityError('expo-analytics-segment', 'getEnabledAsync');\n }\n const isEnabledNumber = await ExponentSegment.getEnabledAsync();\n return !!isEnabledNumber;\n}\n\nexport async function setEnabledAsync(enabled: boolean): Promise<void> {\n if (!ExponentSegment.setEnabledAsync) {\n throw new UnavailabilityError('expo-analytics-segment', 'setEnabledAsync');\n }\n await ExponentSegment.setEnabledAsync(enabled);\n}\n"]}
\No newline at end of file