Skip to content
Open
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ web-build/
**/*/android

.turbo
build/**
build/**

#Firestore Config
packages/app/firebase/config/google-services.json
packages/app/firebase/config/GoogleService-Info.plist

9 changes: 6 additions & 3 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"semi": false,
"useTabs": false,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"arrowParens": "always",
"parser": "typescript",
"printWidth": 80,
"singleQuote": true
}
}
3 changes: 2 additions & 1 deletion apps/expo/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NativeNavigation } from 'app/navigation/native'
import { Provider } from 'app/provider'
import { Provider } from 'app/provider/app-providers'
import "expo-dev-client"

export default function App() {
return (
Expand Down
21 changes: 17 additions & 4 deletions apps/expo/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,31 @@
"android"
],
"ios": {
"bundleIdentifier": "io.andfriends.modelo"
"bundleIdentifier": "io.andfriends.modelo",
"googleServicesFile": "../../packages/firebase/config/GoogleService-Info.plist"
},
"android": {
"package": "io.andfriends.modelo",
"googleServicesFile": "../../packages/firebase/config/google-services.json"
},
"plugins": [
[
"expo-build-properties", {
"ios": {
"useFrameworks": "static"
}
}
],
"@react-native-firebase/app"

],
"extra": {
"eas": {
"projectId": "7e95f6d0-5145-4bba-aa65-e5e3d190cdcc"
}
},
"updates": {
"url": "https://u.expo.dev/7e95f6d0-5145-4bba-aa65-e5e3d190cdcc"
},
"android": {
"package": "io.andfriends.modelo"
}
}
}
27 changes: 18 additions & 9 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{
"name": "@modelo/expo",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"@react-native-firebase/analytics": "^17.3.0",
"@react-native-firebase/app": "^17.3.0",
"app": "*",
"expo": "^46.0.0",
"expo-splash-screen": "~0.16.1",
"expo": "~46.0.19",
"expo-build-properties": "~0.3.0",
"expo-dev-client": "~1.3.1",
"expo-splash-screen": "~0.16.2",
"expo-status-bar": "~1.4.0",
"expo-updates": "~0.14.7",
"react": "18.2.0",
"react": "18.0.0",
"react-dom": "18.2.0",
"react-native": "0.69.5",
"react-native": "0.69.6",
"react-native-gesture-handler": "~2.5.0",
"react-native-reanimated": "2.9.1",
"react-native-safe-area-context": "4.3.1",
Expand All @@ -22,11 +29,13 @@
},
"scripts": {
"start": "expo start --dev-client",
"start:ios:device": "eas build --profile development --platform ios && say done",
"start:android": "expo start --android --dev-client",
"android": "expo run:android",
"ios": "expo run:ios"
"ios": "expo run:ios",
"dev:ios-build": "yarn expo:prebuild && yarn ios",
"dev:android-build": "yarn expo:prebuild && yarn android",
"expo:prebuild": "yarn expo prebuild --skip-dependency-update react && yarn react-native"
},
"main": "index.js",
"version": "1.0.0",
"private": true,
"name": "expo-app"
"private": true
}
Empty file added apps/next/.env
Empty file.
2 changes: 1 addition & 1 deletion apps/next/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ yarn-error.log*

# local env files
.env.local
.env.development.local
.env.development
.env.test.local
.env.production.local

Expand Down
4 changes: 4 additions & 0 deletions apps/next/env.local.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add here variables local to your machine, do not check in
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
20 changes: 20 additions & 0 deletions apps/next/env.production.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
NEXT_PUBLIC_FIREBASE_API_KEY=
NEXT_PUBLIC_FIREBASE_PROJECT_ID=
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
NEXT_PUBLIC_FIREBASE_APP_ID=
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
NEXT_PUBLIC_SITE_URL=
NEXT_PUBLIC_APPCHECK_KEY=
NEXT_PUBLIC_REQUIRE_EMAIL_VERIFICATION=false

FIREBASE_CLIENT_EMAIL=
GCLOUD_PROJECT=

## SECRET KEYS ARE BEST ADDED TO YOUR CI
FIREBASE_PRIVATE_KEY=

NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
20 changes: 15 additions & 5 deletions apps/next/next.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { withExpo } = require('@expo/next-adapter')
const withPlugins = require('next-compose-plugins')
const { withExpo } = require('@expo/next-adapter');
const withPlugins = require('next-compose-plugins');
const withTM = require('next-transpile-modules')([
'solito',
'dripsy',
'@dripsy/core',
'moti',
'app',
])
]);

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -21,7 +21,17 @@ const nextConfig = {
forceSwcTransforms: true,
swcPlugins: [[require.resolve('./plugins/swc_plugin_reanimated.wasm')]],
},
}
webpack: (config, options) => {
config.resolve.extensions = [
'.web.js',
'.web.jsx',
'.web.ts',
'.web.tsx',
...(config.resolve?.extensions ?? []),
];
return config;
},
};

module.exports = withPlugins(
[
Expand All @@ -34,4 +44,4 @@ module.exports = withPlugins(
],
],
nextConfig
)
);
6 changes: 4 additions & 2 deletions apps/next/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "next-app",
"name": "@modelo/next",
"version": "0.1.0",
"private": true,
"engines": {
Expand All @@ -14,8 +14,10 @@
"dependencies": {
"@expo/next-adapter": "^4.0.12",
"app": "*",
"firebase": "^9.17.1",
"next": "13.0.1",
"raf": "^3.4.1"
"raf": "^3.4.1",
"reactfire": "^4.2.2"
},
"devDependencies": {
"@types/node": "17.0.21",
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fixReanimatedIssue = () => {

fixReanimatedIssue()

import { Provider } from 'app/provider'
import { Provider } from 'app/provider/app-providers'
import Head from 'next/head'
import React from 'react'
import type { SolitoAppProps } from 'solito'
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-native": "^0.69.5",
"concurrently": "^7.6.0",
"eslint": "^8.21.0",
"turbo": "^1.4.2",
"typescript": "^4.7.4"
},
"scripts": {
"native": "cd apps/expo && expo start",
"web": "cd apps/next && yarn next"
"web": "cd apps/next && yarn next",
"run:next": "yarn turbo dev --filter=@modelo/next",
"run:expo": "yarn workspace @modelo/expo start",
"build:ios": "turbo run dev:ios-build --parallel --no-cache --filter=@modelo/expo",
"build:android": "turbo run dev:android-build --parallel --no-cache --filter=@modelo/expo"

}
}
7 changes: 7 additions & 0 deletions packages/app/hooks/use-analytics-tracking.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useTrackScreenViews } from './use-track-screen-views';
import { useTrackSignedInUser } from './use-track-signed-in-user';

export function useAnalyticsTracking() {
useTrackScreenViews();
useTrackSignedInUser();
}
29 changes: 29 additions & 0 deletions packages/app/hooks/use-track-screen-views.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useCallback, useEffect } from 'react';
import Router from 'next/router';

// import { isBrowser } from '~/core/generic/is-browser';

/**
* @name useTrackScreenViews
* @description tracks screens to Analytics when a new route is loaded
*/
export function useTrackScreenViews() {
console.log('[useTrackScreenViews]');
const onRouteChangeComplete = useCallback(async () => {
// if (!isBrowser()) {
// return;
// }
const { getAnalytics, logEvent } = await import('firebase/analytics');
const title = document.title;
logEvent(getAnalytics(), 'screen_view', {
firebase_screen: title,
firebase_screen_class: title,
});
}, []);
useEffect(() => {
Router.events.on('routeChangeComplete', onRouteChangeComplete);
return () => {
Router.events.off('routeChangeComplete', onRouteChangeComplete);
};
}, [onRouteChangeComplete]);
}
25 changes: 25 additions & 0 deletions packages/app/hooks/use-track-signed-in-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// import { useEffect } from 'react';

