Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci --ignore-scripts
- run: npm install --ignore-scripts
- run: npm run build
- run: npm run lint
- run: npm test
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/publish-svelte.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish @screeb/sdk-svelte

on:
push:
tags:
- '@screeb/sdk-svelte@*'

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- run: npm install -g npm@latest
- run: npm install --ignore-scripts
- run: npm run build
- run: npm publish --workspace=packages/sdk-svelte --access public --provenance
4 changes: 1 addition & 3 deletions examples/example-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"build": "tsc && vite build",
"clean": "rm -Rf dist",
"lint": "eslint .",
"lint": "eslint \"src/**/*.ts\"",
"start": "vite"
},
"dependencies": {
Expand All @@ -37,10 +37,8 @@
"@typescript-eslint/eslint-plugin": "^6.7.5",
"eslint": "^8.51.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.7.0",
"typescript": "^5.2.2",
"vite": "^4.4.11"
}
Expand Down
4 changes: 1 addition & 3 deletions examples/example-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"build": "vite build",
"clean": "rm -Rf dist",
"lint": "eslint .",
"lint": "eslint \"src/**/*.{ts,js}\"",
"start": "vite"
},
"dependencies": {
Expand All @@ -32,11 +32,9 @@
"@typescript-eslint/eslint-plugin": "^6.7.5",
"eslint": "^8.51.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-svelte": "^2.34.0",
"jest": "^29.7.0",
"svelte": "^4.2.1",
"svelte-check": "^3.5.2",
"tslib": "^2.6.2",
Expand Down
64 changes: 25 additions & 39 deletions examples/example-expo/README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,41 @@
# Welcome to your Expo app 👋
# `@screeb/react-native` Expo example

This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
Minimal Expo app used to validate the Screeb React Native SDK with a generated native project.

> Screeb SDK documentation: [developers.screeb.app/sdk-react-native/install](https://developers.screeb.app/sdk-react-native/install)
> Documentation: [developers.screeb.app/sdk-react-native/install](https://developers.screeb.app/sdk-react-native/install)

## Get started
## Run

1. Install dependencies from the repository root (all workspaces share the same lockfile).
Install dependencies from the repository root:

```bash
npm install
```

2. Recreate the native project (new architecture is enabled by default and Screeb is autolinked via `react-native.config.js`).

```bash
npm run prebuild --workspace=example-expo
npm run ios --workspace=example-expo # or npm run android --workspace=example-expo
```

3. Start the Metro server.

```bash
npm run example:expo --workspace=@screeb/react-native
```

The generated build installs a fully native binary; Expo Go cannot load the Screeb TurboModule. Always launch the app produced by `expo run:ios` / `expo run:android` after the `prebuild` step.
If native sources fall out of sync, re-run `npm run prebuild --workspace=example-expo -- --clean` to regenerate the iOS and Android folders from scratch.

You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).

## Get a fresh project
```bash
npm install
```

When you're ready, run:
Recreate the native project:

```bash
npm run reset-project --workspace=example-expo
npm run prebuild --workspace=example-expo
```

This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
Run the native app:

## Learn more
```bash
npm run ios --workspace=example-expo
# or
npm run android --workspace=example-expo
```

To learn more about developing your project with Expo, look at the following resources:
Start Metro from the React Native SDK workspace:

- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
```bash
npm run example:expo --workspace=@screeb/react-native
```

## Join the community
Expo Go cannot load the Screeb TurboModule. Use the app produced by `expo run:ios` or `expo run:android`.

Join our community of developers creating universal apps.
If native sources fall out of sync, regenerate them with:

- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
```bash
npm run prebuild --workspace=example-expo -- --clean
```
30 changes: 3 additions & 27 deletions examples/example-expo/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,23 @@
"slug": "example-expo",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "exampleexpo",
"userInterfaceStyle": "automatic",
"newArchEnabled": true,
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.anonymous.example-expo"
},
"android": {
"adaptiveIcon": {
"backgroundColor": "#E6F4FE",
"foregroundImage": "./assets/images/android-icon-foreground.png",
"backgroundImage": "./assets/images/android-icon-background.png",
"monochromeImage": "./assets/images/android-icon-monochrome.png"
},
"edgeToEdgeEnabled": true,
"predictiveBackGestureEnabled": false,
"package": "com.anonymous.exampleexpo"
},
"web": {
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router",
[
"expo-splash-screen",
{
"image": "./assets/images/splash-icon.png",
"imageWidth": 200,
"resizeMode": "contain",
"backgroundColor": "#ffffff",
"dark": {
"backgroundColor": "#000000"
}
}
]
"./plugins/withScreebLocalSdk",
"expo-router"
],
"experiments": {
"typedRoutes": true,
"reactCompiler": true
"typedRoutes": true
}
}
}
23 changes: 5 additions & 18 deletions examples/example-expo/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import 'react-native-reanimated';

