rn-erxes-sdk 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/App.js +3 -2
- package/lib/commonjs/App.js.map +1 -1
- package/lib/commonjs/Widget.js +6 -5
- package/lib/commonjs/Widget.js.map +1 -1
- package/lib/commonjs/components/InputTools.js +2 -1
- package/lib/commonjs/components/InputTools.js.map +1 -1
- package/lib/commonjs/graphql/ApolloContainer.js +3 -2
- package/lib/commonjs/graphql/ApolloContainer.js.map +1 -1
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/screen/conversation/ConversationDetail.js +4 -2
- package/lib/commonjs/screen/conversation/ConversationDetail.js.map +1 -1
- package/lib/commonjs/screen/home/Home.js +4 -2
- package/lib/commonjs/screen/home/Home.js.map +1 -1
- package/lib/commonjs/utils/logger.js +55 -0
- package/lib/commonjs/utils/logger.js.map +1 -0
- package/lib/module/App.js +3 -2
- package/lib/module/App.js.map +1 -1
- package/lib/module/Widget.js +6 -5
- package/lib/module/Widget.js.map +1 -1
- package/lib/module/components/InputTools.js +2 -1
- package/lib/module/components/InputTools.js.map +1 -1
- package/lib/module/graphql/ApolloContainer.js +3 -2
- package/lib/module/graphql/ApolloContainer.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/screen/conversation/ConversationDetail.js +4 -2
- package/lib/module/screen/conversation/ConversationDetail.js.map +1 -1
- package/lib/module/screen/home/Home.js +4 -2
- package/lib/module/screen/home/Home.js.map +1 -1
- package/lib/module/utils/logger.js +46 -0
- package/lib/module/utils/logger.js.map +1 -0
- package/lib/typescript/App.d.ts.map +1 -1
- package/lib/typescript/Widget.d.ts.map +1 -1
- package/lib/typescript/components/InputTools.d.ts.map +1 -1
- package/lib/typescript/graphql/ApolloContainer.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/screen/conversation/ConversationDetail.d.ts.map +1 -1
- package/lib/typescript/screen/home/Home.d.ts.map +1 -1
- package/lib/typescript/utils/logger.d.ts +18 -0
- package/lib/typescript/utils/logger.d.ts.map +1 -0
- package/package.json +1 -1
- package/rn-erxes-sdk.podspec +2 -2
- package/src/App.tsx +3 -2
- package/src/Widget.tsx +6 -5
- package/src/components/InputTools.tsx +2 -1
- package/src/graphql/ApolloContainer.tsx +3 -2
- package/src/index.tsx +2 -0
- package/src/screen/conversation/ConversationDetail.tsx +4 -2
- package/src/screen/home/Home.tsx +4 -2
- package/src/utils/logger.ts +40 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug-gated logger for the SDK.
|
|
3
|
+
*
|
|
4
|
+
* A published SDK should not write to the host app's console in production. All
|
|
5
|
+
* internal logging goes through here so it can be silenced. By default logging
|
|
6
|
+
* follows React Native's `__DEV__` flag (on in development, off in release
|
|
7
|
+
* builds); hosts can override either way via {@link setDebugLogging}.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
let enabled = typeof __DEV__ !== 'undefined' ? __DEV__ : false;
|
|
11
|
+
|
|
12
|
+
/** Enable or disable SDK debug logging at runtime. */
|
|
13
|
+
export const setDebugLogging = value => {
|
|
14
|
+
enabled = value;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Whether SDK debug logging is currently active. */
|
|
18
|
+
export const isDebugLogging = () => enabled;
|
|
19
|
+
const PREFIX = '[erxes]';
|
|
20
|
+
export const logger = {
|
|
21
|
+
info: function () {
|
|
22
|
+
if (enabled) {
|
|
23
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
24
|
+
args[_key] = arguments[_key];
|
|
25
|
+
}
|
|
26
|
+
console.log(PREFIX, ...args);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
warn: function () {
|
|
30
|
+
if (enabled) {
|
|
31
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
32
|
+
args[_key2] = arguments[_key2];
|
|
33
|
+
}
|
|
34
|
+
console.warn(PREFIX, ...args);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
error: function () {
|
|
38
|
+
if (enabled) {
|
|
39
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
40
|
+
args[_key3] = arguments[_key3];
|
|
41
|
+
}
|
|
42
|
+
console.error(PREFIX, ...args);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["enabled","__DEV__","setDebugLogging","value","isDebugLogging","PREFIX","logger","info","_len","arguments","length","args","Array","_key","console","log","warn","_len2","_key2","error","_len3","_key3"],"sourceRoot":"../../../src","sources":["utils/logger.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,IAAIA,OAAO,GAAG,OAAOC,OAAO,KAAK,WAAW,GAAGA,OAAO,GAAG,KAAK;;AAE9D;AACA,OAAO,MAAMC,eAAe,GAAIC,KAAc,IAAK;EACjDH,OAAO,GAAGG,KAAK;AACjB,CAAC;;AAED;AACA,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAMJ,OAAO;AAE3C,MAAMK,MAAM,GAAG,SAAS;AAExB,OAAO,MAAMC,MAAM,GAAG;EACpBC,IAAI,EAAE,SAAAA,CAAA,EAAwB;IAC5B,IAAIP,OAAO,EAAE;MAAA,SAAAQ,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADLC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;QAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;MAAA;MAEVC,OAAO,CAACC,GAAG,CAACV,MAAM,EAAE,GAAGM,IAAI,CAAC;IAC9B;EACF,CAAC;EACDK,IAAI,EAAE,SAAAA,CAAA,EAAwB;IAC5B,IAAIhB,OAAO,EAAE;MAAA,SAAAiB,KAAA,GAAAR,SAAA,CAAAC,MAAA,EADLC,IAAI,OAAAC,KAAA,CAAAK,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;QAAJP,IAAI,CAAAO,KAAA,IAAAT,SAAA,CAAAS,KAAA;MAAA;MAEVJ,OAAO,CAACE,IAAI,CAACX,MAAM,EAAE,GAAGM,IAAI,CAAC;IAC/B;EACF,CAAC;EACDQ,KAAK,EAAE,SAAAA,CAAA,EAAwB;IAC7B,IAAInB,OAAO,EAAE;MAAA,SAAAoB,KAAA,GAAAX,SAAA,CAAAC,MAAA,EADJC,IAAI,OAAAC,KAAA,CAAAQ,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;QAAJV,IAAI,CAAAU,KAAA,IAAAZ,SAAA,CAAAY,KAAA;MAAA;MAEXP,OAAO,CAACK,KAAK,CAACd,MAAM,EAAE,GAAGM,IAAI,CAAC;IAChC;EACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,KAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,KAAoB,MAAM,OAAO,CAAC;AAOzC,MAAM,MAAM,SAAS,GAAG;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAmGjC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Widget.d.ts","sourceRoot":"","sources":["../../src/Widget.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Widget.d.ts","sourceRoot":"","sources":["../../src/Widget.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoB,MAAM,OAAO,CAAC;AA0CzC,QAAA,MAAM,MAAM,UAAW,GAAG,6BA+TzB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputTools.d.ts","sourceRoot":"","sources":["../../../src/components/InputTools.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"InputTools.d.ts","sourceRoot":"","sources":["../../../src/components/InputTools.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAqCpE,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAwO7B,CAAC;AA0IF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloContainer.d.ts","sourceRoot":"","sources":["../../../src/graphql/ApolloContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ApolloContainer.d.ts","sourceRoot":"","sources":["../../../src/graphql/ApolloContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,QAAA,MAAM,eAAe,4BAA6B,GAAG,sBAmDpD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ErxesNativeIOS } from './nativeIos';
|
|
2
2
|
export type { NativeIOSAction, NativeIOSConfig, NativeIOSUser, } from './nativeIos';
|
|
3
|
+
export { setDebugLogging, isDebugLogging } from './utils/logger';
|
|
3
4
|
export { ErxesMessenger } from './ErxesMessenger';
|
|
4
5
|
export type { ErxesUser, ErxesAction, ErxesMessengerHelpers, ErxesMessengerProps, } from './ErxesMessenger';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EACV,eAAe,EACf,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EACV,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EACV,eAAe,EACf,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EACV,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationDetail.d.ts","sourceRoot":"","sources":["../../../../src/screen/conversation/ConversationDetail.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAmD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ConversationDetail.d.ts","sourceRoot":"","sources":["../../../../src/screen/conversation/ConversationDetail.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAiFxE,QAAA,MAAM,kBAAkB,yBA+TvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../../../src/screen/home/Home.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAqB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../../../src/screen/home/Home.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAmB1C,QAAA,MAAM,IAAI,yBA+MT,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug-gated logger for the SDK.
|
|
3
|
+
*
|
|
4
|
+
* A published SDK should not write to the host app's console in production. All
|
|
5
|
+
* internal logging goes through here so it can be silenced. By default logging
|
|
6
|
+
* follows React Native's `__DEV__` flag (on in development, off in release
|
|
7
|
+
* builds); hosts can override either way via {@link setDebugLogging}.
|
|
8
|
+
*/
|
|
9
|
+
/** Enable or disable SDK debug logging at runtime. */
|
|
10
|
+
export declare const setDebugLogging: (value: boolean) => void;
|
|
11
|
+
/** Whether SDK debug logging is currently active. */
|
|
12
|
+
export declare const isDebugLogging: () => boolean;
|
|
13
|
+
export declare const logger: {
|
|
14
|
+
info: (...args: unknown[]) => void;
|
|
15
|
+
warn: (...args: unknown[]) => void;
|
|
16
|
+
error: (...args: unknown[]) => void;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,sDAAsD;AACtD,eAAO,MAAM,eAAe,UAAW,OAAO,SAE7C,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,cAAc,eAAgB,CAAC;AAI5C,eAAO,MAAM,MAAM;oBACD,OAAO,EAAE;oBAKT,OAAO,EAAE;qBAKR,OAAO,EAAE;CAK3B,CAAC"}
|
package/package.json
CHANGED
package/rn-erxes-sdk.podspec
CHANGED
|
@@ -36,10 +36,10 @@ Pod::Spec.new do |s|
|
|
|
36
36
|
spm_dependency(
|
|
37
37
|
s,
|
|
38
38
|
url: 'https://github.com/erxes/erxes-ios-sdk.git',
|
|
39
|
-
requirement: { :kind => 'exactVersion', :version => '0.30.
|
|
39
|
+
requirement: { :kind => 'exactVersion', :version => '0.30.9' },
|
|
40
40
|
products: ['MessengerSDK']
|
|
41
41
|
)
|
|
42
42
|
else
|
|
43
|
-
raise 'rn-erxes-sdk requires React Native 0.81+ CocoaPods SPM support to install MessengerSDK 0.30.
|
|
43
|
+
raise 'rn-erxes-sdk requires React Native 0.81+ CocoaPods SPM support to install MessengerSDK 0.30.9'
|
|
44
44
|
end
|
|
45
45
|
end
|
package/src/App.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import React, { useEffect } from 'react';
|
|
|
3
3
|
import Widget from './Widget';
|
|
4
4
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
5
5
|
import { createObjectIdLikeString } from './utils/objectId';
|
|
6
|
+
import { logger } from './utils/logger';
|
|
6
7
|
import ApolloContainer from './graphql/ApolloContainer';
|
|
7
8
|
|
|
8
9
|
export type PropTypes = {
|
|
@@ -69,7 +70,7 @@ const ErxesSDK: React.FC<PropTypes> = ({
|
|
|
69
70
|
})
|
|
70
71
|
.catch((e) => {
|
|
71
72
|
setLoading(false);
|
|
72
|
-
|
|
73
|
+
logger.error('Failed on cachedConversationId', e.message);
|
|
73
74
|
});
|
|
74
75
|
})
|
|
75
76
|
.catch((e) => {
|
|
@@ -78,7 +79,7 @@ const ErxesSDK: React.FC<PropTypes> = ({
|
|
|
78
79
|
visitorId: createObjectIdLikeString(),
|
|
79
80
|
});
|
|
80
81
|
setLoading(false);
|
|
81
|
-
|
|
82
|
+
logger.error('Failed on cachedCustomerId', e.message);
|
|
82
83
|
});
|
|
83
84
|
}, []);
|
|
84
85
|
|
package/src/Widget.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
widgetsSaveBrowserInfo,
|
|
10
10
|
} from './graphql/mutation';
|
|
11
11
|
import AppContext from './context/Context';
|
|
12
|
+
import { logger } from './utils/logger';
|
|
12
13
|
import ConversationDetail from './screen/conversation/ConversationDetail';
|
|
13
14
|
import MessengerShell from './components/MessengerShell';
|
|
14
15
|
import { TouchableOpacity } from 'react-native';
|
|
@@ -119,7 +120,7 @@ const Widget = (props: any) => {
|
|
|
119
120
|
return res;
|
|
120
121
|
})
|
|
121
122
|
.catch((err) => {
|
|
122
|
-
|
|
123
|
+
logger.error('readConversationMessages failed', err);
|
|
123
124
|
return null;
|
|
124
125
|
});
|
|
125
126
|
},
|
|
@@ -210,7 +211,7 @@ const Widget = (props: any) => {
|
|
|
210
211
|
refetchUnreadConversations();
|
|
211
212
|
},
|
|
212
213
|
error(err) {
|
|
213
|
-
|
|
214
|
+
logger.error('unread conversations subscription error', err);
|
|
214
215
|
},
|
|
215
216
|
});
|
|
216
217
|
|
|
@@ -248,7 +249,7 @@ const Widget = (props: any) => {
|
|
|
248
249
|
}
|
|
249
250
|
})
|
|
250
251
|
.catch((err) => {
|
|
251
|
-
|
|
252
|
+
logger.error('connect failed', err);
|
|
252
253
|
});
|
|
253
254
|
}, []);
|
|
254
255
|
|
|
@@ -261,10 +262,10 @@ const Widget = (props: any) => {
|
|
|
261
262
|
},
|
|
262
263
|
})
|
|
263
264
|
.then(() => {
|
|
264
|
-
|
|
265
|
+
logger.info('browser info saved');
|
|
265
266
|
})
|
|
266
267
|
.catch((err) => {
|
|
267
|
-
|
|
268
|
+
logger.error('saveBrowserInfo failed', err);
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
271
|
}, [connection]);
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
Platform,
|
|
12
12
|
} from 'react-native';
|
|
13
13
|
import { messengerTheme } from '../theme';
|
|
14
|
+
import { logger } from '../utils/logger';
|
|
14
15
|
import {
|
|
15
16
|
SendIcon,
|
|
16
17
|
AttachmentIcon,
|
|
@@ -107,7 +108,7 @@ const InputTools: React.FC<any> = (props: any) => {
|
|
|
107
108
|
const uploaded = await uploadFile(file, subDomain);
|
|
108
109
|
setAttachments((prev) => [...prev, uploaded]);
|
|
109
110
|
} catch (err) {
|
|
110
|
-
|
|
111
|
+
logger.error('attachment upload failed', err);
|
|
111
112
|
const message = err instanceof Error ? err.message : '';
|
|
112
113
|
showUploadError(
|
|
113
114
|
message.includes('Invalid configured file type')
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import { getMainDefinition } from '@apollo/client/utilities';
|
|
11
11
|
import { onError } from '@apollo/client/link/error';
|
|
12
12
|
import { GraphQLWsLink } from '@apollo/client/link/subscriptions';
|
|
13
|
+
import { logger } from '../utils/logger';
|
|
13
14
|
import { createClient } from 'graphql-ws';
|
|
14
15
|
|
|
15
16
|
const ApolloContainer = ({ children, subDomain }: any) => {
|
|
@@ -28,8 +29,8 @@ const ApolloContainer = ({ children, subDomain }: any) => {
|
|
|
28
29
|
);
|
|
29
30
|
|
|
30
31
|
const logoutLink = onError(({ networkError, graphQLErrors }) => {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
logger.error('network error', networkError);
|
|
33
|
+
logger.error('graphQL errors', graphQLErrors);
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
const httpLink = createHttpLink({
|
package/src/index.tsx
CHANGED
|
@@ -32,6 +32,7 @@ import { BackIcon } from '../../components/Icons';
|
|
|
32
32
|
import DateSeparator from '../../components/conversation/DateSeparator';
|
|
33
33
|
import WelcomeMessage from '../../components/conversation/WelcomeMessage';
|
|
34
34
|
import TypingStatus from '../../components/conversation/TypingStatus';
|
|
35
|
+
import { logger } from '../../utils/logger';
|
|
35
36
|
|
|
36
37
|
const hasUserDetails = (user: any): boolean =>
|
|
37
38
|
Boolean(user?.details?.fullName || user?.details?.avatar);
|
|
@@ -301,7 +302,8 @@ const ConversationDetail = () => {
|
|
|
301
302
|
})
|
|
302
303
|
.then((res: any) => {
|
|
303
304
|
if (res.errors) {
|
|
304
|
-
|
|
305
|
+
logger.error('insertMessage errors', res.errors);
|
|
306
|
+
return;
|
|
305
307
|
}
|
|
306
308
|
|
|
307
309
|
const insertedMessage = res.data.widgetsInsertMessage;
|
|
@@ -326,7 +328,7 @@ const ConversationDetail = () => {
|
|
|
326
328
|
}
|
|
327
329
|
})
|
|
328
330
|
.catch((err: any) => {
|
|
329
|
-
|
|
331
|
+
logger.error('insertMessage failed', err);
|
|
330
332
|
})
|
|
331
333
|
.finally(() => {
|
|
332
334
|
sendingRef.current = false;
|
package/src/screen/home/Home.tsx
CHANGED
|
@@ -14,6 +14,7 @@ import React, { useContext } from 'react';
|
|
|
14
14
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
15
15
|
import { useMutation } from '@apollo/client';
|
|
16
16
|
import AppContext from '../../context/Context';
|
|
17
|
+
import { logger } from '../../utils/logger';
|
|
17
18
|
import Supporters from '../greetings/Supporters';
|
|
18
19
|
import Social from '../greetings/Social';
|
|
19
20
|
import { messengerTheme } from '../../theme';
|
|
@@ -92,7 +93,8 @@ const Home = () => {
|
|
|
92
93
|
})
|
|
93
94
|
.then((res: any) => {
|
|
94
95
|
if (res.errors) {
|
|
95
|
-
|
|
96
|
+
logger.error('insertMessage errors', res.errors);
|
|
97
|
+
return;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
const insertedMessage = res.data.widgetsInsertMessage;
|
|
@@ -104,7 +106,7 @@ const Home = () => {
|
|
|
104
106
|
}
|
|
105
107
|
})
|
|
106
108
|
.catch((err: any) => {
|
|
107
|
-
|
|
109
|
+
logger.error('insertMessage failed', err);
|
|
108
110
|
})
|
|
109
111
|
.finally(() => {
|
|
110
112
|
sendingRef.current = false;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug-gated logger for the SDK.
|
|
3
|
+
*
|
|
4
|
+
* A published SDK should not write to the host app's console in production. All
|
|
5
|
+
* internal logging goes through here so it can be silenced. By default logging
|
|
6
|
+
* follows React Native's `__DEV__` flag (on in development, off in release
|
|
7
|
+
* builds); hosts can override either way via {@link setDebugLogging}.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const __DEV__: boolean;
|
|
11
|
+
|
|
12
|
+
let enabled = typeof __DEV__ !== 'undefined' ? __DEV__ : false;
|
|
13
|
+
|
|
14
|
+
/** Enable or disable SDK debug logging at runtime. */
|
|
15
|
+
export const setDebugLogging = (value: boolean) => {
|
|
16
|
+
enabled = value;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Whether SDK debug logging is currently active. */
|
|
20
|
+
export const isDebugLogging = () => enabled;
|
|
21
|
+
|
|
22
|
+
const PREFIX = '[erxes]';
|
|
23
|
+
|
|
24
|
+
export const logger = {
|
|
25
|
+
info: (...args: unknown[]) => {
|
|
26
|
+
if (enabled) {
|
|
27
|
+
console.log(PREFIX, ...args);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
warn: (...args: unknown[]) => {
|
|
31
|
+
if (enabled) {
|
|
32
|
+
console.warn(PREFIX, ...args);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
error: (...args: unknown[]) => {
|
|
36
|
+
if (enabled) {
|
|
37
|
+
console.error(PREFIX, ...args);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|