-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDestPlugin.tsx
More file actions
30 lines (23 loc) · 794 Bytes
/
Copy pathDestPlugin.tsx
File metadata and controls
30 lines (23 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {
Plugin,
PluginType,
SegmentEvent
} from '@segment/analytics-react-native';
import { Platform, NativeModule } from 'react-native';
import UserAgent from 'react-native-user-agent';
//Adds user agent info to events before sent downstream
export class DestPlugin extends Plugin {
// Note that `type` is set as a class property
// If you do not set a type your plugin will be a `utility` plugin (see Plugin Types above)
type = PluginType.enrichment;
execute(event: SegmentEvent) {
console.log(UserAgent.getUserAgent());
if (Platform.OS !== 'android') {
return;
}
if (event.context !== undefined) {
event.context['userAgent'] = UserAgent.getUserAgent();
}
return event;
}
}