react-native-google-analytics-bridge
Advanced tools
Comparing version 2.0.0 to 2.1.0
31
index.js
@@ -35,2 +35,22 @@ "use strict"; | ||
/** | ||
* Track the current screen/view with custom dimension values | ||
* @param {String} screenName The name of the current screen | ||
* @param {Object} customDimensionValues An object containing custom dimension key/value pairs | ||
*/ | ||
static trackScreenViewWithCustomDimensionValues(screenName, customDimensionValues) { | ||
GoogleAnalyticsBridge.trackScreenViewWithCustomDimensionValues(getTrackerId(), screenName, customDimensionValues); | ||
} | ||
/** | ||
* Track an event that has occured with custom dimension 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 | ||
*/ | ||
static trackEventWithCustomDimensionValues(category, action, optionalValues = {}, customDimensionValues) { | ||
GoogleAnalyticsBridge.trackEventWithCustomDimensionValues(getTrackerId(), category, action, optionalValues, customDimensionValues); | ||
} | ||
/** | ||
* Track an event that has occured | ||
@@ -137,2 +157,11 @@ * @param {String} category The event category | ||
/** | ||
* Sets the trackers appName | ||
* The Bundle name is used by default | ||
* @param {String} appName | ||
*/ | ||
static setAppName(appName) { | ||
GoogleAnalyticsBridge.setAppName(getTrackerId(), appName); | ||
} | ||
/** | ||
* Sets new tracker ID for all subsequent static calls | ||
@@ -154,3 +183,3 @@ * @param {String} tracker ID | ||
} | ||
/** | ||
@@ -157,0 +186,0 @@ * Retrieves a boolean value with the given key from the opened container. |
{ | ||
"name": "react-native-google-analytics-bridge", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "React Native bridge for using native Google Analytics libraries on iOS and Android", | ||
"main": "./index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test yet!\" && exit 0" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -1,2 +0,2 @@ | ||
GoogleAnalyticsBridge ![npm version](https://img.shields.io/npm/v/react-native-google-analytics-bridge.svg) | ||
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) | ||
============= | ||
@@ -77,3 +77,3 @@ **Google Analytics Bridge** is built to provide an easy interface to the native Google Analytics libraries on both **iOS** and **Android**. | ||
... | ||
@Override | ||
@@ -90,2 +90,18 @@ protected List<ReactPackage> getPackages() { | ||
### Android build problem | ||
Some people have had problems being hit with `Unknown source file : com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzmu;` after installing this (or similar modules). | ||
This might be because you are using another module which also uses `play-services`, but targets a different version of `play-services`. In the `build.gradle`-file of this module, we target `com.google.android.gms:play-services-analytics:8.+`. In other words, we try to use the latest (8.x.x) version of `play-services`. | ||
If some other module is targetting a previous version, say 8.3.0, then adding the following to your (React Native-project) `build.gradle` may be helpful: | ||
```gradle | ||
compile("com.google.android.gms:play-services-analytics:8.3.0"){ | ||
force = true | ||
} | ||
``` | ||
That should force the app to compile the 8.3.0 version of the dependency my module uses. Obviously, this might not be a solution if several modules are depending on conflicting versions. | ||
I would recommend other module authors which also depend on `play-services` to target `8.+` instead of a specific minor version. | ||
## Google Analytics Javascript API | ||
@@ -102,3 +118,3 @@ | ||
``` | ||
### trackScreenView(screenName) | ||
@@ -218,2 +234,28 @@ | ||
### trackScreenViewWithCustomDimensionValues(screenName, dimensionIndexValueDict) | ||
* **screenName (required):** String, name of current screen | ||
* **dimensionIndexValueDict (required):** Dict of dimension index / values. | ||
Tracks a screen view with one or more customDimensionValues. See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/customdimsmets) docs for more info. | ||
```javascript | ||
GoogleAnalytics.trackScreenViewWithCustomDimensionValues('Home', {'1':'premium', '5':'foo'}); | ||
``` | ||
### trackEventWithCustomDimensionValues(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. | ||
Tracks an event with one or more customDimensionValues. See the [Google Analytics](https://developers.google.com/analytics/devguides/collection/ios/v3/customdimsmets) docs for more info. | ||
```javascript | ||
GoogleAnalytics.trackEventWithCustomDimensionValues('testcategory', 'testaction', {label: 'v1.0.3', value: 22}, {'1':'premium', '5':'foo'}); | ||
``` | ||
### setUser(userId) | ||
@@ -296,2 +338,13 @@ | ||
### setAppName(appName) | ||
* **appName (required):** String | ||
Overrides the app name logged in Google Analytics. The Bundle name is used by default. | ||
Note: This has to be set each time the App starts. | ||
```javascript | ||
GoogleAnalytics.setAppName('someAppName'); | ||
``` | ||
## Google Tag Manager Javascript API | ||
@@ -324,3 +377,3 @@ | ||
##### Returns: | ||
* **value:** String | ||
* **value:** String | ||
@@ -338,3 +391,3 @@ Retrieves a string with the given key from the opened container. | ||
##### Returns: | ||
* **value:** Boolean | ||
* **value:** Boolean | ||
@@ -352,3 +405,3 @@ Retrieves a boolean value with the given key from the opened container. | ||
##### Returns: | ||
* **value:** Number | ||
* **value:** Number | ||
@@ -364,3 +417,3 @@ Retrieves a number with the given key from the opened container. | ||
Read [this guide from Google](https://support.google.com/tagmanager/answer/6003007?hl=en) on how to do the above. | ||
This [blog post](http://www.cbrevik.com/google-tag-manager-and-ab-testing-with-react-native/) details how to do this. [This guide from Google](https://support.google.com/tagmanager/answer/6003007?hl=en) will also prove helpful (and is referenced in the aforementioned blog post). | ||
@@ -372,7 +425,7 @@ Then you can use our Google Tag Manager implementation to pull values out of the container, and track events in Google Analytics in order to complete "goals". | ||
## Google Analytics Logging | ||
There is a divergence in how the iOS and Android versions of the native library handles logging. | ||
There is a divergence in how the iOS and Android versions of the native library handles logging. | ||
[For Android](https://developers.google.com/analytics/devguides/collection/android/v4/advanced#logger) you can check the GA logs with your favorite terminal by using `adb logcat`. | ||
For iOS there is a logger in the [internal library](https://developers.google.com/analytics/devguides/collection/ios/v3/advanced#logger) that writes events to the XCode output window. | ||
For iOS there is a logger in the [internal library](https://developers.google.com/analytics/devguides/collection/ios/v3/advanced#logger) that writes events to the XCode output window. | ||
In order to control the `logLevel` you can add an item in your `Info.plist` with the key `GAILogLevel`. The value you use is a number which corresponds to your desired log-level: | ||
@@ -388,8 +441,8 @@ | ||
- [x] Support for A/B testing | ||
- [ ] Ecommerce: checkout process | ||
- [ ] Ecommerce: impressions | ||
- [ ] Campaigns | ||
- [x] Support for A/B testing | ||
- [x] dryRun flag | ||
- [x] Simple ecommerce | ||
- [x] Make the library more configureable | ||
- [x] Make the library more configureable |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
34406258
37
541
438