https://github.com/dittofeed/sdk-react-native
Dittofeed's react native sdk.
https://github.com/dittofeed/sdk-react-native
customer-engagement react-native
Last synced: 16 days ago
JSON representation
Dittofeed's react native sdk.
- Host: GitHub
- URL: https://github.com/dittofeed/sdk-react-native
- Owner: dittofeed
- License: mit
- Created: 2023-06-28T20:03:21.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-13T03:35:15.000Z (9 months ago)
- Last Synced: 2025-03-23T21:35:44.870Z (about 1 month ago)
- Topics: customer-engagement, react-native
- Language: TypeScript
- Homepage: https://www.dittofeed.com/
- Size: 3.84 MB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sdk-react-native
Dittofeed's react native sdk.
## Installation
```bash
# Using Yarn
yarn add @dittofeed/sdk-react-native# Using NPM
npm install --save @dittofeed/sdk-react-native
```## Usage
Dittofeed's react native sdk can be useful for sending Dittofeed events about your application and users.
```javascript
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { DittofeedSdk } from "@dittofeed/sdk-react-native";
import { useEffect } from "react";export default function App() {
useEffect(() => {
(async () => {
// Initialize the sdk with a writeKey, which is used to identify your
// workspace. This key can be found at
// https://dittofeed.com/dashboard/settings
await DittofeedSdk.init({
writeKey: "Basic abcdefg...",
});// Lets you tie a user to their actions and record traits about them. It
// includes a unique User ID and any optional traits you know about the
// user, like their email, name, and more.
DittofeedSdk.identify({
userId: "123",
traits: {
email: "[email protected]",
firstName: "John"
},
});// The track call is how you record any actions your users perform, along
// with any properties that describe the action.
DittofeedSdk.track({
userId: "123",
event: "Made Purchase",
properties: {
itemId: "abc",
},
});// Lets you record whenever a user sees a screen, the mobile equivalent of
// page, in your mobile app, along with any properties about the screen.
DittofeedSdk.screen({
userId: "123",
name: "Recipe Screen",
properties: {
recipeType: "Soup",
},
});// Ensures that asynchronously submitted events are flushed synchronously
// to Dittofeed's API.
await DittofeedSdk.flush();
})();
}, []);return (
My App
);
}const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
```