feat: whyrating - initial project from turbostarter boilerplate

This commit is contained in:
Alejandro Gutiérrez
2026-02-04 01:54:52 +01:00
commit 5cdc07cd39
1618 changed files with 338230 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import baseConfig from "@turbostarter/eslint-config/base";
export default baseConfig;

View File

@@ -0,0 +1,32 @@
{
"name": "@turbostarter/monitoring-mobile",
"version": "0.1.0",
"private": true,
"type": "module",
"exports": {
".": "./src/index.ts",
"./env": "./src/env.ts"
},
"scripts": {
"clean": "git clean -xdf .cache .turbo dist node_modules",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint",
"typecheck": "tsc --noEmit"
},
"prettier": "@turbostarter/prettier-config",
"devDependencies": {
"@turbostarter/eslint-config": "workspace:*",
"@turbostarter/prettier-config": "workspace:*",
"@turbostarter/tsconfig": "workspace:*",
"eslint": "catalog:",
"prettier": "catalog:",
"typescript": "catalog:"
},
"dependencies": {
"@sentry/react-native": "7.7.0",
"@turbostarter/monitoring": "workspace:*",
"@turbostarter/shared": "workspace:*",
"envin": "catalog:",
"posthog-react-native": "4.14.3"
}
}

View File

@@ -0,0 +1 @@
export { env, preset } from "./providers";

View File

@@ -0,0 +1 @@
export { captureException, identify, initialize } from "./providers";

View File

@@ -0,0 +1,2 @@
export * from "./posthog";
export * from "./posthog/env";

View File

@@ -0,0 +1,29 @@
/* eslint-disable turbo/no-undeclared-env-vars */
import { defineEnv } from "envin";
import * as z from "zod";
import { envConfig } from "@turbostarter/shared/constants";
import type { Preset } from "envin/types";
export const preset = {
id: "posthog",
clientPrefix: "EXPO_PUBLIC_",
client: {
EXPO_PUBLIC_POSTHOG_KEY: z.string(),
EXPO_PUBLIC_POSTHOG_HOST: z
.string()
.optional()
.default("https://us.i.posthog.com"),
},
} as const satisfies Preset;
export const env = defineEnv({
...envConfig,
...preset,
env: {
...process.env,
EXPO_PUBLIC_POSTHOG_KEY: process.env.EXPO_PUBLIC_POSTHOG_KEY,
EXPO_PUBLIC_POSTHOG_HOST: process.env.EXPO_PUBLIC_POSTHOG_HOST,
},
});

View File

@@ -0,0 +1,39 @@
import { PostHog } from "posthog-react-native";
import { env } from "./env";
import type { MonitoringProviderStrategy } from "@turbostarter/monitoring";
let client: PostHog | null = null;
const getClient = () => {
client ??= new PostHog(env.EXPO_PUBLIC_POSTHOG_KEY, {
host: env.EXPO_PUBLIC_POSTHOG_HOST,
errorTracking: {
autocapture: {
uncaughtExceptions: true,
unhandledRejections: true,
console: ["error", "warn"],
},
},
});
return client;
};
export const { captureException, identify, initialize } = {
captureException: (exception) => {
const posthog = getClient();
posthog.captureException(exception);
},
identify: <T extends { id: string }>(user: T | null) => {
const posthog = getClient();
if (user) {
posthog.identify(user.id);
} else {
posthog.reset();
}
},
initialize: () => {
/* PostHog is initialized in the app */
},
} satisfies MonitoringProviderStrategy;

View File

@@ -0,0 +1,28 @@
/* eslint-disable turbo/no-undeclared-env-vars */
import { defineEnv } from "envin";
import * as z from "zod";
import { envConfig, NodeEnv } from "@turbostarter/shared/constants";
import type { Preset } from "envin/types";
export const preset = {
id: "sentry",
clientPrefix: "EXPO_PUBLIC_",
client: {
EXPO_PUBLIC_SENTRY_DSN: z.string(),
EXPO_PUBLIC_SENTRY_ENVIRONMENT: z
.string()
.default(process.env.APP_ENV ?? NodeEnv.DEVELOPMENT),
},
} as const satisfies Preset;
export const env = defineEnv({
...envConfig,
...preset,
env: {
...process.env,
EXPO_PUBLIC_SENTRY_DSN: process.env.EXPO_PUBLIC_SENTRY_DSN,
EXPO_PUBLIC_SENTRY_ENVIRONMENT: process.env.EXPO_PUBLIC_SENTRY_ENVIRONMENT,
},
});

View File

@@ -0,0 +1,45 @@
import * as Sentry from "@sentry/react-native";
import { env } from "./env";
import type { MonitoringProviderStrategy } from "@turbostarter/monitoring";
export const { captureException, identify, initialize } = {
captureException: (exception) => {
Sentry.captureException(exception);
},
identify: (user: Sentry.User | null) => {
Sentry.setUser(user);
},
initialize: () => {
const environment = env.EXPO_PUBLIC_SENTRY_ENVIRONMENT;
Sentry.init({
dsn: env.EXPO_PUBLIC_SENTRY_DSN,
environment,
// Replay may only be enabled for the client-side
integrations: [
// add your desired integrations here
// https://docs.sentry.io/platforms/javascript/configuration/integrations/
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
// Adds more context data to events (IP address, cookies, user, etc.)
// For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/
sendDefaultPii: true,
// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps,
});
},
} satisfies MonitoringProviderStrategy;

View File

@@ -0,0 +1,6 @@
{
"extends": "@turbostarter/tsconfig/internal.json",
"compilerOptions": {},
"include": ["*.ts", "src/**/*"],
"exclude": ["node_modules"]
}