);
}
export default App;
```
--------------------------------
### Sanitizer Function Example 2
Source: https://docs.openreplay.com/en/sdk/network-options
Example of a sanitizer function to ignore payloads for specific URLs. This function sets both the request and response bodies to null for any URL starting with '/secure'.
```typescript
sanitizer: data => {
if (data.url.startsWith("/secure")) {
data.request.body = null;
data.response.body = null;
}
return data
}
```
--------------------------------
### Configure and Start Tracker (SSR)
Source: https://docs.openreplay.com/en/deployment/setup-or
Initialize and start the OpenReplay tracker for Server-Side-Rendered (SSR) applications like NextJS or NuxtJS. Ensure the tracker runs in the browser environment and `tracker.start()` is called after the app is served to the client, for example, within `useEffect` or `componentDidMount`.
```javascript
import OpenReplay from '@openreplay/tracker/cjs';
//...
const tracker = new OpenReplay({
projectKey: PROJECT_KEY
});
//...
function MyApp() {
useEffect(() => { // use componentDidMount in case of React Class Component
tracker.start();
}, []);
}
```
--------------------------------
### Initialize OpenReplay Tracker in Svelte Component
Source: https://docs.openreplay.com/en/sdk/using-or/svelte
Get the tracker instance from Svelte's context and start it within the onMount callback to ensure browser execution.
```javascript
import {key} from "../../context/tracker"
let {getTracker} = getContext(key)
onMount( () => {
let tracker = getTracker()
tracker.start()
})
```
--------------------------------
### Start Session with Default Options
Source: https://docs.openreplay.com/en/rn-sdk/methods/start
Import the SDK and call `startSession` to begin recording with all features enabled by default. No options are needed for default behavior.
```javascript
import OR from '@openreplay/react-native'
OR.tracker.startSession(options)
```
--------------------------------
### Get OpenReplay Deployment Status
Source: https://docs.openreplay.com/en/cli
Use this command to check the current status of deployed OpenReplay services. This is useful for diagnosing issues or verifying a running installation.
```bash
openreplay -s
```
--------------------------------
### Initialize SDK with Enhanced Components and Metadata
Source: https://docs.openreplay.com/en/rn-sdk/init
This example demonstrates initializing the OpenReplay SDK with enhanced components for tracking user interactions and setting metadata. It includes tracking touch interactions, input changes, and sanitizing view content. Ensure environment variables for the project key and ingest URL are correctly set.
```javascript
// App.tsx
import Openreplay from '@openreplay/react-native';
function App() {
const start = () => {
Openreplay.tracker.startSession(
process.env.REACT_APP_KEY!,
{},
process.env.REACT_APP_INGEST
);
Openreplay.tracker.setMetadata('key', 'value');
Openreplay.tracker.setUserID('user-id');
Openreplay.patchNetwork(global, () => false, {});
};
React.useEffect(() => start(), []);
return (
// this top-level view is required to track touch interactions