Skip to content

Commit

Permalink
docs: exaplain where userId comes from
Browse files Browse the repository at this point in the history
  • Loading branch information
nperez0111 committed Nov 22, 2024
1 parent e275565 commit f726a93
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
7 changes: 7 additions & 0 deletions src/content/collaboration/documents/snapshot-compare.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ You can pass in additional options for more control over the diffing process:

Each diff has an `attribution` field, which allows you to add additional metadata with the `hydrateUserData` callback function.

<Callout title="Note" variant="info">
Do note that the `userId` is populated by the `TiptapCollabProvider` and should be used to
identify the user who made the change. Without the `user` field provided by the provider, the
`userId` will be `null`. [See more information in the TiptapCollabProvider
documentation](/collaboration/provider/integration).
</Callout>

**Example:** Color-coding diffs based on user

```ts
Expand Down
56 changes: 29 additions & 27 deletions src/content/collaboration/provider/integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ useEffect(() => {
appId: 'YOUR_APP_ID', // replace with YOUR_APP_ID from Cloud dashboard
token: 'YOUR_JWT', // Authentication token
document: doc,
user: userId,
})
}, [])
```
Expand All @@ -48,46 +49,47 @@ useEffect(() => {

The Tiptap Collaboration provider offers several settings for custom configurations. Review the tables below for all parameters, practical use cases, and key concepts like "[awareness](/collaboration/core-concepts/awareness)".

| Setting | Default Value | Description |
| ------------------ | ----------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `appId` | `''` (empty) | App ID for Collaboration Cloud setups |
| `baseUrl` | `''` (empty) | URL for connecting to on-premises servers. Used as an alternative to `appId` for on-prem setups |
| `name` | `''` (empty) | The document's name |
| `token` | `''` (empty) | Authentication token for secure connections. Supports strings, functions, and Promises |
| `document` | `new Y.Doc()` | The Yjs document instance. Defaults to a new document if none is provided |
| `connect` | `true` | Connects to the server after initialization |
| `preserveConnection` | `true` | Keeps the WebSocket connection open after closing the provider |
| `broadcast` | `true` | Enables document syncing across browser tabs |
| `forceSyncInterval`| `false` | Forces server sync at regular intervals, in milliseconds |
| `quiet` | `false` | Suppresses warning outputs |
| `WebSocketPolyfill`| `WebSocket` | WebSocket implementation for Node.js environments. Use `ws` or another implementation |
| Setting | Default Value | Description |
| -------------------- | ------------- | ----------------------------------------------------------------------------------------------- |
| `appId` | `''` (empty) | App ID for Collaboration Cloud setups |
| `baseUrl` | `''` (empty) | URL for connecting to on-premises servers. Used as an alternative to `appId` for on-prem setups |
| `name` | `''` (empty) | The document's name |
| `token` | `''` (empty) | Authentication token for secure connections. Supports strings, functions, and Promises |
| `document` | `new Y.Doc()` | The Yjs document instance. Defaults to a new document if none is provided |
| `user` | `null` | User ID or name for attributing changes to the document. |
| `connect` | `true` | Connects to the server after initialization |
| `preserveConnection` | `true` | Keeps the WebSocket connection open after closing the provider |
| `broadcast` | `true` | Enables document syncing across browser tabs |
| `forceSyncInterval` | `false` | Forces server sync at regular intervals, in milliseconds |
| `quiet` | `false` | Suppresses warning outputs |
| `WebSocketPolyfill` | `WebSocket` | WebSocket implementation for Node.js environments. Use `ws` or another implementation |

### Optimize reconnection timings

The provider’s reconnection settings are preset for optimal performance in production settings. If you need to adjust these settings for specific scenarios, you can do so with our delay configurations.

Adjust initial delays, apply exponential backoff, or set maximum wait times to fine-tune your application's reconnection behavior, balancing responsiveness with server efficiency.

| Setting | Default Value | Description |
| ----------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `delay` | `1000` | Base delay between reconnection attempts, in milliseconds |
| `factor` | `2` | Multiplier applied to the delay, increasing it exponentially after each attempt |
| `initialDelay` | `0` | Time in milliseconds before the first reconnection attempt |
| `maxAttempts` | `0` | Maximum number of reconnection attempts. `0` means unlimited attempts |
| `jitter` | `true` | Adds variability to the delay by randomly selecting a value between `minDelay` and the calculated delay for each attempt |
| `minDelay` | `1000` | Minimum delay when jitter is enabled. Has no effect if jitter is disabled |
| `maxDelay` | `30000` | Maximum delay allowed between reconnection attempts. Set to `0` to allow the delay to increase indefinitely using exponential backoff (`factor`). |
| `timeout` | `0` | Time limit, in milliseconds, for each reconnection attempt before stopping |
| `messageReconnectTimeout` | `30000` | Time in milliseconds to wait for a server message before terminating the connection. If no message is received, the connection is closed automatically |
| Setting | Default Value | Description |
| ------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `delay` | `1000` | Base delay between reconnection attempts, in milliseconds |
| `factor` | `2` | Multiplier applied to the delay, increasing it exponentially after each attempt |
| `initialDelay` | `0` | Time in milliseconds before the first reconnection attempt |
| `maxAttempts` | `0` | Maximum number of reconnection attempts. `0` means unlimited attempts |
| `jitter` | `true` | Adds variability to the delay by randomly selecting a value between `minDelay` and the calculated delay for each attempt |
| `minDelay` | `1000` | Minimum delay when jitter is enabled. Has no effect if jitter is disabled |
| `maxDelay` | `30000` | Maximum delay allowed between reconnection attempts. Set to `0` to allow the delay to increase indefinitely using exponential backoff (`factor`). |
| `timeout` | `0` | Time limit, in milliseconds, for each reconnection attempt before stopping |
| `messageReconnectTimeout` | `30000` | Time in milliseconds to wait for a server message before terminating the connection. If no message is received, the connection is closed automatically |

## Rate limits

To maintain system integrity and protect from misconfigured clients, our infrastructure—including the management API and websocket connections through the `TiptapCollabProvider`—is subject to rate limits.

### Default rate limits (per source IP):

- **Requests:** 100
- **Time window:** 5 seconds
- **Burst capacity:** Up to 200 requests
- **Requests:** 100
- **Time window:** 5 seconds
- **Burst capacity:** Up to 200 requests

If you encounter these limits under normal operation, please [email us](mailto:humans@tiptap.dev).

0 comments on commit f726a93

Please sign in to comment.