react-native-google-analytics-bridge
Advanced tools
Comparing version 5.2.2 to 5.3.0
{ | ||
"name": "react-native-google-analytics-bridge", | ||
"version": "5.2.2", | ||
"version": "5.3.0", | ||
"description": "React Native bridge for using native Google Analytics libraries on iOS and Android", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -39,2 +39,6 @@ GoogleAnalyticsBridge [![npm version](https://img.shields.io/npm/v/react-native-google-analytics-bridge.svg)](https://www.npmjs.com/package/react-native-google-analytics-bridge) [![Build Status](https://travis-ci.org/idehub/react-native-google-analytics-bridge.svg?branch=master)](https://travis-ci.org/idehub/react-native-google-analytics-bridge) | ||
**Important**: Does this library work with Expo? We have to sort of invert the question a bit, because it should be: does Expo work with other libraries? And the [answer is no](https://docs.expo.io/versions/latest/introduction/faq.html#what-is-the-difference-between-expo-and-react-native): | ||
>The most limiting thing about Expo is that you can’t add in your own native modules without `detach`ing and using ExpoKit. | ||
This includes using [`create-react-native-app`](https://github.com/react-community/create-react-native-app#what-are-the-limitations-of-create-react-native-app) which also makes use of Expo. | ||
## Usage | ||
@@ -58,2 +62,3 @@ ```javascript | ||
GoogleAnalyticsSettings.setDispatchInterval(30); | ||
// Setting `dryRun` to `true` lets you test tracking without sending data to GA | ||
GoogleAnalyticsSettings.setDryRun(true); | ||
@@ -287,3 +292,18 @@ | ||
``` | ||
### trackEventWithCustomDimensionAndMetricValues(category, action, optionalValues, dimensionIndexValueDict) | ||
* **category (required):** String, category of event | ||
* **action (required):** String, name of action | ||
* **optionalValues:** Object | ||
* **label:** String | ||
* **value:** Number | ||
* **dimensionIndexValueDict (required):** Dict of dimension index / values. | ||
* **metricIndexValueDict (required):** Dict of metric index / values. | ||
Tracks an event with one or more customDimensionValues and one or more customMetricValues. See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/customdimsmets) docs for more info. | ||
```javascript | ||
tracker.trackEventWithCustomDimensionAndMetricValues('testcategory', 'testaction', {label: 'v1.0.3', value: 22}, {'1':'premium', '5':'foo'}, , {'1': 3, '5': 4}); | ||
``` | ||
### setUser(userId) | ||
@@ -299,2 +319,22 @@ | ||
### setClient(clientId) | ||
* **clientId (required):** String, an **anonymous** identifier that complies with Google Analytic's client ID policy | ||
See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) for more info. | ||
```javascript | ||
tracker.setClient('35009a79-1a05-49d7-b876-2b884d0f825b'); | ||
``` | ||
### createNewSession(screenName) | ||
* **screenName (required):** String, the current screen which the session started on | ||
See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/sessions#manual) for more info. | ||
```javascript | ||
tracker.createNewSession('HomeScreen'); | ||
``` | ||
### allowIDFA(enabled) | ||
@@ -301,0 +341,0 @@ |
@@ -115,2 +115,6 @@ import { GoogleTagManager } from './GoogleTagManager'; | ||
} | ||
createNewSession(screenName) { | ||
this.tracker.createNewSession(screenName); | ||
} | ||
} |
@@ -58,3 +58,3 @@ import { GoogleAnalyticsBridge } from './NativeBridges'; | ||
} | ||
/** | ||
@@ -99,4 +99,15 @@ * Track the campaign from url | ||
} | ||
/** | ||
* Track an event that has occured with custom dimension and metric values. | ||
* @param {String} category The event category | ||
* @param {String} action The event action | ||
* @param {Object} optionalValues An object containing optional label and value | ||
* @param {Object} customDimensionValues An object containing custom dimension key/value pairs | ||
* @param {Object} customMetricValues An object containing custom metric key/value pairs | ||
*/ | ||
trackEventWithCustomDimensionAndMetricValues(category, action, optionalValues = {}, customDimensionValues, customMetricValues) { | ||
GoogleAnalyticsBridge.trackEventWithCustomDimensionAndMetricValues(this.id, category, action, optionalValues, customDimensionValues, customMetricValues); | ||
} | ||
/** | ||
/** | ||
* Track an event that has occured | ||
@@ -164,2 +175,10 @@ * @param {String} category The event category | ||
/** | ||
* Sets the current clientId for tracking. | ||
* @param {String} clientId The current userId | ||
*/ | ||
setClient(clientId) { | ||
GoogleAnalyticsBridge.setClient(this.id, clientId); | ||
} | ||
/** | ||
* Sets if IDFA (identifier for advertisers) collection should be enabled | ||
@@ -223,3 +242,3 @@ * @param {Boolean} enabled Defaults to true | ||
} | ||
/** | ||
@@ -232,2 +251,6 @@ * Sets the currency for tracking. | ||
} | ||
createNewSession(screenName) { | ||
GoogleAnalyticsBridge.createNewSession(this.id, screenName); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
35755672
44
1013
511