diff --git a/devvit.json b/devvit.json index a36d99b..c854de0 100644 --- a/devvit.json +++ b/devvit.json @@ -32,6 +32,7 @@ ] }, "permissions": { + "journeys": true, "reddit": { "enable": true, "asUser": ["SUBMIT_POST", "SUBMIT_COMMENT", "SUBSCRIBE_TO_SUBREDDIT"] diff --git a/package.json b/package.json index a8409ed..e7298cb 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "node": ">=24.0.0" }, "dependencies": { + "@devvit/analytics": "0.13.11", "@devvit/start": "0.13.11", "@devvit/test": "0.13.11", "@devvit/web": "0.13.11", diff --git a/src/client/game.tsx b/src/client/game.tsx index 1683daa..4126cd4 100644 --- a/src/client/game.tsx +++ b/src/client/game.tsx @@ -3,6 +3,7 @@ import './index.css'; import { StrictMode, useEffect, useState } from 'react'; import { createRoot } from 'react-dom/client'; import { navigateTo } from '@devvit/web/client'; +import { getJourneyId } from './journeys'; import { trpc } from './trpc'; import type { inferRouterOutputs } from '@trpc/server'; import type { AppRouter } from '../server/trpc'; @@ -27,14 +28,18 @@ export const App = () => { const increment = async () => { setLoading(true); - const result = await trpc.counter.increment.mutate(); + const result = await trpc.counter.increment.mutate({ + journeyId: getJourneyId(), + }); setInit((prev) => (prev ? { ...prev, count: result.count } : null)); setLoading(false); }; const decrement = async () => { setLoading(true); - const result = await trpc.counter.decrement.mutate(); + const result = await trpc.counter.decrement.mutate({ + journeyId: getJourneyId(), + }); setInit((prev) => (prev ? { ...prev, count: result.count } : null)); setLoading(false); }; @@ -79,21 +84,21 @@ export const App = () => {