diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96fab4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# Dependencies +node_modules +.pnp +.pnp.js + +# Local env files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Testing +coverage + +# Turbo +.turbo + +# Vercel +.vercel + +# Build Outputs +.next/ +out/ +build +dist + + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Misc +.DS_Store +*.pem diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..e69de29 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..44a73ec --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "eslint.workingDirectories": [ + { + "mode": "auto" + } + ] +} diff --git a/LICENSE b/LICENSE index de2343e..f35683e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 Formbricks +Copyright (c) 2025 Formbricks GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 6892f3f..b57eb76 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,84 @@ -# react-native -Formbricks React-Native SDK +# Turborepo starter + +This Turborepo starter is maintained by the Turborepo core team. + +## Using this example + +Run the following command: + +```sh +npx create-turbo@latest +``` + +## What's inside? + +This Turborepo includes the following packages/apps: + +### Apps and Packages + +- `docs`: a [Next.js](https://nextjs.org/) app +- `web`: another [Next.js](https://nextjs.org/) app +- `@repo/ui`: a stub React component library shared by both `web` and `docs` applications +- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) +- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo + +Each package/app is 100% [TypeScript](https://www.typescriptlang.org/). + +### Utilities + +This Turborepo has some additional tools already setup for you: + +- [TypeScript](https://www.typescriptlang.org/) for static type checking +- [ESLint](https://eslint.org/) for code linting +- [Prettier](https://prettier.io) for code formatting + +### Build + +To build all apps and packages, run the following command: + +``` +cd my-turborepo +pnpm build +``` + +### Develop + +To develop all apps and packages, run the following command: + +``` +cd my-turborepo +pnpm dev +``` + +### Remote Caching + +> [!TIP] +> Vercel Remote Cache is free for all plans. Get started today at [vercel.com](https://vercel.com/signup?/signup?utm_source=remote-cache-sdk&utm_campaign=free_remote_cache). + +Turborepo can use a technique known as [Remote Caching](https://turborepo.com/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines. + +By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup?utm_source=turborepo-examples), then enter the following commands: + +``` +cd my-turborepo +npx turbo login +``` + +This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). + +Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo: + +``` +npx turbo link +``` + +## Useful Links + +Learn more about the power of Turborepo: + +- [Tasks](https://turborepo.com/docs/core-concepts/monorepos/running-tasks) +- [Caching](https://turborepo.com/docs/core-concepts/caching) +- [Remote Caching](https://turborepo.com/docs/core-concepts/remote-caching) +- [Filtering](https://turborepo.com/docs/core-concepts/monorepos/filtering) +- [Configuration Options](https://turborepo.com/docs/reference/configuration) +- [CLI Usage](https://turborepo.com/docs/reference/command-line-reference) diff --git a/apps/playground/.env.example b/apps/playground/.env.example new file mode 100644 index 0000000..340aecb --- /dev/null +++ b/apps/playground/.env.example @@ -0,0 +1,2 @@ +EXPO_PUBLIC_APP_URL=http://192.168.0.197:3000 +EXPO_PUBLIC_FORMBRICKS_ENVIRONMENT_ID=cm5p0cs7r000819182b32j0a1 \ No newline at end of file diff --git a/apps/playground/.eslintrc.js b/apps/playground/.eslintrc.js new file mode 100644 index 0000000..4d8dbbc --- /dev/null +++ b/apps/playground/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + extends: ["@formbricks/eslint-config/react.js"], + parserOptions: { + project: "tsconfig.json", + tsconfigRootDir: __dirname, + }, +}; diff --git a/apps/playground/.gitignore b/apps/playground/.gitignore new file mode 100644 index 0000000..05647d5 --- /dev/null +++ b/apps/playground/.gitignore @@ -0,0 +1,35 @@ +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +node_modules/ + +# Expo +.expo/ +dist/ +web-build/ + +# Native +*.orig.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision + +# Metro +.metro-health-check* + +# debug +npm-debug.* +yarn-debug.* +yarn-error.* + +# macOS +.DS_Store +*.pem + +# local env files +.env*.local + +# typescript +*.tsbuildinfo diff --git a/apps/playground/.npmrc b/apps/playground/.npmrc new file mode 100644 index 0000000..e69de29 diff --git a/apps/playground/app.json b/apps/playground/app.json new file mode 100644 index 0000000..31d6cb2 --- /dev/null +++ b/apps/playground/app.json @@ -0,0 +1,35 @@ +{ + "expo": { + "android": { + "adaptiveIcon": { + "backgroundColor": "#ffffff", + "foregroundImage": "./assets/adaptive-icon.png" + } + }, + "assetBundlePatterns": ["**/*"], + "icon": "./assets/icon.png", + "ios": { + "infoPlist": { + "NSCameraUsageDescription": "Take pictures for certain activities.", + "NSMicrophoneUsageDescription": "Need microphone access for recording videos.", + "NSPhotoLibraryUsageDescription": "Select pictures for certain activities." + }, + "supportsTablet": true + }, + "jsEngine": "hermes", + "name": "react-native-demo", + "newArchEnabled": true, + "orientation": "portrait", + "slug": "react-native-demo", + "splash": { + "backgroundColor": "#ffffff", + "image": "./assets/splash.png", + "resizeMode": "contain" + }, + "userInterfaceStyle": "light", + "version": "1.0.0", + "web": { + "favicon": "./assets/favicon.png" + } + } +} diff --git a/apps/playground/assets/adaptive-icon.png b/apps/playground/assets/adaptive-icon.png new file mode 100644 index 0000000..03d6f6b Binary files /dev/null and b/apps/playground/assets/adaptive-icon.png differ diff --git a/apps/playground/assets/favicon.png b/apps/playground/assets/favicon.png new file mode 100644 index 0000000..e75f697 Binary files /dev/null and b/apps/playground/assets/favicon.png differ diff --git a/apps/playground/assets/icon.png b/apps/playground/assets/icon.png new file mode 100644 index 0000000..a0b1526 Binary files /dev/null and b/apps/playground/assets/icon.png differ diff --git a/apps/playground/assets/splash.png b/apps/playground/assets/splash.png new file mode 100644 index 0000000..0e89705 Binary files /dev/null and b/apps/playground/assets/splash.png differ diff --git a/apps/playground/babel.config.js b/apps/playground/babel.config.js new file mode 100644 index 0000000..2943350 --- /dev/null +++ b/apps/playground/babel.config.js @@ -0,0 +1,6 @@ +module.exports = function babel(api) { + api.cache(true); + return { + presets: ["babel-preset-expo"], + }; +}; diff --git a/apps/playground/index.js b/apps/playground/index.js new file mode 100644 index 0000000..c2ccbfc --- /dev/null +++ b/apps/playground/index.js @@ -0,0 +1,7 @@ +import { registerRootComponent } from "expo"; +import { LogBox } from "react-native"; +import App from "./src/app"; + +registerRootComponent(App); + +LogBox.ignoreAllLogs(); diff --git a/apps/playground/metro.config.js b/apps/playground/metro.config.js new file mode 100644 index 0000000..6bd167c --- /dev/null +++ b/apps/playground/metro.config.js @@ -0,0 +1,21 @@ +// Learn more https://docs.expo.io/guides/customizing-metro +const path = require("node:path"); +const { getDefaultConfig } = require("expo/metro-config"); + +// Find the workspace root, this can be replaced with `find-yarn-workspace-root` +const workspaceRoot = path.resolve(__dirname, "../.."); +const projectRoot = __dirname; + +const config = getDefaultConfig(projectRoot); + +// 1. Watch all files within the monorepo +config.watchFolders = [workspaceRoot]; +// 2. Let Metro know where to resolve packages, and in what order +config.resolver.nodeModulesPaths = [ + path.resolve(projectRoot, "node_modules"), + path.resolve(workspaceRoot, "node_modules"), +]; +// 3. Force Metro to resolve (sub)dependencies only from the `nodeModulesPaths` +config.resolver.disableHierarchicalLookup = true; + +module.exports = config; diff --git a/apps/playground/package.json b/apps/playground/package.json new file mode 100644 index 0000000..66a37be --- /dev/null +++ b/apps/playground/package.json @@ -0,0 +1,30 @@ +{ + "name": "@formbricks/demo-react-native", + "version": "1.0.0", + "main": "./index.js", + "scripts": { + "dev": "expo start", + "android": "expo start --android", + "ios": "expo start --ios", + "web": "expo start --web", + "eject": "expo eject", + "clean": "rimraf .turbo node_modules .expo" + }, + "dependencies": { + "@formbricks/react-native": "workspace:*", + "@react-native-async-storage/async-storage": "2.1.0", + "expo": "52.0.28", + "expo-status-bar": "2.0.1", + "react": "18.3.1", + "react-dom": "18.3.1", + "react-native": "0.76.6", + "react-native-webview": "13.12.5" + }, + "devDependencies": { + "@babel/core": "7.26.0", + "@types/react": "18.3.18", + "eslint": "8.57.0", + "typescript": "5.7.2" + }, + "private": true +} diff --git a/apps/playground/src/app.tsx b/apps/playground/src/app.tsx new file mode 100644 index 0000000..a481648 --- /dev/null +++ b/apps/playground/src/app.tsx @@ -0,0 +1,117 @@ +import { StatusBar } from "expo-status-bar"; +import React, { type JSX } from "react"; +import { Button, LogBox, StyleSheet, Text, View } from "react-native"; +import Formbricks, { + logout, + setAttribute, + setAttributes, + setLanguage, + setUserId, + track, +} from "@formbricks/react-native"; + +LogBox.ignoreAllLogs(); + +export default function App(): JSX.Element { + if (!process.env.EXPO_PUBLIC_FORMBRICKS_ENVIRONMENT_ID) { + throw new Error("EXPO_PUBLIC_FORMBRICKS_ENVIRONMENT_ID is required"); + } + + if (!process.env.EXPO_PUBLIC_APP_URL) { + throw new Error("EXPO_PUBLIC_APP_URL is required"); + } + + return ( + + Formbricks React Native SDK Demo + + +