Redux Beacon
  • Introduction
  • Getting Started (Redux)
  • Getting Started (ngrx)
  • Examples & Recipes
  • Targets
    • GoogleAnalytics
    • GoogleAnalyticsGtag
    • GoogleTagManager
    • Segment
    • Amplitude
    • React Native: GoogleAnalytics
    • React Native: GoogleTagManager
    • React Native: Segment
  • API Reference
    • createMiddleware
    • createMetaReducer
    • EventDefinition
    • EventsMap
    • EventsMapper
  • Extensions
    • logger
    • OfflineWeb
    • OfflineReactNative
  • Utils
    • debounceEvent
    • ensure
    • combineEvents
  • FAQ
  • Migration Guide (v1 to v2)
  • Notes on Offline Events
Powered by GitBook
On this page
  • Setup
  • Usage
  • Event Definitions
  • pageView
  • event
  • alias
  • group
  • identify
  • reset
  1. Targets

React Native: Segment

PreviousReact Native: GoogleTagManagerNextAPI Reference

Last updated 5 years ago

Setup

  1. for Segment.io and create a Segment.io project for your mobile application.

  2. Add by following the guide.

  3. Install the target:

     npm install --save @redux-beacon/react-native-segment

Usage

import Segment from '@redux-beacon/react-native-segment';
import SegmentAnalytics from '@segment/analytics-react-native';

// Create or import an events map.
// See "getting started" pages for instructions.

SegmentAnalytics.setup(writeKey, options);
const Analytics = SegmentAnalytics;

const segment = Segment();
const segmentMiddleware = createMiddleware(eventsMap, segment);

Event Definitions

pageView

Docs:

import { trackPageView } from '@redux-beacon/segment';

const pageView = trackPageView((action, prevState, nextState) => {
  return {
    name: /* (optional) */
    properties: /* (optional) */
  };
});

event

Docs:

import { trackEvent } from '@redux-beacon/react-native-segment';

const event = trackEvent((action, prevState, nextState) => {
  return {
    name: /* fill me in */,
    properties: /* (optional) */,
  };
});

alias

Docs:

import { setAlias } from '@redux-beacon/react-native-segment';

const alias = setAlias((action, prevState, nextState) => {
  return {
    userId: /* fill me in */,
  };
});

group

Docs:

import { setGroup } from '@redux-beacon/react-native-segment';

const group = setGroup((action, prevState, nextState) => {
  return {
    groupId: /* fill me in */,
    traits: /* (optional) */,
  };
});

identify

Docs:

import { identifyUser } from '@redux-beacon/react-native-segment';

const user = identifyUser((action, prevState, nextState) => {
  return {
    userId: /* fill me in */,
    traits: /* (optional) */,
  };
});

reset

Docs:

import { reset } from '@redux-beacon/react-native-segment';

const resetRequest = reset();

Don't see your event listed? Please submit a pull request to the with the missing event. Use the source of the existing event-helpers to guide your work. If you need any support feel free to make the pull request with all you're able to do. We can fill in the gaps from there.

Redux Beacon repository
https://segment.com/docs/sources/mobile/react-native/#screen
https://segment.com/docs/sources/mobile/react-native/#track
https://segment.com/docs/sources/mobile/react-native/#alias
https://segment.com/docs/sources/mobile/react-native/#group
https://segment.com/docs/sources/mobile/react-native/#identify
https://segment.com/docs/sources/mobile/react-native/#reset
Sign up
React Native Segment
Setup
Usage
Event Definitions
pageView
event
alias
group
identify