Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { AmplitudeSessionPlugin } from '@segment/analytics-react-native-plugin-a
const segmentClient = createClient({
writeKey: 'WRITE KEY',
trackAppLifecycleEvents: true,
collectDeviceId: true,
});

const LoggerPlugin = new Logger();
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ export class SegmentClient {
* Application Opened - the previously detected version is same as the current version
*/
private async checkInstalledVersion() {
const context = await getContext(undefined);
const context = await getContext(undefined, this.config);

const previousContext = this.store.context.get();

this.store.context.set(context);
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import type {
UserTraits,
} from './types';

interface GetContextConfig {
collectDeviceId?: boolean;
}
export const getContext = async (
userTraits: UserTraits = {}
userTraits: UserTraits = {},
config: GetContextConfig = {}
): Promise<Context> => {
const { AnalyticsReactNative } = NativeModules;

Expand All @@ -31,7 +35,7 @@ export const getContext = async (
deviceId,
deviceType,
screenDensity,
}: NativeContextInfo = await AnalyticsReactNative.getContextInfo({});
}: NativeContextInfo = await AnalyticsReactNative.getContextInfo(config);

const device: ContextDevice = {
id: deviceId,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export type Config = {
maxEventsToRetry?: number;
defaultSettings?: SegmentAPISettings;
autoAddSegmentDestination?: boolean;
collectDeviceId?: boolean;
};

export type ClientMethods = {
Expand Down