Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"experimentalSortImports": {
"groups": [
["side-effect"],
["builtin"],
["external", "type-external"],
["internal", "type-internal"],
["parent", "type-parent"],
["sibling", "type-sibling"],
["index", "type-index"]
],
"newlinesBetween": false
}
}
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"[markdown]": {
"[markdown,mdx]": {
"editor.detectIndentation": true,
"editor.insertSpaces": false,
"editor.indentSize": "tabSize",
"editor.tabSize": 4
}
},
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file"
}
26 changes: 17 additions & 9 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
This is the **Talo documentation website**, built with Docusaurus. Talo is an open-source game backend that provides features like player management, event tracking, leaderboards, game saves, stats, and feedback for Godot and Unity games.

The documentation is organized into several main sections:

- **Unity**: Unity package documentation (`docs/unity/`)
- **Godot**: Godot plugin documentation (`docs/godot/`)
- **HTTP API**: REST API reference documentation (`docs/http/`)
Expand All @@ -17,24 +18,31 @@ The documentation is organized into several main sections:
## Development Commands

**Start development server:**

```bash
npm start
```

This starts a local development server on port 3009 with live reload.

**Build for production:**

```bash
npm run build
```

Generates static content in the `build/` directory.

**Clear cache:**

```bash
npm clear
```

Clears the Docusaurus cache (useful when experiencing build issues).

**Serve production build locally:**

```bash
npm run serve
```
Expand All @@ -45,14 +53,13 @@ npm run serve

The HTTP API documentation uses a unique architecture that fetches live API route definitions from the Talo backend:

1. **`docusaurus.config.js`**: During build/start, fetches API route metadata from `https://api.trytalo.com/public/docs` (or `http://localhost:3000` in development) and stores it in `customFields.docs.services`
1. **`docusaurus.config.ts`**: During build/start, fetches API route metadata from `https://api.trytalo.com/public/docs` (or `http://localhost:3000` in development) and stores it in `customFields.docs.services`

2. **Service Documentation Components** (`src/components/documentation/`):
- `ServiceDocumentation.js`: React component that renders API routes from the fetched metadata as interactive documentation
- `ServiceDocumentationWithTOC.js`: Variant with table of contents
- `generateServiceTOC.js`: Generates table of contents from service routes
- `useServiceDocs.js`: Hook to access service data from Docusaurus context
- `Sample.js`: Renders code samples for API endpoints
- `ServiceDocumentation.tsx`: React component that renders API routes from the fetched metadata as interactive documentation
- `generateServiceTOC.ts`: Generates table of contents from service routes
- `useServiceDocs.ts`: Hook to access service data from Docusaurus context
- `Sample.tsx`: Renders code samples for API endpoints

3. **MDX Files** (`docs/http/*.mdx`): Use the `<ServiceDocumentation service='ServiceName' />` component to render live API docs. Examples: `event-api.mdx`, `game-channel-api.mdx`, etc.

Expand All @@ -62,7 +69,7 @@ The benefit of this architecture is that API documentation automatically stays i

- **Markdown files** (`docs/**/*.md`): Standard documentation pages written in Markdown
- **MDX files** (`docs/**/*.mdx`): Documentation pages that use React components (primarily for API docs)
- **Sidebars** (`sidebars.js`): Uses Docusaurus auto-generated sidebars from the directory structure
- **Sidebars** (`sidebars.ts`): Uses Docusaurus auto-generated sidebars from the directory structure
- **Static assets** (`static/`): Images and other static files referenced in docs

