Skip to content

Commit aef133b

Browse files
authored
Merge pull request #318 from GetStream/CRNS-128/add-stream-chat-user-agent-header
CRNS:128: adding stream-chat-react-native-{platform}-{package_version} to user agent header for chat client
2 parents 52d7e82 + 46c9a36 commit aef133b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/Chat/Chat.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { useState } from 'react';
1+
import React, { useEffect, useState } from 'react';
2+
import { Platform } from 'react-native';
23
import Dayjs from 'dayjs';
34
import PropTypes from 'prop-types';
45

@@ -9,6 +10,8 @@ import { ChatContext, TranslationContext } from '../../context';
910
import { themed } from '../../styles/theme';
1011
import { Streami18n } from '../../utils/Streami18n';
1112

13+
import { version } from '../../../package.json';
14+
1215
/**
1316
* Chat - Wrapper component for Chat. The needs to be placed around any other chat components.
1417
* This Chat component provides the ChatContext to all other components.
@@ -43,6 +46,10 @@ const Chat = (props) => {
4346
client,
4447
});
4548

49+
useEffect(() => {
50+
client.setUserAgent(`stream-chat-react-native-${Platform.OS}-${version}`);
51+
}, []);
52+
4653
const setActiveChannel = (channel) => setChannel(channel);
4754

4855
if (!translators.t) return null;

0 commit comments

Comments
 (0)