Skip to content

Commit

Permalink
Merge pull request #2 from UserLeap/jh/PDE-3769
Browse files Browse the repository at this point in the history
Add event properties
  • Loading branch information
Joyce Huang committed Nov 8, 2022
2 parents 7baa48a + 59a09a1 commit 3a38aa5
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 373 deletions.
69 changes: 45 additions & 24 deletions example/App.js
Expand Up @@ -6,8 +6,8 @@
* @flow strict-local
*/

import React from 'react';
import type {Node} from 'react';
import React from "react";
import type { Node } from "react";
import {
SafeAreaView,
ScrollView,
Expand All @@ -17,25 +17,26 @@ import {
useColorScheme,
View,
TouchableOpacity,
} from 'react-native';
} from "react-native";

import {
Colors,
Header,
LearnMoreLinks,
} from 'react-native/Libraries/NewAppScreen';
import { createClient } from '@segment/analytics-react-native';
import { SprigPlugin } from '@sprig-technologies/analytics-react-native-plugin-sprig';
} from "react-native/Libraries/NewAppScreen";
import { createClient } from "@segment/analytics-react-native";
import { SprigPlugin } from "@sprig-technologies/analytics-react-native-plugin-sprig";

const Section = ({children, title}): Node => {
const isDarkMode = useColorScheme() === 'dark';
const Section = ({ children, title }): Node => {
const isDarkMode = useColorScheme() === "dark";
return (
<>
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
style={styles.scrollView}
>
<Header />
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
Expand All @@ -49,53 +50,73 @@ const Section = ({children, title}): Node => {
};

const App: () => Node = () => {
const isDarkMode = useColorScheme() === 'dark';
const isDarkMode = useColorScheme() === "dark";

const segmentClient = createClient({
writeKey: 'YOUR_SEGMENT_WRITE_KEY_HERE',
trackAppLifecycleEvents: true,
defaultSettings: true,
});
const plugin = new SprigPlugin();
segmentClient.add({plugin: plugin});
segmentClient.add({ plugin: plugin });

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

return (
<SafeAreaView style={backgroundStyle}>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<StatusBar barStyle={isDarkMode ? "light-content" : "dark-content"} />
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
style={backgroundStyle}
>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
}}
>
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Track</Text>
<View style={styles.sectionDescription}>
<TouchableOpacity
onPress={() => {
segmentClient.track('YOUR_SPRIG_SURVEY_EVENT');
}}>
segmentClient.track("YOUR_SPRIG_SURVEY_EVENT");
}}
>
<Text>Send event</Text>
</TouchableOpacity>
</View>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Track</Text>
<View style={styles.sectionDescription}>
<TouchableOpacity
onPress={() => {
segmentClient.track("YOUR_SPRIG_SURVEY_EVENT", {
isFreePlan: false,
age: 45,
planName: "Premium",
});
}}
>
<Text>Send event with properties</Text>
</TouchableOpacity>
</View>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Identify</Text>
<View style={styles.sectionDescription}>
<TouchableOpacity
onPress={() => {
segmentClient.identify('YOUR_USER_ID', {
test_attribute: '1',
email: 'abc@test.com',
segmentClient.identify("YOUR_USER_ID", {
test_attribute: "1",
email: "abc@test.com",
});
}}>
}}
>
<Text>Send event</Text>
</TouchableOpacity>
</View>
Expand All @@ -115,15 +136,15 @@ const styles = StyleSheet.create({
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
fontWeight: "600",
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
fontWeight: "400",
},
highlight: {
fontWeight: '700',
fontWeight: "700",
},
});

Expand Down
16 changes: 13 additions & 3 deletions example/ios/Podfile.lock
Expand Up @@ -284,6 +284,9 @@ PODS:
- React-jsinspector (0.69.5)
- React-logger (0.69.5):
- glog
- react-native-userleap (2.12.0):
- React
- UserLeapKit (= 4.11.0)
- React-perflogger (0.69.5)
- React-RCTActionSheet (0.69.5):
- React-Core/RCTActionSheetHeaders (= 0.69.5)
Expand Down Expand Up @@ -356,8 +359,9 @@ PODS:
- React-Core
- sovran-react-native
- SocketRocket (0.6.0)
- sovran-react-native (0.4.4):
- sovran-react-native (0.4.5):
- React-Core
- UserLeapKit (4.11.0)
- Yoga (1.14.0)
- YogaKit (1.18.1):
- Yoga (~> 1.14)
Expand Down Expand Up @@ -406,6 +410,7 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- react-native-userleap (from `../node_modules/react-native-userleap`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
Expand Down Expand Up @@ -439,6 +444,7 @@ SPEC REPOS:
- libevent
- OpenSSL-Universal
- SocketRocket
- UserLeapKit
- YogaKit

EXTERNAL SOURCES:
Expand Down Expand Up @@ -480,6 +486,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
react-native-userleap:
:path: "../node_modules/react-native-userleap"
React-perflogger:
:path: "../node_modules/react-native/ReactCommon/reactperflogger"
React-RCTActionSheet:
Expand Down Expand Up @@ -546,6 +554,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: e42f0b46de293a026c2fb20e524d4fe09f81f575
React-jsinspector: e385fb7a1440ae3f3b2cd1a139ca5aadaab43c10
React-logger: 15c734997c06fe9c9b88e528fb7757601e7a56df
react-native-userleap: 6f56e436fe9284fde68dcb182f25f9e9f930faca
React-perflogger: 367418425c5e4a9f0f80385ee1eaacd2a7348f8e
React-RCTActionSheet: e4885e7136f98ded1137cd3daccc05eaed97d5a6
React-RCTAnimation: 7c5a74f301c9b763343ba98a3dd776ed2676993f
Expand All @@ -561,10 +570,11 @@ SPEC CHECKSUMS:
RNCAsyncStorage: 0c357f3156fcb16c8589ede67cc036330b6698ca
segment-analytics-react-native: f550cb6d5d5f67eb8099f78108f8ded1052cd5e4
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
sovran-react-native: 5f9715a62b50008d72c0cf904cb08c8377777b62
sovran-react-native: fd3dc8f1a4b14acdc4ad25fc6b4ac4f52a2a2a15
UserLeapKit: a6b9029ed8e181cdb7f0692b606552e9d061cbf9
Yoga: c2b1f2494060865ac1f27e49639e72371b1205fa
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 254f9fef949e27a5512142d052082c6d900279c2

COCOAPODS: 1.11.2
COCOAPODS: 1.11.3
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
4 changes: 2 additions & 2 deletions example/package.json
@@ -1,6 +1,6 @@
{
"name": "ReactNativeTestApp",
"version": "0.0.1",
"version": "0.0.2",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand All @@ -16,7 +16,7 @@
"@sprig-technologies/analytics-react-native-plugin-sprig": "../",
"react": "18.0.0",
"react-native": "0.69.5",
"react-native-userleap": "2.8.4"
"react-native-userleap": "2.12.0"
},
"devDependencies": {
"@babel/core": "^7.12.9",
Expand Down

0 comments on commit 3a38aa5

Please sign in to comment.