### Node Version
Expand All @@ -72,6 +79,7 @@ This project requires **Node.js 20.x** (specified in `package.json` engines fiel
## Documentation Conventions

- Use frontmatter for page metadata:

```yaml
---
sidebar_position: 1
Expand All @@ -81,9 +89,9 @@ This project requires **Node.js 20.x** (specified in `package.json` engines fiel

- Cross-reference other docs using relative paths: `/docs/unity/install`

- Include code samples in fenced code blocks with language identifiers (e.g., ```csharp, ```gdscript, ```bash)
- Include code samples in fenced code blocks with language identifiers (e.g., ` ```csharp `, ` ```gdscript `, ` ```bash `)

- The site supports C# and GDScript syntax highlighting via Prism (configured in `docusaurus.config.js`)
- The site supports C# and GDScript syntax highlighting via Prism (configured in `docusaurus.config.ts`)

## Important Notes

Expand Down
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/godot/channels.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ var is_last_page := members_page.is_last_page
```

You can provide the following filtering options:

- `page`: the current pagination index
- `player_id`: find channel members with this player ID
- `alias_id`: find a channel member with this ID
Expand Down Expand Up @@ -234,6 +235,7 @@ func _on_message_received(channel: TaloChannel, player_alias: TaloPlayerAlias, m
### Listening for other signals

You can also listen for the following signals:

- `Talo.channels.player_joined`: Emitted when a player joins a channel. Returns the `TaloChannel` and the `TaloPlayerAlias` that joined.

- `Talo.channels.player_left`: Emitted when a player leaves a channel. Returns the `TaloChannel`, the `TaloPlayerAlias` that left and a `Talo.channels.ChannelLeavingReason`.
Expand Down
1 change: 1 addition & 0 deletions docs/godot/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Events are sent off in batches to prevent issues around rate limiting or using t
## Meta props

Talo sends through some extra props with each event. These props are made up of the following metadata:

- The player's operating system
- The version of the game
- The window mode (fullscreen, fullscreen windowed, maximized window or windowed)
Expand Down
1 change: 1 addition & 0 deletions docs/godot/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ socket_url="wss://api.trytalo.com"
```

You can also add the following section for logging:

```gdscript title="addons/talo/settings.cfg"
...

Expand Down
1 change: 0 additions & 1 deletion docs/godot/leaderboards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ To create a leaderboard, head over to [the dashboard](https://dashboard.trytalo.
Check out this blog post on [how to build quick & easy leaderboards in Godot](https://trytalo.com/blog/leaderboards-godot?utm_source=docs&utm_medium=tip) for a detailed walkthrough
:::


## Creating entries

<ScopeBadges scope='leaderboards' write />
Expand Down
3 changes: 2 additions & 1 deletion docs/godot/player-authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Once a player is registered, a session will automatically be created for them an
To start a session, call the `Talo.player_auth.login()` function with the username and password the player provided.

The `login()` function returns a `Talo.player_auth.LoginResult` which maps to:

1. A successful login
2. A successful login but the player must verify their details before creating the session
3. An unsuccessful login attempt
Expand Down Expand Up @@ -142,7 +143,7 @@ if res != OK:
TaloAuthError.ErrorCode.NEW_PASSWORD_MATCHES_CURRENT_PASSWORD:
validation_label.text = "New password must be different from the current password"
_:
validation_label.text = Talo.player_auth.last_error.get_string()
validation_label.text = Talo.player_auth.last_error.get_string()
else:
password_change_success.emit()
```
Expand Down
2 changes: 1 addition & 1 deletion docs/godot/player-presence.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var res := await Talo.player_presence.update_presence(online, custom_status)

This function returns a `TaloPlayerPresence` object.

## Subscribing to presence
## Subscribing to presence

<ScopeBadges scope='playerPresence' read />

Expand Down
3 changes: 2 additions & 1 deletion docs/godot/saves.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Check out this blog post on [how to save and load data in Godot](https://trytalo
## Saves demos

As part of the Godot plugin, we've included a few demos to help you get started:

1. [Playground saves](https://github.com/TaloDev/godot/tree/develop/addons/talo/samples/playground) - allows you to create/load/update/delete a very basic save
2. [Persistent buttons](https://github.com/TaloDev/godot/tree/develop/addons/talo/samples/persistent_buttons) - a simple demo focused on saving/loading functionality
3. [Scene-based saves](https://github.com/TaloDev/godot/tree/develop/addons/talo/samples/multiscene_saves) - a full demo showing how data gets persisted between scenes with a player and other loadables
Expand All @@ -28,7 +29,7 @@ Talo's game saves let you easily save and load specific nodes in your game. To d
Once a loadable has entered the tree, its `_ready()` function registers it with the saves manager. We need to register all the Loadables in the scene so that when we load our save, we can match the content in the save file with the structure of the scene.

:::caution
If your loadable overrides the `_ready()` function, ensure that it contains `super()` so that Talo can still register the loadable.
If your loadable overrides the `_ready()` function, ensure that it contains `super()` so that Talo can still register the loadable.
:::

Importantly, each Loadable _must_ have a unique `id` so that Talo knows which node to load with which data. This can be set in the inspector or in the code.
Expand Down
1 change: 1 addition & 0 deletions docs/http/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ curl \
## Player authentication

When calling API endpoints on behalf of a player that is using [player authentication](https://trytalo.com/players#authentication) you must send the following headers:

1. `x-talo-player`: the ID of the player
2. `x-talo-alias`: the ID of the player's identified alias
3. `x-talo-session`: the session token received after registering or logging-in a player
Expand Down
15 changes: 8 additions & 7 deletions docs/http/event-api.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import ServiceDocumentation from '@site/src/components/documentation/ServiceDocumentation'
import siteConfig from '@generated/docusaurus.config'
import { ServiceDocumentation } from '@site/src/components/documentation/ServiceDocumentation'
import { generateServiceTOC } from '@site/src/components/documentation/generateServiceTOC'

# Event API

export const service = 'EventAPI'

export const toc = [
{ value: 'Endpoints', id: 'endpoints', level: 2 },
...generateServiceTOC('EventAPIService', siteConfig),
...generateServiceTOC(service),
{ value: 'Types', id: 'types', level: 2 },
{ value: 'EventData', id: 'eventdata', level: 3 }
{ value: 'EventData', id: 'eventdata', level: 3 },
]

Event tracking lets you get rid of the guess-work. By tracking important actions when they happen, you're able to gauge how well a mechanic is being used and even track the overall progress of your players. See how often potions get used, items get bought and how many level-ups there are per day, month or year.
Expand All @@ -18,7 +19,7 @@ Learn more about events <a href='https://trytalo.com/events?utm_source=docs&utm_
## Endpoints

<ServiceDocumentation
service='EventAPIService'
service={service}
metaDescription="Talo Events let you easily track and analyse player engagement in your game. See what players like the most and what they're missing."
/>

Expand All @@ -28,8 +29,8 @@ Learn more about events <a href='https://trytalo.com/events?utm_source=docs&utm_

```ts
type EventData = {
name: string // name of the event
timestamp: number // UNIX milisecond timestamp, e.g. 1656971058297
name: string // name of the event
timestamp: number // UNIX milisecond timestamp, e.g. 1656971058297
props?: Prop[]
}

Expand Down
11 changes: 6 additions & 5 deletions docs/http/game-channel-api.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import ServiceDocumentation from '@site/src/components/documentation/ServiceDocumentation'
import siteConfig from '@generated/docusaurus.config'
import { ServiceDocumentation } from '@site/src/components/documentation/ServiceDocumentation'
import { generateServiceTOC } from '@site/src/components/documentation/generateServiceTOC'

# Game channel API

export const service = 'GameChannelAPI'

export const toc = [
{ value: 'Endpoints', id: 'endpoints', level: 2 },
...generateServiceTOC('GameChannelAPIService', siteConfig),
...generateServiceTOC(service),
{ value: 'Types', id: 'types', level: 2 },
{ value: 'Prop', id: 'prop', level: 3 }
{ value: 'Prop', id: 'prop', level: 3 },
]

Channels are a way to send messages between players in your game. You can use channels to create chat rooms, send notifications or create any other kind of messaging system you can think of.
Expand All @@ -18,7 +19,7 @@ Learn more about channels [here](https://trytalo.com/channels?utm_source=docs&ut
## Endpoints

<ServiceDocumentation
service='GameChannelAPIService'
service={service}
metaDescription="Talo's Game Channel service lets you create channels for your game. Channels can be used for chat rooms, notifications and more."
/>

Expand Down
9 changes: 5 additions & 4 deletions docs/http/game-config-api.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import ServiceDocumentation from '@site/src/components/documentation/ServiceDocumentation'
import siteConfig from '@generated/docusaurus.config'
import { ServiceDocumentation } from '@site/src/components/documentation/ServiceDocumentation'
import { generateServiceTOC } from '@site/src/components/documentation/generateServiceTOC'

# Game config API

export const service = 'GameConfigAPI'

export const toc = [
{ value: 'Endpoints', id: 'endpoints', level: 2 },
...generateServiceTOC('GameConfigAPIService', siteConfig)
...generateServiceTOC(service),
]

Talo's live config allows you to configure your game directly in the dashboard. Your game can then fetch this config on-demand, allowing your game and players to have the latest information without downloading a new update.
Expand All @@ -18,6 +19,6 @@ Learn more about live config [here](https://trytalo.com/live-config?utm_source=d
## Endpoints

<ServiceDocumentation
service='GameConfigAPIService'
service={service}
metaDescription="Talo's live config lets you update your game's easily configure events, tests and updates to your game directly from the web."
/>
9 changes: 5 additions & 4 deletions docs/http/game-feedback-api.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import ServiceDocumentation from '@site/src/components/documentation/ServiceDocumentation'
import siteConfig from '@generated/docusaurus.config'
import { ServiceDocumentation } from '@site/src/components/documentation/ServiceDocumentation'
import { generateServiceTOC } from '@site/src/components/documentation/generateServiceTOC'

# Game feedback API

export const service = 'GameFeedbackAPI'

export const toc = [
{ value: 'Endpoints', id: 'endpoints', level: 2 },
...generateServiceTOC('GameFeedbackAPIService', siteConfig)
...generateServiceTOC(service),
]

Using Talo's Feedback service, you can effortlessly collect valuable player feedback to improve your game's experience. Players can send feedback directly from within the game, providing insights that can help you understand their needs and preferences better.
Expand All @@ -16,6 +17,6 @@ Learn more about feedback [here](https://trytalo.com/feedback?utm_source=docs&ut
## Endpoints

<ServiceDocumentation
service='GameFeedbackAPIService'
service={service}
metaDescription="Talo's Feedback service lets you easily collect feedback directly from your players. Categories can be configured to help segment feedback."
/>
15 changes: 8 additions & 7 deletions docs/http/game-save-api.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import ServiceDocumentation from '@site/src/components/documentation/ServiceDocumentation'
import siteConfig from '@generated/docusaurus.config'
import { ServiceDocumentation } from '@site/src/components/documentation/ServiceDocumentation'
import { generateServiceTOC } from '@site/src/components/documentation/generateServiceTOC'

# Game save API

export const service = 'GameSaveAPI'

export const toc = [
{ value: 'Endpoints', id: 'endpoints', level: 2 },
...generateServiceTOC('GameSaveAPIService', siteConfig),
...generateServiceTOC(service),
{ value: 'Types', id: 'types', level: 2 },
{ value: 'SaveContent', id: 'savecontent', level: 3 }
{ value: 'SaveContent', id: 'savecontent', level: 3 },
]

Talo's save system allows you to persist your game's state across multiple sessions. Each object in your scene can be saved and restored automatically from one of your player's saves.
Expand All @@ -18,7 +19,7 @@ Learn more about game saves [here](https://trytalo.com/saves?utm_source=docs&utm
## Endpoints

<ServiceDocumentation
service='GameSaveAPIService'
service={service}
metaDescription="Talo's Game Save service lets you save and load game data. Saves work both online and offline and will automatically sync when the player is back online."
/>

Expand All @@ -33,13 +34,13 @@ type SaveContent = {

type SavedObject = {
id: UUID
name: string // e.g. Unity GameObject hierarchy name
name: string // e.g. Unity GameObject hierarchy name
data: SavedObjectData[]
}

type SavedObjectData = {
key: string
value: string
type: string // class to cast value to on-load, e.g. System.Boolean in C#
type: string // class to cast value to on-load, e.g. System.Boolean in C#
}
```
Loading