Skip to content

Commit 61bab2e

Browse files
authored
Add PostHog capture for reified relations (#758)
1 parent 93ea74e commit 61bab2e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

apps/roam/src/components/settings/AdminPanel.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import refreshConfigTree from "~/utils/refreshConfigTree";
3737
import createBlock from "roamjs-components/writes/createBlock";
3838
import deleteBlock from "roamjs-components/writes/deleteBlock";
3939
import { USE_REIFIED_RELATIONS } from "~/data/userSettings";
40+
import posthog from "posthog-js";
4041

4142
const NodeRow = ({ node }: { node: PConceptFull }) => {
4243
return (
@@ -265,6 +266,9 @@ const MigrationTab = (): React.ReactElement => {
265266
const doMigrateRelations = async () => {
266267
setOngoing(true);
267268
try {
269+
posthog.capture("Reified Relations: Migration Started", {
270+
dryRun: useDryRun,
271+
});
268272
const before = await countReifiedRelations();
269273
const numProcessed = await migrateRelations(useDryRun);
270274
const after = await countReifiedRelations();
@@ -273,11 +277,22 @@ const MigrationTab = (): React.ReactElement => {
273277
`${after - before} new relations created out of ${numProcessed} distinct relations processed`,
274278
);
275279
else setMigrationResults(`${numProcessed} new relations created`);
280+
posthog.capture("Reified Relations: Migration Completed", {
281+
dryRun: useDryRun,
282+
processed: numProcessed,
283+
before,
284+
after,
285+
created: after - before,
286+
});
276287
} catch (e) {
277288
console.error("Relation migration failed", e);
278289
setMigrationResults(
279290
`Migration failed: ${(e as Error).message ?? "see console for details"}`,
280291
);
292+
posthog.capture("Reified Relations: Migration Failed", {
293+
dryRun: useDryRun,
294+
error: (e as Error).message ?? "unknown error",
295+
});
281296
} finally {
282297
setOngoing(false);
283298
}
@@ -432,6 +447,9 @@ const FeatureFlagsTab = (): React.ReactElement => {
432447
void setSetting(USE_REIFIED_RELATIONS, target.checked).catch(
433448
() => undefined,
434449
);
450+
posthog.capture("Reified Relations: Toggled", {
451+
enabled: target.checked,
452+
});
435453
}}
436454
labelElement={
437455
<>

0 commit comments

Comments
 (0)