Skip to content

Commit

Permalink
chore: last expo sample for android and ios and session replay (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Sep 25, 2024
1 parent ccb0aeb commit e034b82
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 74 deletions.
45 changes: 0 additions & 45 deletions .github/disabled_workflows/ci-e2e.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/bundle-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- uses: actions/checkout@v4
- uses: preactjs/compressed-size-action@v2
with:
pattern: 'posthog-{web,node}/lib/**/*.js'
pattern: 'posthog-{web,node,react-native}/lib/**/*.js'
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18

- run: yarn install
- run: yarn test
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18

- run: yarn install
- run: yarn build
Expand All @@ -42,10 +42,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
- run: |
yarn
cd examples/example-expo
cd examples/example-expo-latest
yarn global add yalc
yarn
yarn tsc
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
with:
path: ${{ matrix.package.name }}

- name: Set up Node 16
- name: Set up Node 18
uses: actions/setup-node@v4
if: steps.check-package-version.outputs.is-new-version == 'true'
with:
node-version: 16
node-version: 18
registry-url: https://registry.npmjs.org

- name: Install dependencies
Expand Down
7 changes: 1 addition & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ yarn test
yarn test:rn
```

### Running E2E tests with Detox

See [Example Expo Readme](./examples/example-expo/README.md)

### Examples

#### React Native

```sh
cd examples/example-expo
cd examples/example-expo-latest
yarn && yarn start
```

Expand All @@ -45,5 +41,4 @@ Then run:
```sh
cd examples/example-node
yarn && yarn start
# example-expo has some buttons that will talk to this server
```
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import React, { useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import PostHog from "posthog-react-native";
import React, { useState } from 'react'
import { StatusBar } from 'expo-status-bar'
import { StyleSheet, Text, View } from 'react-native'
import PostHog from 'posthog-react-native'

export const posthog = new PostHog('phc_QFbR1y41s5sxnNTZoyKG2NJo2RlsCIWkUfdpawgb40D', {
export const posthog = new PostHog('phc_QFbR1y41s5sxnNTZoyKG2NJo2RlsCIWkUfdpawgb40D', {
host: 'https://us.i.posthog.com',
flushAt: 1,
enableSessionReplay: true,
})
})
posthog.debug(true)

export default function App() {
const [buttonText, setButtonText] = useState('Open up App.js to start working on your app!');
const [buttonText, setButtonText] = useState('Open up App.js to start working on your app!')

const handleClick = () => {
posthog.capture('button_clicked', { name: 'example' });
setButtonText('button_clicked' + new Date().toISOString());
};
posthog.capture('button_clicked', { name: 'example' })
setButtonText('button_clicked' + new Date().toISOString())
}

return (
<View style={styles.container}>
<Text onPress={handleClick}>{buttonText}</Text>
<StatusBar style="auto" />
</View>
);
)
}

const styles = StyleSheet.create({
Expand All @@ -33,4 +33,4 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
});
})
13 changes: 10 additions & 3 deletions examples/example-expo-latest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
"version": "1.0.0",
"main": "expo/AppEntry.js",
"scripts": {
"preinstall": "yarn build:posthog",
"prestart": "yarn build:posthog",
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
"web": "expo start --web",
"build:posthog": "yarn build:posthog:publish && yarn build:posthog:link",
"build:posthog:publish": "cd ../../posthog-react-native && yalc publish --replace",
"build:posthog:link": "yalc add posthog-react-native"
},
"dependencies": {
"expo": "~51.0.28",
Expand All @@ -15,13 +20,15 @@
"expo-file-system": "~17.0.1",
"expo-localization": "~15.0.3",
"expo-status-bar": "~1.12.1",
"posthog-react-native": "^3.3.0",
"posthog-react-native": "file:.yalc/posthog-react-native",
"posthog-react-native-session-replay": "^0.1.1",
"react": "18.2.0",
"react-native": "0.74.5"
},
"devDependencies": {
"@babel/core": "^7.20.0"
"@babel/core": "^7.20.0",
"@types/react": "^18.3.9",
"typescript": "^5.6.2"
},
"private": true
}
8 changes: 7 additions & 1 deletion examples/example-expo-latest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"compilerOptions": {},
"compilerOptions": {
"strict": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"extends": "expo/tsconfig.base"
}

0 comments on commit e034b82

Please sign in to comment.