-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,45 @@ This library is based on its node counterpart, [analytics-node](https://github.c | |
## Installation | ||
|
||
```bash | ||
$ npm install analytics-react-native | ||
npm install analytics-react-native | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
import Analytics from analytics-react-native; | ||
|
||
const analytics = new Analytics(YOUR_WRITE_KEY); | ||
|
||
analytics.identify({ | ||
userId: user.id, | ||
traits: { | ||
name: 'John', | ||
lastname: 'Doe', | ||
email: '[email protected]', | ||
plan: 'Enterprise', | ||
} | ||
); | ||
|
||
analytics.track({ | ||
userId: user.id, | ||
event: 'Item Purchased', | ||
properties: { | ||
revenue: 39.95, | ||
shippingMethod: '2-day' | ||
} | ||
}); | ||
``` | ||
### Configuration | ||
The second argument to the Analytics constructor is an optional object to configure the module. | ||
```javascript | ||
const analytics = new Analytics(YOUR_WRITE_KEY, { | ||
host: 'http://localhost/', // Host where reports will be send. Useful for debug. | ||
flushAt: 20, // The number of messages to enqueue before flushing. | ||
flushAfter: 10000 // The number of milliseconds to wait before flushing the queue automatically. | ||
}); | ||
``` | ||
## Documentation | ||
|