Skip to content

Commit 7bd4c63

Browse files
committed
enabling tracking SDK client usage type between expo and react-native
1 parent 4d187bb commit 7bd4c63

File tree

8 files changed

+81
-87
lines changed

8 files changed

+81
-87
lines changed

expo-package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"main": "src/index.js",
1111
"types": "types/index.d.ts",
1212
"dependencies": {
13-
"stream-chat-react-native-core": "v3.1.2"
13+
"stream-chat-react-native-core": "link:../"
1414
},
1515
"peerDependencies": {
1616
"@react-native-community/netinfo": "^5.9.7",

expo-package/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ registerNativeHandlers({
133133
throw new Error('Downloading image failed...');
134134
}
135135
},
136+
SDK: 'stream-chat-expo',
136137
shareImage: async ({ type, url }) => {
137138
try {
138139
await Sharing.shareAsync(url, { mimeType: type, UTI: type });

expo-package/yarn.lock

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@
516516
"@babel/helper-create-regexp-features-plugin" "^7.12.1"
517517
"@babel/helper-plugin-utils" "^7.10.4"
518518

519-
"@babel/[email protected]", "@babel/runtime@^7.12.13":
519+
520520
version "7.12.13"
521521
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.13.tgz#0a21452352b02542db0ffb928ac2d3ca7cb6d66d"
522522
integrity sha512-8+3UMPBrjFa/6TtKi/7sehPKqfAm4g6K+YQjyyFOLUTxzOngcRZTlAVY8sc2CORJYqdHQY8gRPHmn+qo15rCBw==
@@ -530,6 +530,13 @@
530530
dependencies:
531531
regenerator-runtime "^0.13.4"
532532

533+
"@babel/runtime@^7.13.10":
534+
version "7.13.10"
535+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d"
536+
integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==
537+
dependencies:
538+
regenerator-runtime "^0.13.4"
539+
533540
"@babel/template@^7.0.0", "@babel/template@^7.10.4", "@babel/template@^7.12.7":
534541
version "7.12.7"
535542
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.7.tgz#c817233696018e39fbb6c491d2fb684e05ed43bc"
@@ -800,10 +807,10 @@ follow-redirects@^1.10.0:
800807
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7"
801808
integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==
802809

803-
form-data@^3.0.0:
804-
version "3.0.0"
805-
resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.0.tgz#31b7e39c85f1355b7139ee0c647cf0de7f83c682"
806-
integrity sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==
810+
form-data@^4.0.0:
811+
version "4.0.0"
812+
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
813+
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
807814
dependencies:
808815
asynckit "^0.4.0"
809816
combined-stream "^1.0.8"
@@ -1271,39 +1278,24 @@ source-map@^0.5.0:
12711278
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
12721279
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
12731280

1274-
1275-
version "3.1.2"
1276-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-3.1.2.tgz#1a63dc8c68f80745752b38bbf20010d7c7d05c91"
1277-
integrity sha512-iOz6xhG/mw1OKbK+dcxIliB7zyrtSeDofuJQ4d2Fz8ysQodOfqmJp7fCNmLuGCvgP9z6mDSXrASPmCL4Yo02GQ==
1278-
dependencies:
1279-
"@babel/runtime" "7.12.13"
1280-
"@gorhom/bottom-sheet" "3.0.0-alpha.0"
1281-
anchorme "^1.1.2"
1282-
dayjs "1.10.4"
1283-
file-loader "6.2.0"
1284-
i18next "19.8.7"
1285-
lodash-es "4.17.20"
1286-
metro-react-native-babel-preset "0.65.0"
1287-
mime-types "2.1.28"
1288-
path "0.12.7"
1289-
react-art "^16.8.6"
1290-
react-native-markdown-package "1.8.1"
1291-
stream-chat "3.1.2"
1292-
1293-
1294-
version "3.1.2"
1295-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-3.1.2.tgz#271ff85f5533ae432bc94168bfeffca8efc6b55a"
1296-
integrity sha512-hIVkycehlJrkG2D+RV77qhZeOjZyas398DNdD8GeQlVB7Li60p+XPAsaeNob7kEptFow2LC2TTUiR4hQDCbufg==
1297-
dependencies:
1298-
"@babel/runtime" "^7.12.13"
1281+
"stream-chat-react-native-core@link:..":
1282+
version "0.0.0"
1283+
uid ""
1284+
1285+
1286+
version "3.6.2"
1287+
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-3.6.2.tgz#4f3ab28f3c02519daea26bcb8578bddd5f414c4a"
1288+
integrity sha512-hhe7gW86GfaoYdZoauh9FQf2bwhi5LApwLZAjsm9qZ0Qx31z409XVPvkMfiDewgjBjodzGWq7p7ZTyW7mczeDg==
1289+
dependencies:
1290+
"@babel/runtime" "^7.13.10"
12991291
"@types/jsonwebtoken" "^8.5.0"
13001292
"@types/ws" "^7.4.0"
13011293
axios "^0.21.1"
13021294
base64-js "^1.5.1"
1303-
form-data "^3.0.0"
1295+
form-data "^4.0.0"
13041296
isomorphic-ws "^4.0.1"
13051297
jsonwebtoken "^8.5.1"
1306-
ws "^7.4.3"
1298+
ws "^7.4.4"
13071299

13081300
supports-color@^5.3.0:
13091301
version "5.5.0"
@@ -1359,7 +1351,7 @@ util@^0.10.3:
13591351
dependencies:
13601352
inherits "2.0.3"
13611353

1362-
ws@^7.4.3:
1363-
version "7.4.3"
1364-
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.3.tgz#1f9643de34a543b8edb124bdcbc457ae55a6e5cd"
1365-
integrity sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==
1354+
ws@^7.4.4:
1355+
version "7.4.4"
1356+
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59"
1357+
integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==

native-package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"types": "types/index.d.ts",
1212
"dependencies": {
1313
"es6-symbol": "^3.1.3",
14-
"stream-chat-react-native-core": "v3.1.2"
14+
"stream-chat-react-native-core": "link:../"
1515
},
1616
"peerDependencies": {
1717
"@react-native-community/blur": ">=3.6.0",

native-package/src/index.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ registerNativeHandlers({
166166
throw new Error('Downloading image failed...');
167167
}
168168
},
169+
SDK: 'stream-chat-react-native',
169170
shareImage: async ({ type, url }) => {
170171
try {
171172
const base64Image = await RNFS.readFile(url, 'base64');
@@ -174,22 +175,22 @@ registerNativeHandlers({
174175
activityItemSources:
175176
Platform.OS === 'ios'
176177
? [
177-
{
178-
item: {
179-
default: {
180-
content: url,
181-
type: 'url',
182-
},
183-
},
184-
linkMetadata: {
185-
icon: url,
186-
},
187-
placeholderItem: {
178+
{
179+
item: {
180+
default: {
188181
content: url,
189182
type: 'url',
190183
},
191184
},
192-
]
185+
linkMetadata: {
186+
icon: url,
187+
},
188+
placeholderItem: {
189+
content: url,
190+
type: 'url',
191+
},
192+
},
193+
]
193194
: undefined,
194195
excludedActivityTypes: [],
195196
failOnCancel: false,

native-package/yarn.lock

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@
516516
"@babel/helper-create-regexp-features-plugin" "^7.12.1"
517517
"@babel/helper-plugin-utils" "^7.10.4"
518518

519-
"@babel/[email protected]", "@babel/runtime@^7.12.13":
519+
520520
version "7.12.13"
521521
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.13.tgz#0a21452352b02542db0ffb928ac2d3ca7cb6d66d"
522522
integrity sha512-8+3UMPBrjFa/6TtKi/7sehPKqfAm4g6K+YQjyyFOLUTxzOngcRZTlAVY8sc2CORJYqdHQY8gRPHmn+qo15rCBw==
@@ -530,6 +530,13 @@
530530
dependencies:
531531
regenerator-runtime "^0.13.4"
532532

533+
"@babel/runtime@^7.13.10":
534+
version "7.13.10"
535+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d"
536+
integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==
537+
dependencies:
538+
regenerator-runtime "^0.13.4"
539+
533540
"@babel/template@^7.0.0", "@babel/template@^7.10.4", "@babel/template@^7.12.7":
534541
version "7.12.7"
535542
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.7.tgz#c817233696018e39fbb6c491d2fb684e05ed43bc"
@@ -841,10 +848,10 @@ follow-redirects@^1.10.0:
841848
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7"
842849
integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==
843850

844-
form-data@^3.0.0:
845-
version "3.0.0"
846-
resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.0.tgz#31b7e39c85f1355b7139ee0c647cf0de7f83c682"
847-
integrity sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==
851+
form-data@^4.0.0:
852+
version "4.0.0"
853+
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
854+
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
848855
dependencies:
849856
asynckit "^0.4.0"
850857
combined-stream "^1.0.8"
@@ -1317,39 +1324,24 @@ source-map@^0.5.0:
13171324
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
13181325
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
13191326

1320-
1321-
version "3.1.2"
1322-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-3.1.2.tgz#1a63dc8c68f80745752b38bbf20010d7c7d05c91"
1323-
integrity sha512-iOz6xhG/mw1OKbK+dcxIliB7zyrtSeDofuJQ4d2Fz8ysQodOfqmJp7fCNmLuGCvgP9z6mDSXrASPmCL4Yo02GQ==
1324-
dependencies:
1325-
"@babel/runtime" "7.12.13"
1326-
"@gorhom/bottom-sheet" "3.0.0-alpha.0"
1327-
anchorme "^1.1.2"
1328-
dayjs "1.10.4"
1329-
file-loader "6.2.0"
1330-
i18next "19.8.7"
1331-
lodash-es "4.17.20"
1332-
metro-react-native-babel-preset "0.65.0"
1333-
mime-types "2.1.28"
1334-
path "0.12.7"
1335-
react-art "^16.8.6"
1336-
react-native-markdown-package "1.8.1"
1337-
stream-chat "3.1.2"
1338-
1339-
1340-
version "3.1.2"
1341-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-3.1.2.tgz#271ff85f5533ae432bc94168bfeffca8efc6b55a"
1342-
integrity sha512-hIVkycehlJrkG2D+RV77qhZeOjZyas398DNdD8GeQlVB7Li60p+XPAsaeNob7kEptFow2LC2TTUiR4hQDCbufg==
1343-
dependencies:
1344-
"@babel/runtime" "^7.12.13"
1327+
"stream-chat-react-native-core@link:..":
1328+
version "0.0.0"
1329+
uid ""
1330+
1331+
1332+
version "3.6.2"
1333+
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-3.6.2.tgz#4f3ab28f3c02519daea26bcb8578bddd5f414c4a"
1334+
integrity sha512-hhe7gW86GfaoYdZoauh9FQf2bwhi5LApwLZAjsm9qZ0Qx31z409XVPvkMfiDewgjBjodzGWq7p7ZTyW7mczeDg==
1335+
dependencies:
1336+
"@babel/runtime" "^7.13.10"
13451337
"@types/jsonwebtoken" "^8.5.0"
13461338
"@types/ws" "^7.4.0"
13471339
axios "^0.21.1"
13481340
base64-js "^1.5.1"
1349-
form-data "^3.0.0"
1341+
form-data "^4.0.0"
13501342
isomorphic-ws "^4.0.1"
13511343
jsonwebtoken "^8.5.1"
1352-
ws "^7.4.3"
1344+
ws "^7.4.4"
13531345

13541346
supports-color@^5.3.0:
13551347
version "5.5.0"
@@ -1415,7 +1407,7 @@ util@^0.10.3:
14151407
dependencies:
14161408
inherits "2.0.3"
14171409

1418-
ws@^7.4.3:
1419-
version "7.4.3"
1420-
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.3.tgz#1f9643de34a543b8edb124bdcbc457ae55a6e5cd"
1421-
integrity sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==
1410+
ws@^7.4.4:
1411+
version "7.4.4"
1412+
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59"
1413+
integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==

src/components/Chat/Chat.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from '../../contexts/translationContext/TranslationContext';
2222
import { useStreami18n } from '../../utils/useStreami18n';
2323

24+
import { SDK } from '../../native';
2425
import { version } from '../../version.json';
2526

2627
import type { Channel } from 'stream-chat';
@@ -183,7 +184,7 @@ const ChatWithContext = <
183184

184185
useEffect(() => {
185186
if (client.setUserAgent) {
186-
client.setUserAgent(`stream-chat-react-native-${Platform.OS}-${version}`);
187+
client.setUserAgent(`${SDK}-${Platform.OS}-${version}`);
187188
// This is to disable recovery related logic in js client, since we handle it in this SDK
188189
client.recoverStateOnReconnect = false;
189190
}

src/native.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ type HapticFeedbackMethod =
126126
type TriggerHaptic = (method: HapticFeedbackMethod) => void | never;
127127
export let triggerHaptic: TriggerHaptic = fail;
128128

129+
export let SDK: string;
130+
129131
type Handlers = {
130132
BlurView?: BlurView;
131133
compressImage?: CompressImage;
@@ -136,6 +138,7 @@ type Handlers = {
136138
NetInfo?: NetInfo;
137139
pickDocument?: PickDocument;
138140
saveFile?: SaveFile;
141+
SDK?: string;
139142
shareImage?: ShareImage;
140143
takePhoto?: TakePhoto;
141144
triggerHaptic?: TriggerHaptic;
@@ -181,6 +184,10 @@ export const registerNativeHandlers = (handlers: Handlers) => {
181184
saveFile = handlers.saveFile;
182185
}
183186

187+
if (handlers.SDK) {
188+
SDK = handlers.SDK;
189+
}
190+
184191
if (handlers.shareImage) {
185192
shareImage = handlers.shareImage;
186193
}

0 commit comments

Comments
 (0)