Skip to content

Commit

Permalink
Send userAgent string with api requests
Browse files Browse the repository at this point in the history
  • Loading branch information
borisyankov committed Dec 19, 2016
1 parent f5b3271 commit 9d9720c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/api/apiFetch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Auth } from '../types';
import { getAuthHeader, encodeAsURI } from '../utils/url';
import userAgent from '../utils/userAgent';

const apiVersion = 'api/v1';

Expand All @@ -13,7 +14,7 @@ export const apiFetch = async (
const allParams = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
'User-Agent': 'ZulipReactNative',
'User-Agent': userAgent,
'Authorization': getAuthHeader(auth.email, auth.apiKey),
},
...params,
Expand Down
3 changes: 0 additions & 3 deletions src/events/eventActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import {
} from '../constants';

const processEvent = (dispatch, event, getState) => {
if (!getState().account) {
console.log('WTF WTF WTF', getState());
}
const isInNarrow = isMessageInNarrow(
event.message,
getState().chat.narrow,
Expand Down
7 changes: 1 addition & 6 deletions src/main/MainScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
} from 'react-native';
import Drawer from 'react-native-drawer';

import DeviceInfo from 'react-native-device-info';

import Chat from '../chat/Chat';
import MainNavBar from '../nav/MainNavBar';
import StreamSidebar from '../nav/StreamSidebar';
Expand All @@ -15,10 +13,7 @@ export default class MainScreen extends React.Component {

render() {
const { streamlistOpened, doNarrow } = this.props;
console.log('getModel', DeviceInfo.getModel());
console.log('getSystemVersion', DeviceInfo.getSystemVersion());
console.log('getVersion', DeviceInfo.getVersion());
console.log('getUserAgent', DeviceInfo.getUserAgent());

return (
<Drawer
content={
Expand Down
1 change: 0 additions & 1 deletion src/message-list/InfiniteScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class InfiniteScrollView extends React.Component {
stickyHeaderIndices={this.props.stickyHeaderIndices}
anchorMode
bounces={false}
scrollEventThrottle={1000}
autoScrollToBottom={this.props.autoScrollToBottom}
>
{this.props.children}
Expand Down
6 changes: 6 additions & 0 deletions src/utils/userAgent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { NativeModules } from 'react-native';
import DeviceInfo from 'react-native-device-info';

const userAgent = NativeModules.RNDeviceInfo ? `ZulipMobile ${DeviceInfo.getVersion()} (${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()})` : '';

export default userAgent;

0 comments on commit 9d9720c

Please sign in to comment.