// import { isBrowser } from '~/core/generic/is-browser';
// import { useUserSession } from '~/core/hooks/use-user-session';

/**
* @name useTrackSignedInUser
* @description tracks the current user ID
*/
export function useTrackSignedInUser() {
console.log('[useTrackSignedInUser]');
// const user = useUserSession();
// const userId = user?.auth?.uid;
// useEffect(() => {
// if (!isBrowser()) {
// return;
// }
// void (async () => {
// const { getAnalytics, setUserId } = await import('firebase/analytics');
// if (userId) {
// setUserId(getAnalytics(), userId);
// }
// })();
// }, [userId]);
}
16 changes: 16 additions & 0 deletions packages/app/provider/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const config = {
firebase: {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
},
environment: process.env.NEXT_PUBLIC_VERCEL_ENV ?? 'development',
emulatorHost: process.env.NEXT_PUBLIC_EMULATOR_HOST,
emulator: process.env.NEXT_PUBLIC_EMULATOR === 'true',
production: process.env.NODE_ENV === 'production',
};
export default config;
38 changes: 38 additions & 0 deletions packages/app/provider/firebase/FirebaseAnalyticsProvider.web.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {AnalyticsProvider, useInitAnalytics} from 'reactfire';
import config from '../config'
import { useAnalyticsTracking } from 'app/hooks/use-analytics-tracking';

function FirebaseAnalyticsProvider({children}: React.PropsWithChildren){
return <BrowserFirebaseAnalyticsProvider>{children}</BrowserFirebaseAnalyticsProvider>

}

function BrowserFirebaseAnalyticsProvider(props: React.PropsWithChildren){
const {data: sdk, status} = useInitAnalytics(async (app) =>{
const {getAnalytics} = await import('firebase/analytics');
return getAnalytics(app);
});

if(status !== 'success'){
return <>{props.children}</>
}

return (
<AnalyticsProvider sdk={sdk}>
<AnalyticsTrackingEventsProvider>
{props.children}
</AnalyticsTrackingEventsProvider>
</AnalyticsProvider>
);

}

function AnalyticsTrackingEventsProvider({
children
}: React.PropsWithChildren){
useAnalyticsTracking();
return <>{children}</>
}


export {FirebaseAnalyticsProvider}
17 changes: 17 additions & 0 deletions packages/app/provider/firebase/FirebaseAppShell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { FirebaseOptions } from 'firebase/app';
import { FirebaseAppProvider } from 'reactfire';

function FirebaseAppShell({
children,
config,
}:React.PropsWithChildren<{
config: FirebaseOptions;
}>){
return (
<FirebaseAppProvider firebaseConfig={config}>
{children}
</FirebaseAppProvider>
)
}

export { FirebaseAppShell }
10 changes: 0 additions & 10 deletions packages/app/provider/index.tsx

This file was deleted.

Loading