Get Started

Prev Next

Add the Mapp Fashion React Native SDK to your app and initialize it. The steps apply to SDK version 1.0.0.

Prerequisites

  • Your app meets the requirements of the SDK.

  • You have the host, the namespace ID and the client ID of your Mapp Fashion account. Mapp provides them during onboarding.


Procedure

Step 1: Install the SDK

Install the SDK together with its peer dependencies and the secure storage for the login data. Bare React Native apps use React Native Keychain, Expo apps use Expo SecureStore via the Expo storage plugin of the SDK.

npx expo install mapp-fashion-react-native-sdk mapp-fashion-react-native-sdk-expo expo-secure-store @react-native-async-storage/async-storage react-native-get-random-values
npm install mapp-fashion-react-native-sdk react-native-keychain @react-native-async-storage/async-storage@^2.0.0 react-native-get-random-values@^2.0.0

Do not install @snowplow/react-native-tracker in your app. The SDK includes the Snowplow tracker itself.

Rebuild the native app: run expo prebuild or pod install, then create a new build.

Step 2: Add the provider

Wrap your app in DressipiProvider. The provider handles authentication, consent and tracking for all components inside it. Mount it once and keep it mounted for the lifetime of the app. In Expo apps, also pass the Expo storage adapter.

import { DressipiProvider } from 'mapp-fashion-react-native-sdk';
import { SecureStoreAdapter } from 'mapp-fashion-react-native-sdk-expo';

const storage = new SecureStoreAdapter();

export default function App() {
  return (
    <DressipiProvider
      namespaceId="your-namespace-id"
      domain="fashion.example.com"
      clientId="your-client-id"
      appVersion="1.4.0"
      appBuild="42"
      storage={storage}
    >
      <YourApp />
    </DressipiProvider>
  );
}
import { DressipiProvider } from 'mapp-fashion-react-native-sdk';

export default function App() {
  return (
    <DressipiProvider
      namespaceId="your-namespace-id"
      domain="fashion.example.com"
      clientId="your-client-id"
      appVersion="1.4.0"
      appBuild="42"
    >
      <YourApp />
    </DressipiProvider>
  );
}

Prop

Type

Required

Description

namespaceId

string

Yes

Namespace ID of your Mapp Fashion account

domain

string

Yes

Mapp Fashion host of your account, without https://

clientId

string

Yes

Client ID for the Mapp Fashion API

appVersion

string

No

Version of your app, for example from expo-application. The SDK does not read it automatically. Without it, the tracking data contains no app version.

appBuild

string

No

Build number of your app. Without it, the tracking data contains no build number.

storage

SecureStorageAdapter

No

Secure storage for the login data and the consent. Default: React Native Keychain. In Expo apps, pass a SecureStoreAdapter from mapp-fashion-react-native-sdk-expo.

defaultConsent

boolean

No

Consent value used as long as the user has not decided. See step 3.

enableLogging

boolean

No

Writes debug information to the console. Default: false

logTokens

boolean

No

Includes tokens in the debug output. Only takes effect with enableLogging. Default: false

The SDK authenticates and sends tracking data only after the user has consented. Read and store the choice of the user with the useCompliance hook:

import { useCompliance } from 'mapp-fashion-react-native-sdk';

function PrivacySettings() {
  const { hasConsented, setConsent, isLoading } = useCompliance();

  // hasConsented: true, false, or null if the user has not decided yet
  // setConsent(true) or setConsent(false) stores the choice
}

Consent

Recommendations

Tracking

Not decided (null)

Not requested until the user decides

Not sent. Events are kept in memory and sent once the user consents.

Given (true)

Requested with authentication

Sent

Rejected (false)

Requested anonymously

Not sent. Events are kept in memory and sent if the user consents later.

The choice is stored on the device and kept across app restarts. As long as the user has not decided, the SDK uses defaultConsent. If you do not set defaultConsent, your app shows no recommendations until the user has decided. Events kept in memory are lost if the app is closed before the user consents.


Result

Once the user has consented, the SDK authenticates and sends events to Mapp Fashion. To check this in a development build, set enableLogging to true and filter the console for [Fashion HTTP] or [Fashion Tracking]. The log shows OAuth, recommendation and collector requests with status and duration, and whether events are queued or dispatched. If the network user ID is missing, the log shows a missing_network_user_id warning.

Warning

Do not enable logging in production builds. The log can contain request data and user identifiers.