mixpanel-react-native
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -12,3 +12,3 @@ /** | ||
const mixpanel = await Mixpanel.init("token"); | ||
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", false, {"$lib_version": "1.0.2", "mp_lib": "react-native"}); | ||
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", false, {"$lib_version": "1.1.0", "mp_lib": "react-native"}); | ||
}); | ||
@@ -15,0 +15,0 @@ |
103
index.js
@@ -20,2 +20,3 @@ "use strict"; | ||
INVALID_OBJECT: " is not a valid json object", | ||
INVALID_STRING: " is not a valid string", | ||
REQUIRED_DOUBLE: " is not a valid number" | ||
@@ -26,4 +27,2 @@ } | ||
TOKEN: "token", | ||
DISTINCT_ID_IN_OPTIONS: "distinctId in the options parameter", | ||
PROPERTIES_IN_OPTIONS: "properties in the options parameter", | ||
DISTINCT_ID: "distinctId", | ||
@@ -33,4 +32,2 @@ ALIAS: "alias", | ||
GROUP_KEY: "groupKey", | ||
GROUP_ID: "groupID", | ||
GROUP_IDs: "groupIDs", | ||
PROPERTIES: "properties", | ||
@@ -64,4 +61,4 @@ PROPERTY_NAME: "propertyName", | ||
* @param {string} token your project token. | ||
* @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See | ||
* optOutTracking() | ||
* @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See optOutTracking() | ||
* | ||
*/ | ||
@@ -109,3 +106,3 @@ static async init(token, optOutTrackingDefault = DEFAULT_OPT_OUT) { | ||
* | ||
* @return {boolean} true if user has opted out from tracking. Defaults to false. | ||
* @return {Promise<boolean>} true if user has opted out from tracking. Defaults to false. | ||
*/ | ||
@@ -123,3 +120,3 @@ hasOptedOutTracking() { | ||
optInTracking() { | ||
return MixpanelReactNative.optInTracking(this.token); | ||
MixpanelReactNative.optInTracking(this.token); | ||
} | ||
@@ -135,3 +132,3 @@ | ||
optOutTracking() { | ||
return MixpanelReactNative.optOutTracking(this.token); | ||
MixpanelReactNative.optOutTracking(this.token); | ||
} | ||
@@ -161,3 +158,3 @@ | ||
} | ||
return MixpanelReactNative.identify(this.token, distinctId); | ||
MixpanelReactNative.identify(this.token, distinctId); | ||
} | ||
@@ -182,7 +179,6 @@ | ||
} | ||
if (!StringHelper.isValid(distinctId)) { | ||
StringHelper.raiseError(PARAMS.DISTINCT_ID); | ||
} | ||
return MixpanelReactNative.alias(this.token, alias, distinctId); | ||
MixpanelReactNative.alias(this.token, alias, distinctId); | ||
} | ||
@@ -206,7 +202,6 @@ | ||
} | ||
if (!ObjectHelper.isValidOrUndefined(properties)) { | ||
ObjectHelper.raiseError(PARAMS.PROPERTIES); | ||
} | ||
return MixpanelReactNative.track(this.token, eventName, properties || {}); | ||
MixpanelReactNative.track(this.token, eventName, properties || {}); | ||
} | ||
@@ -243,7 +238,6 @@ | ||
} | ||
if (!ObjectHelper.isValidOrUndefined(properties)) { | ||
ObjectHelper.raiseError(PARAMS.PROPERTIES); | ||
} | ||
return MixpanelReactNative.trackWithGroups(this.token, eventName, properties || {}, groups); | ||
MixpanelReactNative.trackWithGroups(this.token, eventName, properties || {}, groups); | ||
} | ||
@@ -261,4 +255,3 @@ | ||
} | ||
return MixpanelReactNative.setGroup(this.token, groupKey, groupID); | ||
MixpanelReactNative.setGroup(this.token, groupKey, groupID); | ||
} | ||
@@ -289,4 +282,3 @@ | ||
} | ||
return MixpanelReactNative.addGroup(this.token, groupKey, groupID); | ||
MixpanelReactNative.addGroup(this.token, groupKey, groupID); | ||
} | ||
@@ -304,4 +296,3 @@ | ||
} | ||
return MixpanelReactNative.removeGroup(this.token, groupKey, groupID); | ||
MixpanelReactNative.removeGroup(this.token, groupKey, groupID); | ||
} | ||
@@ -321,3 +312,3 @@ | ||
} | ||
return MixpanelReactNative.deleteGroup(this.token, groupKey, groupID); | ||
MixpanelReactNative.deleteGroup(this.token, groupKey, groupID); | ||
} | ||
@@ -344,3 +335,3 @@ | ||
} | ||
return MixpanelReactNative.registerSuperProperties(this.token, properties || {}); | ||
MixpanelReactNative.registerSuperProperties(this.token, properties || {}); | ||
} | ||
@@ -360,3 +351,3 @@ | ||
} | ||
return MixpanelReactNative.registerSuperPropertiesOnce(this.token, properties || {}); | ||
MixpanelReactNative.registerSuperPropertiesOnce(this.token, properties || {}); | ||
} | ||
@@ -377,3 +368,3 @@ | ||
} | ||
return MixpanelReactNative.unregisterSuperProperty(this.token, propertyName); | ||
MixpanelReactNative.unregisterSuperProperty(this.token, propertyName); | ||
} | ||
@@ -387,3 +378,3 @@ | ||
* | ||
* @return {object} Super properties for this Mixpanel instance. | ||
* @return {Promise<object>} Super properties for this Mixpanel instance. | ||
*/ | ||
@@ -403,3 +394,3 @@ getSuperProperties() { | ||
clearSuperProperties() { | ||
return MixpanelReactNative.clearSuperProperties(this.token); | ||
MixpanelReactNative.clearSuperProperties(this.token); | ||
} | ||
@@ -418,3 +409,3 @@ | ||
} | ||
return MixpanelReactNative.timeEvent(this.token, eventName); | ||
MixpanelReactNative.timeEvent(this.token, eventName); | ||
} | ||
@@ -427,3 +418,3 @@ | ||
* | ||
* @return {number} Time elapsed since timeEvent(String) was called for the given eventName. | ||
* @return {Promise<number>} Time elapsed since timeEvent(String) was called for the given eventName. | ||
*/ | ||
@@ -442,3 +433,3 @@ eventElapsedTime(eventName) { | ||
reset() { | ||
return MixpanelReactNative.reset(this.token); | ||
MixpanelReactNative.reset(this.token); | ||
} | ||
@@ -474,3 +465,3 @@ | ||
flush() { | ||
return MixpanelReactNative.flush(this.token); | ||
MixpanelReactNative.flush(this.token); | ||
} | ||
@@ -505,3 +496,3 @@ } | ||
* @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code" | ||
* @param {string} to The value of the Mixpanel property. For "Zip Code", this value might be the String "90210" | ||
* @param {object} to The value of the Mixpanel property. For "Zip Code", this value might be the String "90210" | ||
*/ | ||
@@ -518,3 +509,3 @@ set(prop, to) { | ||
} | ||
return MixpanelReactNative.set(this.token, properties); | ||
MixpanelReactNative.set(this.token, properties); | ||
} | ||
@@ -526,3 +517,3 @@ | ||
* @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code" | ||
* @param {string} to The value of the Mixpanel property. For "Zip Code", this value might be the String "90210" | ||
* @param {object} to The value of the Mixpanel property. For "Zip Code", this value might be the String "90210" | ||
*/ | ||
@@ -540,3 +531,3 @@ setOnce(prop, to) { | ||
} | ||
return MixpanelReactNative.setOnce(this.token, properties); | ||
MixpanelReactNative.setOnce(this.token, properties); | ||
} | ||
@@ -550,3 +541,3 @@ | ||
* @param {string} prop the People Analytics property that should have its value changed | ||
* @param {string} by the amount to be added to the current value of the named property | ||
* @param {number} by the amount to be added to the current value of the named property | ||
* | ||
@@ -576,3 +567,3 @@ */ | ||
} | ||
return MixpanelReactNative.increment(this.token, add); | ||
MixpanelReactNative.increment(this.token, add); | ||
} | ||
@@ -585,3 +576,3 @@ | ||
* @param {string} name the People Analytics property that should have it's value appended to | ||
* @param {string} value the new value that will appear at the end of the property's list | ||
* @param {object} value the new value that will appear at the end of the property's list | ||
*/ | ||
@@ -597,5 +588,5 @@ append(name, value) { | ||
if (DevicePlatform.iOS === Helper.getDevicePlatform()) { | ||
return MixpanelReactNative.append(this.token, appendProp); | ||
MixpanelReactNative.append(this.token, appendProp); | ||
} else { | ||
return MixpanelReactNative.append(this.token, name, value); | ||
MixpanelReactNative.append(this.token, name, value); | ||
} | ||
@@ -610,3 +601,3 @@ } | ||
* @param {string} name name of the list-valued property to set or modify | ||
* @param {string} value an array of values to add to the property value if not already present | ||
* @param {array} value an array of values to add to the property value if not already present | ||
*/ | ||
@@ -621,5 +612,5 @@ union(name, value) { | ||
if (DevicePlatform.iOS === Helper.getDevicePlatform()) { | ||
return MixpanelReactNative.union(this.token, {[name]: value}); | ||
MixpanelReactNative.union(this.token, {[name]: value}); | ||
} else { | ||
return MixpanelReactNative.union(this.token, name, value); | ||
MixpanelReactNative.union(this.token, name, value); | ||
} | ||
@@ -633,3 +624,3 @@ } | ||
* @param {string} name the People Analytics property that should have it's value removed from | ||
* @param {string} value the value that will be removed from the property's list | ||
* @param {object} value the value that will be removed from the property's list | ||
*/ | ||
@@ -645,5 +636,5 @@ remove(name, value) { | ||
if (DevicePlatform.iOS === Helper.getDevicePlatform()) { | ||
return MixpanelReactNative.remove(this.token, removeProp); | ||
MixpanelReactNative.remove(this.token, removeProp); | ||
} else { | ||
return MixpanelReactNative.remove(this.token, name, value); | ||
MixpanelReactNative.remove(this.token, name, value); | ||
} | ||
@@ -660,3 +651,3 @@ } | ||
} | ||
return MixpanelReactNative.unset(this.token, name); | ||
MixpanelReactNative.unset(this.token, name); | ||
} | ||
@@ -678,3 +669,3 @@ | ||
} | ||
return MixpanelReactNative.trackCharge(this.token, charge, properties || {}); | ||
MixpanelReactNative.trackCharge(this.token, charge, properties || {}); | ||
} | ||
@@ -686,3 +677,3 @@ | ||
clearCharges() { | ||
return MixpanelReactNative.clearCharges(this.token); | ||
MixpanelReactNative.clearCharges(this.token); | ||
} | ||
@@ -697,3 +688,3 @@ | ||
deleteUser() { | ||
return MixpanelReactNative.deleteUser(this.token); | ||
MixpanelReactNative.deleteUser(this.token); | ||
} | ||
@@ -736,3 +727,3 @@ } | ||
} | ||
return MixpanelReactNative.groupSetProperties(this.token, this.groupKey, this.groupID, properties); | ||
MixpanelReactNative.groupSetProperties(this.token, this.groupKey, this.groupID, properties); | ||
} | ||
@@ -756,3 +747,3 @@ | ||
} | ||
return MixpanelReactNative.groupSetPropertyOnce(this.token, this.groupKey, this.groupID, properties); | ||
MixpanelReactNative.groupSetPropertyOnce(this.token, this.groupKey, this.groupID, properties); | ||
} | ||
@@ -769,3 +760,3 @@ | ||
} | ||
return MixpanelReactNative.groupUnsetProperty(this.token, this.groupKey, this.groupID, prop); | ||
MixpanelReactNative.groupUnsetProperty(this.token, this.groupKey, this.groupID, prop); | ||
} | ||
@@ -786,3 +777,3 @@ | ||
return MixpanelReactNative.groupRemovePropertyValue(this.token, this.groupKey, this.groupID, name, value); | ||
MixpanelReactNative.groupRemovePropertyValue(this.token, this.groupKey, this.groupID, name, value); | ||
} | ||
@@ -803,3 +794,3 @@ | ||
value = Array.isArray(value) ? value : [value]; | ||
return MixpanelReactNative.groupUnionProperty(this.token, this.groupKey, this.groupID, name, value); | ||
MixpanelReactNative.groupUnionProperty(this.token, this.groupKey, this.groupID, name, value); | ||
} | ||
@@ -806,0 +797,0 @@ |
{ | ||
"name": "mixpanel-react-native", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Official React Native Tracking Library for Mixpanel Analytics", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1358366
66
1711