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:
27
packages/analytics/web/src/providers/open-panel/env.ts
Normal file
27
packages/analytics/web/src/providers/open-panel/env.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/* 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: "open-panel",
|
||||
client: {
|
||||
NEXT_PUBLIC_OPEN_PANEL_CLIENT_ID: z.string(),
|
||||
},
|
||||
server: {
|
||||
OPEN_PANEL_SECRET: z.string(),
|
||||
},
|
||||
} as const satisfies Preset;
|
||||
|
||||
export const env = defineEnv({
|
||||
...envConfig,
|
||||
...preset,
|
||||
env: {
|
||||
...process.env,
|
||||
NEXT_PUBLIC_OPEN_PANEL_CLIENT_ID:
|
||||
process.env.NEXT_PUBLIC_OPEN_PANEL_CLIENT_ID,
|
||||
},
|
||||
});
|
||||
45
packages/analytics/web/src/providers/open-panel/index.tsx
Normal file
45
packages/analytics/web/src/providers/open-panel/index.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { OpenPanelComponent } from "@openpanel/nextjs";
|
||||
|
||||
import { env } from "./env";
|
||||
|
||||
import type { AnalyticsProviderClientStrategy } from "@turbostarter/analytics";
|
||||
|
||||
export const { Provider, track, identify, reset } = {
|
||||
Provider: ({ children }) => {
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
<OpenPanelComponent
|
||||
clientId={env.NEXT_PUBLIC_OPEN_PANEL_CLIENT_ID}
|
||||
trackScreenViews
|
||||
trackAttributes
|
||||
trackOutgoingLinks
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
track: (event, data) => {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
window.op("track", event, data);
|
||||
},
|
||||
identify: (userId, traits) => {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
window.op("identify", {
|
||||
profileId: userId,
|
||||
...traits,
|
||||
});
|
||||
},
|
||||
reset: () => {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
window.op("clear");
|
||||
},
|
||||
} satisfies AnalyticsProviderClientStrategy;
|
||||
28
packages/analytics/web/src/providers/open-panel/server.ts
Normal file
28
packages/analytics/web/src/providers/open-panel/server.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { OpenPanel } from "@openpanel/nextjs";
|
||||
|
||||
import { env } from "./env";
|
||||
|
||||
import type { AnalyticsProviderServerStrategy } from "@turbostarter/analytics";
|
||||
|
||||
let client: OpenPanel | null = null;
|
||||
|
||||
const getClient = () => {
|
||||
if (client) {
|
||||
return client;
|
||||
}
|
||||
|
||||
client = new OpenPanel({
|
||||
clientId: env.NEXT_PUBLIC_OPEN_PANEL_CLIENT_ID,
|
||||
clientSecret: env.OPEN_PANEL_SECRET,
|
||||
});
|
||||
|
||||
return client;
|
||||
};
|
||||
|
||||
export const { track } = {
|
||||
track: (event, data) => {
|
||||
const client = getClient();
|
||||
|
||||
void client.track(event, data);
|
||||
},
|
||||
} satisfies AnalyticsProviderServerStrategy;
|
||||
Reference in New Issue
Block a user