Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zihejia committed Feb 29, 2024
1 parent a03310c commit e85357e
Show file tree
Hide file tree
Showing 16 changed files with 252 additions and 164 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"java.compile.nullAnalysis.mode": "automatic"
"java.compile.nullAnalysis.mode": "automatic",
"files.trimTrailingWhitespace": true
}
77 changes: 42 additions & 35 deletions Samples/MixpanelExpo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SafeAreaView,
} from "react-native";

import { Mixpanel } from "mixpanel-react-native";
import {Mixpanel} from "mixpanel-react-native";

const App = () => {
const trackAutomaticEvents = false;
Expand All @@ -23,7 +23,7 @@ const App = () => {

const group = mixpanel.getGroup("company_id", 111);
const track = async () => {
await mixpanel.track("Track Event1!");
await mixpanel.track("Track Event!");
};

const identify = async () => {
Expand All @@ -38,8 +38,14 @@ const App = () => {
}, 2000);
};

const createAlias = async () => {
const distinctId = await mixpanel.getDistinctId();
alert(distinctId);
await mixpanel.alias("New Alias", distinctId);
};

const trackWProperties = async () => {
const properties = { "Cool Property": "Property Value" };
const properties = {"Cool Property": "Property Value"};
await mixpanel.track("Track event with property", properties);
};

Expand Down Expand Up @@ -134,7 +140,7 @@ const App = () => {
};

const trackCharge = () => {
mixpanel.getPeople().trackCharge(12.8, { sandwich: 1 });
mixpanel.getPeople().trackCharge(12.8, {sandwich: 1});
};

const clearCharges = () => {
Expand Down Expand Up @@ -186,18 +192,18 @@ const App = () => {
const trackWithGroups = () => {
mixpanel.trackWithGroups(
"tracked with groups",
{ a: 1, b: 2.3 },
{ company_id: 111 }
{a: 1, b: 2.3},
{company_id: 111}
);
};

const DATA = [
{
title: "Events and Properties",
data: [
{ id: "1", label: "Track Event", onPress: track },
{ id: "2", label: "Identify", onPress: identify },
{ id: "3", label: "Time Event for 2 secs", onPress: timeEvent },
{id: "1", label: "Track Event", onPress: track},
{id: "2", label: "Identify", onPress: identify},
{id: "3", label: "Time Event for 2 secs", onPress: timeEvent},
{
id: "4",
label: "Track Event with Properties",
Expand Down Expand Up @@ -228,35 +234,36 @@ const App = () => {
label: "Register Super Properties Once",
onPress: registerSuperPropertiesOnce,
},
{ id: "10", label: "Flush", onPress: flush },
{id: "10", label: "Create Alias", onPress: createAlias},
{id: "11", label: "Flush", onPress: flush},
],
},
{
title: "GDPR",
data: [
{ id: "1", label: "Opt In", onPress: optIn },
{ id: "2", label: "Opt Out", onPress: optOut },
{id: "1", label: "Opt In", onPress: optIn},
{id: "2", label: "Opt Out", onPress: optOut},
],
},
{
title: "Profile",
data: [
{ id: "2", label: "Set Property", onPress: setProperty },
{ id: "3", label: "Set One Property", onPress: setOneProperty },
{id: "2", label: "Set Property", onPress: setProperty},
{id: "3", label: "Set One Property", onPress: setOneProperty},
{
id: "4",
label: "Set One Property Once",
onPress: setOnePropertyOnce,
},
{ id: "5", label: "Unset Properties", onPress: unsetProperties },
{ id: "6", label: "Increment Property", onPress: incrementProperty },
{id: "5", label: "Unset Properties", onPress: unsetProperties},
{id: "6", label: "Increment Property", onPress: incrementProperty},
{
id: "7",
label: "Remove Property Value",
onPress: removePropertyValue,
},
{ id: "8", label: "Append Properties", onPress: appendProperties },
{ id: "9", label: "Union Properties", onPress: unionProperties },
{id: "8", label: "Append Properties", onPress: appendProperties},
{id: "9", label: "Union Properties", onPress: unionProperties},
{
id: "10",
label: "Track Charge",
Expand All @@ -267,37 +274,37 @@ const App = () => {
label: "Track Charge with Properties",
onPress: trackCharge,
},
{ id: "12", label: "Clear Charges", onPress: clearCharges },
{ id: "1", label: "Reset", onPress: reset },
{ id: "13", label: "Delete User", onPress: deleteUser },
{ id: "14", label: "Flush", onPress: flush },
{id: "12", label: "Clear Charges", onPress: clearCharges},
{id: "1", label: "Reset", onPress: reset},
{id: "13", label: "Delete User", onPress: deleteUser},
{id: "14", label: "Flush", onPress: flush},
],
},
{
title: "Group",
data: [
{ id: "1", label: "Add Group", onPress: addGroup },
{ id: "2", label: "Set Group", onPress: setGroup },
{ id: "3", label: "Remove Group", onPress: removeGroup },
{ id: "4", label: "Delete Group", onPress: deleteGroup },
{ id: "5", label: "Track With Groups", onPress: trackWithGroups },
{ id: "6", label: "Set Group Property", onPress: setGroupProperty },
{ id: "7", label: "Set Property Once", onPress: setGroupPropertyOnce },
{ id: "8", label: "Unset Property", onPress: unsetGroupProperty },
{ id: "9", label: "Remove Property", onPress: removeGroupProperty },
{ id: "10", label: "Union Property", onPress: unionGroupProperty },
{ id: "11", label: "Flush", onPress: flush },
{id: "1", label: "Add Group", onPress: addGroup},
{id: "2", label: "Set Group", onPress: setGroup},
{id: "3", label: "Remove Group", onPress: removeGroup},
{id: "4", label: "Delete Group", onPress: deleteGroup},
{id: "5", label: "Track With Groups", onPress: trackWithGroups},
{id: "6", label: "Set Group Property", onPress: setGroupProperty},
{id: "7", label: "Set Property Once", onPress: setGroupPropertyOnce},
{id: "8", label: "Unset Property", onPress: unsetGroupProperty},
{id: "9", label: "Remove Property", onPress: removeGroupProperty},
{id: "10", label: "Union Property", onPress: unionGroupProperty},
{id: "11", label: "Flush", onPress: flush},
],
},
];

const renderItem = ({ item }) => (
const renderItem = ({item}) => (
<View style={styles.item}>
<Button title={item.label} onPress={item.onPress} color="#8A2BE2" />
</View>
);

const renderSectionHeader = ({ section: { title } }) => (
const renderSectionHeader = ({section: {title}}) => (
<Text style={styles.header}>{title}</Text>
);

Expand Down
5 changes: 4 additions & 1 deletion Samples/MixpanelExpo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"expo-status-bar": "~1.11.1",
"mixpanel-react-native": "github:mixpanel/mixpanel-react-native#js-core",
"react": "18.2.0",
"react-native": "0.73.4"
"react-native": "0.73.4",
"react-native-web": "~0.19.6",
"react-dom": "18.2.0",
"@expo/metro-runtime": "~3.1.3"
},
"devDependencies": {
"@babel/core": "^7.20.0"
Expand Down
Loading

0 comments on commit e85357e

Please sign in to comment.