import { useColorScheme } from '@/hooks/use-color-scheme';

export const unstable_settings = {
anchor: '(tabs)',
};
import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";

export default function RootLayout() {
const colorScheme = useColorScheme();

return (
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
</Stack>
<>
<Stack screenOptions={{ headerShown: false }} />
<StatusBar style="auto" />
</ThemeProvider>
</>
);
}
150 changes: 150 additions & 0 deletions examples/example-expo/app/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import * as Screeb from "@screeb/react-native";
import { useEffect } from "react";
import {
Alert,
Button,
ScrollView,
StyleSheet,
Text,
View,
} from "react-native";

const PROJECT_TOKEN = "0e2b609a-8dce-4695-a80f-966fbfa87a88";
const RESPONDENT_ID = "0021de43-6e44-443c-9903-2ab99f9c4233";
const SURVEY_ID = "8dd42ae1-f716-429c-9843-fad62adf2ac4";
const USER_PROPERTIES = {
locale: "fr-FR",
premium: true,
};

const initScreeb = async () => {
try {
await Screeb.initSdk(
PROJECT_TOKEN,
RESPONDENT_ID,
USER_PROPERTIES,
{
onReady: (payload: unknown) => {
console.log("Screeb ready", payload);
},
onSurveyDisplayAllowed: () => {
console.log("Survey display allowed");
return true;
},
version: "1.0.0",
},
{},
);
} catch (error) {
console.error("Failed to init Screeb", error);
Alert.alert("Screeb init failed", "Check the Metro logs for details.");
}
};

export default function ScreebExpoExample() {
useEffect(() => {
initScreeb();
}, []);

return (
<ScrollView contentContainerStyle={styles.content}>
<Text style={styles.title}>@screeb/react-native + Expo</Text>
<Text style={styles.description}>
Minimal Expo development build for exercising the Screeb React Native
wrapper.
</Text>

<View style={styles.buttonList}>
<Button title="Init SDK" onPress={() => initScreeb()} />
<Button title="Close SDK" onPress={() => Screeb.closeSdk()} />
<Button
title="Set identity"
onPress={() =>
Screeb.setIdentity("expo-user@screeb.app", {
plan: "Pro",
premium: true,
})
}
/>
<Button
title="Track event"
onPress={() =>
Screeb.trackEvent("ExpoExampleEvent", {
plan: "Pro",
premium: true,
})
}
/>
<Button
title="Track screen"
onPress={() =>
Screeb.trackScreen("ExpoExampleScreen", {
plan: "Pro",
premium: true,
})
}
/>
<Button
title="Set visitor properties"
onPress={() =>
Screeb.setProperties({
plan: "Pro",
premium: true,
})
}
/>
<Button
title="Start survey"
onPress={() =>
Screeb.startSurvey(SURVEY_ID, true, null, true, {
onSurveyShowed: (payload: string) => {
console.log("Survey displayed", payload);
return null;
},
version: "1.0.0",
})
}
/>
<Button
title="Assign group"
onPress={() =>
Screeb.assignGroup(null, "ExpoFans", {
plan: "Pro",
})
}
/>
<Button
title="Unassign group"
onPress={() =>
Screeb.unassignGroup(null, "ExpoFans", {
plan: "Pro",
})
}
/>
<Button title="Debug" onPress={() => Screeb.debug()} />
<Button title="Debug targeting" onPress={() => Screeb.debugTargeting()} />
</View>
</ScrollView>
);
}

const styles = StyleSheet.create({
buttonList: {
gap: 12,
},
content: {
gap: 18,
padding: 24,
paddingTop: 72,
},
description: {
color: "#475569",
fontSize: 16,
lineHeight: 22,
},
title: {
color: "#0f172a",
fontSize: 24,
fontWeight: "700",
},
});
1 change: 0 additions & 1 deletion examples/example-expo/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ module.exports = (api) => {

return {
presets: ["babel-preset-expo"],
plugins: ["react-native-reanimated/plugin"],
};
};
Loading
Loading