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:
24
packages/analytics/web/src/providers/vemetric/env.ts
Normal file
24
packages/analytics/web/src/providers/vemetric/env.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/* 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: "vemetric",
|
||||
client: {
|
||||
NEXT_PUBLIC_VEMETRIC_PROJECT_TOKEN: z.string(),
|
||||
},
|
||||
} as const satisfies Preset;
|
||||
|
||||
export const env = defineEnv({
|
||||
...envConfig,
|
||||
...preset,
|
||||
env: {
|
||||
...process.env,
|
||||
NEXT_PUBLIC_VEMETRIC_PROJECT_TOKEN:
|
||||
process.env.NEXT_PUBLIC_VEMETRIC_PROJECT_TOKEN,
|
||||
},
|
||||
});
|
||||
49
packages/analytics/web/src/providers/vemetric/index.tsx
Normal file
49
packages/analytics/web/src/providers/vemetric/index.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import { VemetricScript, vemetric } from "@vemetric/react";
|
||||
|
||||
import { env } from "./env";
|
||||
|
||||
import type { AnalyticsProviderClientStrategy } from "@turbostarter/analytics";
|
||||
|
||||
export const { Provider, track, identify, reset } = {
|
||||
Provider: ({ children }) => {
|
||||
return (
|
||||
<>
|
||||
<VemetricScript
|
||||
token={env.NEXT_PUBLIC_VEMETRIC_PROJECT_TOKEN}
|
||||
trackPageViews
|
||||
trackOutboundLinks
|
||||
trackDataAttributes
|
||||
/>
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
},
|
||||
track: (event, data) => {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
void vemetric.trackEvent(event, {
|
||||
eventData: data,
|
||||
});
|
||||
},
|
||||
identify: (userId, traits) => {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
void vemetric.identify({
|
||||
identifier: userId,
|
||||
data: {
|
||||
set: traits,
|
||||
},
|
||||
});
|
||||
},
|
||||
reset: () => {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
void vemetric.resetUser();
|
||||
},
|
||||
} satisfies AnalyticsProviderClientStrategy;
|
||||
30
packages/analytics/web/src/providers/vemetric/server.ts
Normal file
30
packages/analytics/web/src/providers/vemetric/server.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Vemetric } from "@vemetric/node";
|
||||
|
||||
import { env } from "./env";
|
||||
|
||||
import type { AnalyticsProviderServerStrategy } from "@turbostarter/analytics";
|
||||
|
||||
let client: Vemetric | null = null;
|
||||
|
||||
const getClient = () => {
|
||||
if (client) {
|
||||
return client;
|
||||
}
|
||||
|
||||
client = new Vemetric({
|
||||
token: env.NEXT_PUBLIC_VEMETRIC_PROJECT_TOKEN,
|
||||
});
|
||||
|
||||
return client;
|
||||
};
|
||||
|
||||
export const { track } = {
|
||||
track: (event, data) => {
|
||||
const client = getClient();
|
||||
|
||||
void client.trackEvent(event, {
|
||||
userIdentifier: data?.distinctId?.toString() ?? "anonymous",
|
||||
eventData: data,
|
||||
});
|
||||
},
|
||||
} satisfies AnalyticsProviderServerStrategy;
|
||||
Reference in New Issue
Block a user