feat(db): mesh data model — meshes, members, invites, audit log
- pgSchema "mesh" with 4 tables isolating the peer mesh domain - Enums: visibility, transport, tier, role - audit_log is metadata-only (E2E encryption enforced at broker/client) - Cascade on mesh delete, soft-delete via archivedAt/revokedAt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
3
packages/monitoring/mobile/eslint.config.js
Normal file
3
packages/monitoring/mobile/eslint.config.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import baseConfig from "@turbostarter/eslint-config/base";
|
||||
|
||||
export default baseConfig;
|
||||
32
packages/monitoring/mobile/package.json
Normal file
32
packages/monitoring/mobile/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
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;
|
||||
6
packages/monitoring/mobile/tsconfig.json
Normal file
6
packages/monitoring/mobile/tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "@turbostarter/tsconfig/internal.json",
|
||||
"compilerOptions": {},
|
||||
"include": ["*.ts", "src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user