feat: turbostarter boilerplate
Production-ready Next.js boilerplate with: - Runtime env validation (fail-fast on missing vars) - Feature-gated config (S3, Stripe, email, OAuth) - Docker + Coolify deployment pipeline - PostgreSQL + pgvector, MinIO S3, Better Auth - TypeScript strict mode (no ignoreBuildErrors) - i18n (en/es), AI modules, billing, monitoring Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1
packages/monitoring/mobile/src/env.ts
Normal file
1
packages/monitoring/mobile/src/env.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { env, preset } from "./providers";
|
||||
1
packages/monitoring/mobile/src/index.ts
Normal file
1
packages/monitoring/mobile/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { captureException, identify, initialize } from "./providers";
|
||||
2
packages/monitoring/mobile/src/providers/index.ts
Normal file
2
packages/monitoring/mobile/src/providers/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./posthog";
|
||||
export * from "./posthog/env";
|
||||
29
packages/monitoring/mobile/src/providers/posthog/env.ts
Normal file
29
packages/monitoring/mobile/src/providers/posthog/env.ts
Normal 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,
|
||||
},
|
||||
});
|
||||
39
packages/monitoring/mobile/src/providers/posthog/index.ts
Normal file
39
packages/monitoring/mobile/src/providers/posthog/index.ts
Normal 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;
|
||||
28
packages/monitoring/mobile/src/providers/sentry/env.ts
Normal file
28
packages/monitoring/mobile/src/providers/sentry/env.ts
Normal 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,
|
||||
},
|
||||
});
|
||||
45
packages/monitoring/mobile/src/providers/sentry/index.ts
Normal file
45
packages/monitoring/mobile/src/providers/sentry/index.ts
Normal 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;
|
||||
Reference in New Issue
Block a user