@luciq/react-native 18.0.0

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.
Files changed (239) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/FONTS_SETUP_GUIDE.md +521 -0
  3. package/Gemfile +1 -0
  4. package/Gemfile.lock +11 -0
  5. package/LICENSE +21 -0
  6. package/README.md +148 -0
  7. package/RNLuciq.podspec +21 -0
  8. package/android/build.gradle +88 -0
  9. package/android/gradle.properties +4 -0
  10. package/android/jacoco.gradle +52 -0
  11. package/android/native.gradle +7 -0
  12. package/android/proguard-rules.txt +1 -0
  13. package/android/sourcemaps.gradle +255 -0
  14. package/android/src/main/AndroidManifest.xml +4 -0
  15. package/android/src/main/java/ai/luciq/reactlibrary/ArgsRegistry.java +278 -0
  16. package/android/src/main/java/ai/luciq/reactlibrary/Constants.java +20 -0
  17. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciq.java +328 -0
  18. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqAPMModule.java +392 -0
  19. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqBugReportingModule.java +444 -0
  20. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqCrashReportingModule.java +169 -0
  21. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqFeatureRequestsModule.java +98 -0
  22. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqNetworkLoggerModule.java +195 -0
  23. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqReactnativeModule.java +1611 -0
  24. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqReactnativePackage.java +41 -0
  25. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqRepliesModule.java +298 -0
  26. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqSessionReplayModule.java +213 -0
  27. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqSurveysModule.java +237 -0
  28. package/android/src/main/java/ai/luciq/reactlibrary/utils/ArrayUtil.java +167 -0
  29. package/android/src/main/java/ai/luciq/reactlibrary/utils/EventEmitterModule.java +35 -0
  30. package/android/src/main/java/ai/luciq/reactlibrary/utils/LuciqUtil.java +58 -0
  31. package/android/src/main/java/ai/luciq/reactlibrary/utils/MainThreadHandler.java +13 -0
  32. package/android/src/main/java/ai/luciq/reactlibrary/utils/MapUtil.java +171 -0
  33. package/android/src/main/java/ai/luciq/reactlibrary/utils/RNTouchedViewExtractor.java +167 -0
  34. package/android/src/main/java/ai/luciq/reactlibrary/utils/ReportUtil.java +67 -0
  35. package/app.plugin.js +1 -0
  36. package/babel.config.js +3 -0
  37. package/bin/commands/MigrateCommand.d.ts +6 -0
  38. package/bin/commands/UploadEasUpdatesSourcemaps.d.ts +2 -0
  39. package/bin/commands/UploadSoFiles.d.ts +6 -0
  40. package/bin/commands/UploadSourcemaps.d.ts +2 -0
  41. package/bin/config/migration-config.json +125 -0
  42. package/bin/index.d.ts +2 -0
  43. package/bin/index.js +19179 -0
  44. package/bin/upload/index.d.ts +4 -0
  45. package/bin/upload/migrate.d.ts +14 -0
  46. package/bin/upload/uploadEasUpdatesSourcemaps.d.ts +21 -0
  47. package/bin/upload/uploadSoFiles.d.ts +21 -0
  48. package/bin/upload/uploadSourcemaps.d.ts +21 -0
  49. package/cli/commands/MigrateCommand.ts +32 -0
  50. package/cli/commands/UploadEasUpdatesSourcemaps.ts +34 -0
  51. package/cli/commands/UploadSoFiles.ts +38 -0
  52. package/cli/commands/UploadSourcemaps.ts +40 -0
  53. package/cli/config/migration-config.json +125 -0
  54. package/cli/index.ts +21 -0
  55. package/cli/upload/index.ts +4 -0
  56. package/cli/upload/migrate.ts +271 -0
  57. package/cli/upload/uploadEasUpdatesSourcemaps.ts +74 -0
  58. package/cli/upload/uploadSoFiles.ts +112 -0
  59. package/cli/upload/uploadSourcemaps.ts +73 -0
  60. package/dangerfile.ts +44 -0
  61. package/dist/index.d.ts +19 -0
  62. package/dist/index.js +14 -0
  63. package/dist/models/FeatureFlag.d.ts +11 -0
  64. package/dist/models/FeatureFlag.js +1 -0
  65. package/dist/models/LuciqConfig.d.ts +42 -0
  66. package/dist/models/LuciqConfig.js +1 -0
  67. package/dist/models/NonFatalOptions.d.ts +15 -0
  68. package/dist/models/NonFatalOptions.js +1 -0
  69. package/dist/models/OverAirUpdate.d.ts +12 -0
  70. package/dist/models/OverAirUpdate.js +1 -0
  71. package/dist/models/Report.d.ts +70 -0
  72. package/dist/models/Report.js +109 -0
  73. package/dist/models/ReproConfig.d.ts +27 -0
  74. package/dist/models/ReproConfig.js +1 -0
  75. package/dist/models/SessionMetadata.d.ts +55 -0
  76. package/dist/models/SessionMetadata.js +1 -0
  77. package/dist/models/ThemeConfig.d.ts +27 -0
  78. package/dist/models/ThemeConfig.js +1 -0
  79. package/dist/models/W3cExternalTraceAttributes.d.ts +22 -0
  80. package/dist/models/W3cExternalTraceAttributes.js +1 -0
  81. package/dist/modules/APM.d.ts +77 -0
  82. package/dist/modules/APM.js +104 -0
  83. package/dist/modules/BugReporting.d.ts +138 -0
  84. package/dist/modules/BugReporting.js +202 -0
  85. package/dist/modules/CrashReporting.d.ts +19 -0
  86. package/dist/modules/CrashReporting.js +40 -0
  87. package/dist/modules/FeatureRequests.d.ts +20 -0
  88. package/dist/modules/FeatureRequests.js +28 -0
  89. package/dist/modules/Luciq.d.ts +362 -0
  90. package/dist/modules/Luciq.js +797 -0
  91. package/dist/modules/NetworkLogger.d.ts +52 -0
  92. package/dist/modules/NetworkLogger.js +208 -0
  93. package/dist/modules/Replies.d.ts +78 -0
  94. package/dist/modules/Replies.js +121 -0
  95. package/dist/modules/SessionReplay.d.ts +78 -0
  96. package/dist/modules/SessionReplay.js +98 -0
  97. package/dist/modules/Surveys.d.ts +75 -0
  98. package/dist/modules/Surveys.js +101 -0
  99. package/dist/native/NativeAPM.d.ts +18 -0
  100. package/dist/native/NativeAPM.js +4 -0
  101. package/dist/native/NativeBugReporting.d.ts +32 -0
  102. package/dist/native/NativeBugReporting.js +10 -0
  103. package/dist/native/NativeConstants.d.ts +182 -0
  104. package/dist/native/NativeConstants.js +1 -0
  105. package/dist/native/NativeCrashReporting.d.ts +18 -0
  106. package/dist/native/NativeCrashReporting.js +2 -0
  107. package/dist/native/NativeFeatureRequests.d.ts +8 -0
  108. package/dist/native/NativeFeatureRequests.js +2 -0
  109. package/dist/native/NativeLuciq.d.ts +86 -0
  110. package/dist/native/NativeLuciq.js +10 -0
  111. package/dist/native/NativeNetworkLogger.d.ts +21 -0
  112. package/dist/native/NativeNetworkLogger.js +14 -0
  113. package/dist/native/NativePackage.d.ts +21 -0
  114. package/dist/native/NativePackage.js +2 -0
  115. package/dist/native/NativeReplies.d.ts +21 -0
  116. package/dist/native/NativeReplies.js +8 -0
  117. package/dist/native/NativeSessionReplay.d.ts +16 -0
  118. package/dist/native/NativeSessionReplay.js +8 -0
  119. package/dist/native/NativeSurveys.d.ts +22 -0
  120. package/dist/native/NativeSurveys.js +9 -0
  121. package/dist/utils/AppStatesHandler.d.ts +3 -0
  122. package/dist/utils/AppStatesHandler.js +16 -0
  123. package/dist/utils/Enums.d.ts +244 -0
  124. package/dist/utils/Enums.js +266 -0
  125. package/dist/utils/FeatureFlags.d.ts +7 -0
  126. package/dist/utils/FeatureFlags.js +24 -0
  127. package/dist/utils/LuciqConstants.d.ts +14 -0
  128. package/dist/utils/LuciqConstants.js +15 -0
  129. package/dist/utils/LuciqUtils.d.ts +97 -0
  130. package/dist/utils/LuciqUtils.js +301 -0
  131. package/dist/utils/UnhandledRejectionTracking.d.ts +9 -0
  132. package/dist/utils/UnhandledRejectionTracking.js +99 -0
  133. package/dist/utils/XhrNetworkInterceptor.d.ts +39 -0
  134. package/dist/utils/XhrNetworkInterceptor.js +253 -0
  135. package/dist/utils/config.d.ts +5 -0
  136. package/dist/utils/config.js +6 -0
  137. package/dist/utils/logger.d.ts +10 -0
  138. package/dist/utils/logger.js +39 -0
  139. package/expo.d.ts +1 -0
  140. package/expo.js +1 -0
  141. package/ios/RNLuciq/ArgsRegistry.h +32 -0
  142. package/ios/RNLuciq/ArgsRegistry.m +276 -0
  143. package/ios/RNLuciq/LuciqAPMBridge.h +26 -0
  144. package/ios/RNLuciq/LuciqAPMBridge.m +99 -0
  145. package/ios/RNLuciq/LuciqBugReportingBridge.h +60 -0
  146. package/ios/RNLuciq/LuciqBugReportingBridge.m +241 -0
  147. package/ios/RNLuciq/LuciqCrashReportingBridge.h +18 -0
  148. package/ios/RNLuciq/LuciqCrashReportingBridge.m +68 -0
  149. package/ios/RNLuciq/LuciqFeatureRequestsBridge.h +30 -0
  150. package/ios/RNLuciq/LuciqFeatureRequestsBridge.m +61 -0
  151. package/ios/RNLuciq/LuciqNetworkLoggerBridge.h +44 -0
  152. package/ios/RNLuciq/LuciqNetworkLoggerBridge.m +206 -0
  153. package/ios/RNLuciq/LuciqReactBridge.h +151 -0
  154. package/ios/RNLuciq/LuciqReactBridge.m +548 -0
  155. package/ios/RNLuciq/LuciqRepliesBridge.h +40 -0
  156. package/ios/RNLuciq/LuciqRepliesBridge.m +80 -0
  157. package/ios/RNLuciq/LuciqSessionReplayBridge.h +32 -0
  158. package/ios/RNLuciq/LuciqSessionReplayBridge.m +107 -0
  159. package/ios/RNLuciq/LuciqSurveysBridge.h +46 -0
  160. package/ios/RNLuciq/LuciqSurveysBridge.m +107 -0
  161. package/ios/RNLuciq/RCTConvert+LuciqEnums.h +18 -0
  162. package/ios/RNLuciq/RCTConvert+LuciqEnums.m +127 -0
  163. package/ios/RNLuciq/RNLuciq.h +35 -0
  164. package/ios/RNLuciq/RNLuciq.m +107 -0
  165. package/ios/RNLuciq/Util/LCQAPM+PrivateAPIs.h +15 -0
  166. package/ios/RNLuciq/Util/LCQCrashReporting+CP.h +13 -0
  167. package/ios/RNLuciq/Util/LCQNetworkLogger+CP.h +68 -0
  168. package/ios/RNLuciq/Util/Luciq+CP.h +12 -0
  169. package/ios/RNLuciq.xcodeproj/project.pbxproj +352 -0
  170. package/ios/native.rb +12 -0
  171. package/ios/sourcemaps.sh +120 -0
  172. package/migrate.js +569 -0
  173. package/package.json +92 -0
  174. package/plugin/build/index.js +42078 -0
  175. package/plugin/src/index.ts +5 -0
  176. package/plugin/src/pluginProps.ts +6 -0
  177. package/plugin/src/withLuciq.ts +51 -0
  178. package/plugin/src/withLuciqAndroid.ts +99 -0
  179. package/plugin/src/withLuciqIOS.ts +109 -0
  180. package/plugin/tsconfig.json +7 -0
  181. package/react-native.config.js +16 -0
  182. package/scripts/customize-ios-endpoints.sh +28 -0
  183. package/scripts/dream-11-delete-unused-features.sh +62 -0
  184. package/scripts/find-token.js +58 -0
  185. package/scripts/find-token.sh +70 -0
  186. package/scripts/notify-github.sh +15 -0
  187. package/scripts/replace.js +58 -0
  188. package/scripts/snapshot-comment.md +15 -0
  189. package/scripts/snapshot-version.sh +11 -0
  190. package/src/index.ts +40 -0
  191. package/src/models/FeatureFlag.ts +12 -0
  192. package/src/models/LuciqConfig.ts +48 -0
  193. package/src/models/NonFatalOptions.ts +16 -0
  194. package/src/models/OverAirUpdate.ts +14 -0
  195. package/src/models/Report.ts +124 -0
  196. package/src/models/ReproConfig.ts +31 -0
  197. package/src/models/SessionMetadata.ts +57 -0
  198. package/src/models/ThemeConfig.ts +34 -0
  199. package/src/models/W3cExternalTraceAttributes.ts +22 -0
  200. package/src/modules/APM.ts +117 -0
  201. package/src/modules/BugReporting.ts +254 -0
  202. package/src/modules/CrashReporting.ts +54 -0
  203. package/src/modules/FeatureRequests.ts +32 -0
  204. package/src/modules/Luciq.ts +934 -0
  205. package/src/modules/NetworkLogger.ts +270 -0
  206. package/src/modules/Replies.ts +137 -0
  207. package/src/modules/SessionReplay.ts +111 -0
  208. package/src/modules/Surveys.ts +118 -0
  209. package/src/native/NativeAPM.ts +51 -0
  210. package/src/native/NativeBugReporting.ts +70 -0
  211. package/src/native/NativeConstants.ts +215 -0
  212. package/src/native/NativeCrashReporting.ts +29 -0
  213. package/src/native/NativeFeatureRequests.ts +12 -0
  214. package/src/native/NativeLuciq.ts +179 -0
  215. package/src/native/NativeNetworkLogger.ts +42 -0
  216. package/src/native/NativePackage.ts +25 -0
  217. package/src/native/NativeReplies.ts +34 -0
  218. package/src/native/NativeSessionReplay.ts +21 -0
  219. package/src/native/NativeSurveys.ts +34 -0
  220. package/src/promise.d.ts +11 -0
  221. package/src/utils/AppStatesHandler.ts +19 -0
  222. package/src/utils/Enums.ts +266 -0
  223. package/src/utils/FeatureFlags.ts +33 -0
  224. package/src/utils/LuciqConstants.ts +24 -0
  225. package/src/utils/LuciqUtils.ts +417 -0
  226. package/src/utils/UnhandledRejectionTracking.ts +118 -0
  227. package/src/utils/XhrNetworkInterceptor.ts +333 -0
  228. package/src/utils/config.ts +7 -0
  229. package/src/utils/logger.ts +54 -0
  230. package/tsconfig.json +32 -0
  231. package/tsconfig.test.json +4 -0
  232. package/tsconfig.upload.json +10 -0
  233. package/upload/index.d.ts +4 -0
  234. package/upload/index.js +17314 -0
  235. package/upload/migrate.d.ts +14 -0
  236. package/upload/package.json +5 -0
  237. package/upload/uploadEasUpdatesSourcemaps.d.ts +21 -0
  238. package/upload/uploadSoFiles.d.ts +21 -0
  239. package/upload/uploadSourcemaps.d.ts +21 -0
@@ -0,0 +1,52 @@
1
+ import type { RequestHandler } from '@apollo/client';
2
+ import { NetworkData, ProgressCallback } from '../utils/XhrNetworkInterceptor';
3
+ import { NetworkListenerType } from '../native/NativeNetworkLogger';
4
+ export type { NetworkData };
5
+ export type NetworkDataObfuscationHandler = (data: NetworkData) => Promise<NetworkData>;
6
+ /**
7
+ * Sets whether network logs should be sent with bug reports.
8
+ * It is enabled by default.
9
+ * @param isEnabled
10
+ */
11
+ export declare const setEnabled: (isEnabled: boolean) => void;
12
+ /**
13
+ * @internal
14
+ * Sets whether enabling or disabling native network interception.
15
+ * It is disabled by default.
16
+ * @param isEnabled
17
+ */
18
+ export declare const setNativeInterceptionEnabled: (isEnabled: boolean) => void;
19
+ export declare const getNetworkDataObfuscationHandler: () => NetworkDataObfuscationHandler | null | undefined;
20
+ export declare const getRequestFilterExpression: () => string;
21
+ export declare const hasRequestFilterExpression: () => boolean;
22
+ /**
23
+ * Obfuscates any response data.
24
+ * @param handler
25
+ */
26
+ export declare const setNetworkDataObfuscationHandler: (handler?: NetworkDataObfuscationHandler | null | undefined) => void;
27
+ /**
28
+ * Omit requests from being logged based on either their request or response details
29
+ * @param expression
30
+ */
31
+ export declare const setRequestFilterExpression: (expression: string) => void;
32
+ /**
33
+ * Returns progress in terms of totalBytesSent and totalBytesExpectedToSend a network request.
34
+ * @param handler
35
+ */
36
+ export declare const setProgressHandlerForRequest: (handler: ProgressCallback) => void;
37
+ export declare const apolloLinkRequestHandler: RequestHandler;
38
+ /**
39
+ * Sets whether network body logs will be captured or not.
40
+ * @param isEnabled
41
+ */
42
+ export declare const setNetworkLogBodyEnabled: (isEnabled: boolean) => void;
43
+ /**
44
+ * @internal
45
+ * Exported for internal/testing purposes only.
46
+ */
47
+ export declare const resetNetworkListener: () => void;
48
+ /**
49
+ * @internal
50
+ * Exported for internal/testing purposes only.
51
+ */
52
+ export declare const registerNetworkLogsListener: (type: NetworkListenerType, handler?: ((networkSnapshot: NetworkData) => void) | undefined) => void;
@@ -0,0 +1,208 @@
1
+ import LuciqConstants from '../utils/LuciqConstants';
2
+ import xhr from '../utils/XhrNetworkInterceptor';
3
+ import { LuciqRNConfig } from '../utils/config';
4
+ import { Logger } from '../utils/logger';
5
+ import { NativeLuciq } from '../native/NativeLuciq';
6
+ import { isContentTypeNotAllowed, registerFilteringAndObfuscationListener, registerFilteringListener, registerObfuscationListener, reportNetworkLog, } from '../utils/LuciqUtils';
7
+ import { NativeNetworkLogger, NativeNetworkLoggerEvent, NetworkListenerType, NetworkLoggerEmitter, } from '../native/NativeNetworkLogger';
8
+ import { Platform } from 'react-native';
9
+ let _networkDataObfuscationHandler;
10
+ let _requestFilterExpression = 'false';
11
+ let _isNativeInterceptionEnabled = false;
12
+ let _networkListener = null;
13
+ let hasFilterExpression = false;
14
+ function getPortFromUrl(url) {
15
+ const portMatch = url.match(/:(\d+)(?=\/|$)/);
16
+ return portMatch ? portMatch[1] : null;
17
+ }
18
+ /**
19
+ * Sets whether network logs should be sent with bug reports.
20
+ * It is enabled by default.
21
+ * @param isEnabled
22
+ */
23
+ export const setEnabled = (isEnabled) => {
24
+ if (isEnabled) {
25
+ xhr.enableInterception();
26
+ xhr.setOnDoneCallback(async (network) => {
27
+ // eslint-disable-next-line no-new-func
28
+ const predicate = Function('network', 'return ' + _requestFilterExpression);
29
+ if (!predicate(network)) {
30
+ const MAX_NETWORK_BODY_SIZE_IN_BYTES = await NativeLuciq.getNetworkBodyMaxSize();
31
+ try {
32
+ if (_networkDataObfuscationHandler) {
33
+ network = await _networkDataObfuscationHandler(network);
34
+ }
35
+ if (__DEV__) {
36
+ const urlPort = getPortFromUrl(network.url);
37
+ if (urlPort === LuciqRNConfig.metroDevServerPort) {
38
+ return;
39
+ }
40
+ }
41
+ if (network.requestBodySize > MAX_NETWORK_BODY_SIZE_IN_BYTES) {
42
+ network.requestBody = `${LuciqConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE}${MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024} Kb`;
43
+ Logger.warn('LCQ-RN:', `${LuciqConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE}${MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024} Kb`);
44
+ }
45
+ if (network.responseBodySize > MAX_NETWORK_BODY_SIZE_IN_BYTES) {
46
+ network.responseBody = `${LuciqConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE}${MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024} Kb`;
47
+ Logger.warn('LCQ-RN:', `${LuciqConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE}${MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024} Kb`);
48
+ }
49
+ if (network.requestBody && isContentTypeNotAllowed(network.requestContentType)) {
50
+ network.requestBody = `Body is omitted because content type ${network.requestContentType} isn't supported`;
51
+ Logger.warn(`LCQ-RN: The request body for the network request with URL ${network.url} has been omitted because the content type ${network.requestContentType} isn't supported.`);
52
+ }
53
+ if (network.responseBody && isContentTypeNotAllowed(network.contentType)) {
54
+ network.responseBody = `Body is omitted because content type ${network.contentType} isn't supported`;
55
+ Logger.warn(`LCQ-RN: The response body for the network request with URL ${network.url} has been omitted because the content type ${network.contentType} isn't supported.`);
56
+ }
57
+ reportNetworkLog(network);
58
+ }
59
+ catch (e) {
60
+ Logger.error(e);
61
+ }
62
+ }
63
+ });
64
+ }
65
+ else {
66
+ xhr.disableInterception();
67
+ }
68
+ };
69
+ /**
70
+ * @internal
71
+ * Sets whether enabling or disabling native network interception.
72
+ * It is disabled by default.
73
+ * @param isEnabled
74
+ */
75
+ export const setNativeInterceptionEnabled = (isEnabled) => {
76
+ _isNativeInterceptionEnabled = isEnabled;
77
+ };
78
+ export const getNetworkDataObfuscationHandler = () => _networkDataObfuscationHandler;
79
+ export const getRequestFilterExpression = () => _requestFilterExpression;
80
+ export const hasRequestFilterExpression = () => hasFilterExpression;
81
+ /**
82
+ * Obfuscates any response data.
83
+ * @param handler
84
+ */
85
+ export const setNetworkDataObfuscationHandler = (handler) => {
86
+ _networkDataObfuscationHandler = handler;
87
+ if (_isNativeInterceptionEnabled && Platform.OS === 'ios') {
88
+ if (hasFilterExpression) {
89
+ registerFilteringAndObfuscationListener(_requestFilterExpression);
90
+ }
91
+ else {
92
+ registerObfuscationListener();
93
+ }
94
+ }
95
+ };
96
+ /**
97
+ * Omit requests from being logged based on either their request or response details
98
+ * @param expression
99
+ */
100
+ export const setRequestFilterExpression = (expression) => {
101
+ _requestFilterExpression = expression;
102
+ hasFilterExpression = true;
103
+ if (_isNativeInterceptionEnabled && Platform.OS === 'ios') {
104
+ if (_networkDataObfuscationHandler) {
105
+ registerFilteringAndObfuscationListener(_requestFilterExpression);
106
+ }
107
+ else {
108
+ registerFilteringListener(_requestFilterExpression);
109
+ }
110
+ }
111
+ };
112
+ /**
113
+ * Returns progress in terms of totalBytesSent and totalBytesExpectedToSend a network request.
114
+ * @param handler
115
+ */
116
+ export const setProgressHandlerForRequest = (handler) => {
117
+ xhr.setOnProgressCallback(handler);
118
+ };
119
+ export const apolloLinkRequestHandler = (operation, forward) => {
120
+ try {
121
+ operation.setContext((context) => {
122
+ const newHeaders = context.headers ?? {};
123
+ newHeaders[LuciqConstants.GRAPHQL_HEADER] = operation.operationName;
124
+ return { headers: newHeaders };
125
+ });
126
+ }
127
+ catch (e) {
128
+ Logger.error(e);
129
+ }
130
+ return forward(operation);
131
+ };
132
+ /**
133
+ * Sets whether network body logs will be captured or not.
134
+ * @param isEnabled
135
+ */
136
+ export const setNetworkLogBodyEnabled = (isEnabled) => {
137
+ NativeLuciq.setNetworkLogBodyEnabled(isEnabled);
138
+ };
139
+ /**
140
+ * @internal
141
+ * Exported for internal/testing purposes only.
142
+ */
143
+ export const resetNetworkListener = () => {
144
+ if (process.env.NODE_ENV === 'test') {
145
+ _networkListener = null;
146
+ NativeNetworkLogger.resetNetworkLogsListener();
147
+ }
148
+ else {
149
+ Logger.error(`${LuciqConstants.LCQ_APM_TAG}: The \`resetNetworkListener()\` method is intended solely for testing purposes.`);
150
+ }
151
+ };
152
+ /**
153
+ * @internal
154
+ * Exported for internal/testing purposes only.
155
+ */
156
+ export const registerNetworkLogsListener = (type, handler) => {
157
+ if (Platform.OS === 'ios') {
158
+ // remove old listeners
159
+ if (NetworkLoggerEmitter.listenerCount(NativeNetworkLoggerEvent.NETWORK_LOGGER_HANDLER) > 0) {
160
+ NetworkLoggerEmitter.removeAllListeners(NativeNetworkLoggerEvent.NETWORK_LOGGER_HANDLER);
161
+ }
162
+ if (_networkListener == null) {
163
+ // set new listener.
164
+ _networkListener = type;
165
+ }
166
+ else {
167
+ // attach a new listener to the existing one.
168
+ _networkListener = NetworkListenerType.both;
169
+ }
170
+ }
171
+ NetworkLoggerEmitter.addListener(NativeNetworkLoggerEvent.NETWORK_LOGGER_HANDLER, (networkSnapshot) => {
172
+ // Mapping the data [Native -> React-Native].
173
+ const { id, url, requestHeader, requestBody, responseHeader, response, responseCode } = networkSnapshot;
174
+ const networkSnapshotObj = {
175
+ id: id,
176
+ url: url,
177
+ requestBody: requestBody,
178
+ requestHeaders: requestHeader,
179
+ method: '',
180
+ responseBody: response,
181
+ responseCode: responseCode,
182
+ responseHeaders: responseHeader,
183
+ contentType: '',
184
+ duration: 0,
185
+ requestBodySize: 0,
186
+ responseBodySize: 0,
187
+ errorDomain: '',
188
+ errorCode: 0,
189
+ startTime: 0,
190
+ serverErrorMessage: '',
191
+ requestContentType: '',
192
+ isW3cHeaderFound: true,
193
+ networkStartTimeInSeconds: 0,
194
+ partialId: 0,
195
+ w3cCaughtHeader: '',
196
+ w3cGeneratedHeader: '',
197
+ };
198
+ if (handler) {
199
+ handler(networkSnapshotObj);
200
+ }
201
+ });
202
+ if (Platform.OS === 'ios') {
203
+ NativeNetworkLogger.registerNetworkLogsListener(_networkListener ?? NetworkListenerType.both);
204
+ }
205
+ else {
206
+ NativeNetworkLogger.registerNetworkLogsListener();
207
+ }
208
+ };
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Enables and disables everything related to receiving replies.
3
+ * @param isEnabled
4
+ */
5
+ export declare const setEnabled: (isEnabled: boolean) => void;
6
+ /**
7
+ * Tells whether the user has chats already or not.
8
+ */
9
+ export declare const hasChats: () => Promise<boolean>;
10
+ /**
11
+ * Manual invocation for replies.
12
+ */
13
+ export declare const show: () => void;
14
+ /**
15
+ * Sets a block of code that gets executed when a new message is received.
16
+ * @param handler A callback that gets executed when a new message is received.
17
+ */
18
+ export declare const setOnNewReplyReceivedHandler: (handler: () => void) => void;
19
+ /**
20
+ * Returns the number of unread messages the user currently has.
21
+ * Use this method to get the number of unread messages the user
22
+ * has, then possibly notify them about it with your own UI.
23
+ * Notifications count, or -1 in case the SDK has not been initialized.
24
+ */
25
+ export declare const getUnreadRepliesCount: () => Promise<number>;
26
+ /**
27
+ * Enables/disables showing in-app notifications when the user receives a
28
+ * new message.
29
+ * @param isEnabled A boolean to set whether
30
+ * notifications are enabled or disabled.
31
+ */
32
+ export declare const setInAppNotificationsEnabled: (isEnabled: boolean) => void;
33
+ /**
34
+ * Set whether new in app notification received will play a small sound notification
35
+ * or not (Default is {@code false})
36
+ * @android
37
+ *
38
+ * @param isEnabled desired state of conversation sounds
39
+ */
40
+ export declare const setInAppNotificationSound: (isEnabled: boolean) => void;
41
+ /**
42
+ * Enables/disables the use of push notifications in the SDK.
43
+ * Defaults to YES.
44
+ * @param isEnabled A boolean to indicate whether push notifications are enabled or disabled.
45
+ */
46
+ export declare const setPushNotificationsEnabled: (isEnabled: boolean) => void;
47
+ /**
48
+ * Set the GCM registration token to Luciq
49
+ *
50
+ * @param token the GCM registration token
51
+ */
52
+ export declare const setPushNotificationRegistrationTokenAndroid: (token: string) => void;
53
+ /**
54
+ * Show in-app Messaging's notifications
55
+ *
56
+ * @param data the data bundle related to Luciq
57
+ */
58
+ export declare const showNotificationAndroid: (data: Record<string, string>) => void;
59
+ /**
60
+ * Set the push notification's icon that will be shown with Luciq notifications
61
+ *
62
+ * @param resourceId the notification icon resource ID
63
+ */
64
+ export declare const setNotificationIconAndroid: (resourceId: number) => void;
65
+ /**
66
+ * Set a notification channel id to a notification channel that notifications
67
+ * can be posted to.
68
+ *
69
+ * @param id an id to a notification channel that notifications
70
+ */
71
+ export declare const setPushNotificationChannelIdAndroid: (id: string) => void;
72
+ /**
73
+ * Set whether new system notification received will play the default sound from
74
+ * RingtoneManager or not (Default is {@code false})
75
+ *
76
+ * @param isEnabled desired state of conversation sounds
77
+ */
78
+ export declare const setSystemReplyNotificationSoundEnabledAndroid: (isEnabled: boolean) => void;
@@ -0,0 +1,121 @@
1
+ import { Platform } from 'react-native';
2
+ import { NativeEvents, NativeReplies, emitter } from '../native/NativeReplies';
3
+ /**
4
+ * Enables and disables everything related to receiving replies.
5
+ * @param isEnabled
6
+ */
7
+ export const setEnabled = (isEnabled) => {
8
+ NativeReplies.setEnabled(isEnabled);
9
+ };
10
+ /**
11
+ * Tells whether the user has chats already or not.
12
+ */
13
+ export const hasChats = async () => {
14
+ const result = await NativeReplies.hasChats();
15
+ return result;
16
+ };
17
+ /**
18
+ * Manual invocation for replies.
19
+ */
20
+ export const show = () => {
21
+ NativeReplies.show();
22
+ };
23
+ /**
24
+ * Sets a block of code that gets executed when a new message is received.
25
+ * @param handler A callback that gets executed when a new message is received.
26
+ */
27
+ export const setOnNewReplyReceivedHandler = (handler) => {
28
+ emitter.addListener(NativeEvents.ON_REPLY_RECEIVED_HANDLER, handler);
29
+ NativeReplies.setOnNewReplyReceivedHandler(handler);
30
+ };
31
+ /**
32
+ * Returns the number of unread messages the user currently has.
33
+ * Use this method to get the number of unread messages the user
34
+ * has, then possibly notify them about it with your own UI.
35
+ * Notifications count, or -1 in case the SDK has not been initialized.
36
+ */
37
+ export const getUnreadRepliesCount = async () => {
38
+ const count = await NativeReplies.getUnreadRepliesCount();
39
+ return count;
40
+ };
41
+ /**
42
+ * Enables/disables showing in-app notifications when the user receives a
43
+ * new message.
44
+ * @param isEnabled A boolean to set whether
45
+ * notifications are enabled or disabled.
46
+ */
47
+ export const setInAppNotificationsEnabled = (isEnabled) => {
48
+ NativeReplies.setInAppNotificationEnabled(isEnabled);
49
+ };
50
+ /**
51
+ * Set whether new in app notification received will play a small sound notification
52
+ * or not (Default is {@code false})
53
+ * @android
54
+ *
55
+ * @param isEnabled desired state of conversation sounds
56
+ */
57
+ export const setInAppNotificationSound = (isEnabled) => {
58
+ if (Platform.OS === 'android') {
59
+ NativeReplies.setInAppNotificationSound(isEnabled);
60
+ }
61
+ };
62
+ /**
63
+ * Enables/disables the use of push notifications in the SDK.
64
+ * Defaults to YES.
65
+ * @param isEnabled A boolean to indicate whether push notifications are enabled or disabled.
66
+ */
67
+ export const setPushNotificationsEnabled = (isEnabled) => {
68
+ NativeReplies.setPushNotificationsEnabled(isEnabled);
69
+ };
70
+ /**
71
+ * Set the GCM registration token to Luciq
72
+ *
73
+ * @param token the GCM registration token
74
+ */
75
+ export const setPushNotificationRegistrationTokenAndroid = (token) => {
76
+ if (Platform.OS === 'android') {
77
+ NativeReplies.setPushNotificationRegistrationToken(token);
78
+ }
79
+ };
80
+ /**
81
+ * Show in-app Messaging's notifications
82
+ *
83
+ * @param data the data bundle related to Luciq
84
+ */
85
+ export const showNotificationAndroid = (data) => {
86
+ if (Platform.OS === 'android') {
87
+ NativeReplies.showNotification(data);
88
+ }
89
+ };
90
+ /**
91
+ * Set the push notification's icon that will be shown with Luciq notifications
92
+ *
93
+ * @param resourceId the notification icon resource ID
94
+ */
95
+ export const setNotificationIconAndroid = (resourceId) => {
96
+ if (Platform.OS === 'android') {
97
+ NativeReplies.setNotificationIcon(resourceId);
98
+ }
99
+ };
100
+ /**
101
+ * Set a notification channel id to a notification channel that notifications
102
+ * can be posted to.
103
+ *
104
+ * @param id an id to a notification channel that notifications
105
+ */
106
+ export const setPushNotificationChannelIdAndroid = (id) => {
107
+ if (Platform.OS === 'android') {
108
+ NativeReplies.setPushNotificationChannelId(id);
109
+ }
110
+ };
111
+ /**
112
+ * Set whether new system notification received will play the default sound from
113
+ * RingtoneManager or not (Default is {@code false})
114
+ *
115
+ * @param isEnabled desired state of conversation sounds
116
+ */
117
+ export const setSystemReplyNotificationSoundEnabledAndroid = (isEnabled) => {
118
+ if (Platform.OS === 'android') {
119
+ NativeReplies.setSystemReplyNotificationSoundEnabled(isEnabled);
120
+ }
121
+ };
@@ -0,0 +1,78 @@
1
+ import type { SessionMetadata } from '../models/SessionMetadata';
2
+ /**
3
+ * Enables or disables Session Replay for your Luciq integration.
4
+ *
5
+ * By default, Session Replay is enabled if it is available in your current plan
6
+ *
7
+ * @param isEnabled
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * SessionReplay.setEnabled(true);
12
+ * ```
13
+ */
14
+ export declare const setEnabled: (isEnabled: boolean) => void;
15
+ /**
16
+ * Enables or disables network logs for Session Replay.
17
+ *
18
+ * By default, network logs are enabled.
19
+ *
20
+ * @param isEnabled
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * SessionReplay.setNetworkLogsEnabled(true);
25
+ * ```
26
+ */
27
+ export declare const setNetworkLogsEnabled: (isEnabled: boolean) => void;
28
+ /**
29
+ * Enables or disables Luciq logs for Session Replay.
30
+ *
31
+ * By default, Luciq logs are enabled.
32
+ *
33
+ * @param isEnabled
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * SessionReplay.setLuciqLogsEnabled(true);
38
+ * ```
39
+ */
40
+ export declare const setLuciqLogsEnabled: (isEnabled: boolean) => void;
41
+ /**
42
+ * Enables or disables capturing of user steps for Session Replay.
43
+ *
44
+ * By default, user steps are enabled.
45
+ *
46
+ * @param isEnabled
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * SessionReplay.setUserStepsEnabled(true);
51
+ * ```
52
+ */
53
+ export declare const setUserStepsEnabled: (isEnabled: boolean) => void;
54
+ /**
55
+ * Retrieves current session's replay link.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * SessionReplay.getSessionReplayLink();
60
+ * ```
61
+ */
62
+ export declare const getSessionReplayLink: () => Promise<string>;
63
+ /**
64
+ * Set a callback for whether this session should sync
65
+ *
66
+ * @param handler
67
+
68
+ * @example
69
+ * ```ts
70
+ * SessionReplay.setSyncCallback((metadata) => {
71
+ * return metadata.device == "Xiaomi M2007J3SY" &&
72
+ * metadata.os == "OS Level 33" &&
73
+ * metadata.appVersion == "3.1.4 (4)" ||
74
+ * metadata.sessionDurationInSeconds > 20;
75
+ * });
76
+ * ```
77
+ */
78
+ export declare const setSyncCallback: (handler: (payload: SessionMetadata) => boolean) => Promise<void>;
@@ -0,0 +1,98 @@
1
+ import { NativeSessionReplay, NativeEvents, emitter } from '../native/NativeSessionReplay';
2
+ /**
3
+ * Enables or disables Session Replay for your Luciq integration.
4
+ *
5
+ * By default, Session Replay is enabled if it is available in your current plan
6
+ *
7
+ * @param isEnabled
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * SessionReplay.setEnabled(true);
12
+ * ```
13
+ */
14
+ export const setEnabled = (isEnabled) => {
15
+ NativeSessionReplay.setEnabled(isEnabled);
16
+ };
17
+ /**
18
+ * Enables or disables network logs for Session Replay.
19
+ *
20
+ * By default, network logs are enabled.
21
+ *
22
+ * @param isEnabled
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * SessionReplay.setNetworkLogsEnabled(true);
27
+ * ```
28
+ */
29
+ export const setNetworkLogsEnabled = (isEnabled) => {
30
+ NativeSessionReplay.setNetworkLogsEnabled(isEnabled);
31
+ };
32
+ /**
33
+ * Enables or disables Luciq logs for Session Replay.
34
+ *
35
+ * By default, Luciq logs are enabled.
36
+ *
37
+ * @param isEnabled
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * SessionReplay.setLuciqLogsEnabled(true);
42
+ * ```
43
+ */
44
+ export const setLuciqLogsEnabled = (isEnabled) => {
45
+ NativeSessionReplay.setLuciqLogsEnabled(isEnabled);
46
+ };
47
+ /**
48
+ * Enables or disables capturing of user steps for Session Replay.
49
+ *
50
+ * By default, user steps are enabled.
51
+ *
52
+ * @param isEnabled
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * SessionReplay.setUserStepsEnabled(true);
57
+ * ```
58
+ */
59
+ export const setUserStepsEnabled = (isEnabled) => {
60
+ NativeSessionReplay.setUserStepsEnabled(isEnabled);
61
+ };
62
+ /**
63
+ * Retrieves current session's replay link.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * SessionReplay.getSessionReplayLink();
68
+ * ```
69
+ */
70
+ export const getSessionReplayLink = async () => {
71
+ return NativeSessionReplay.getSessionReplayLink();
72
+ };
73
+ /**
74
+ * Set a callback for whether this session should sync
75
+ *
76
+ * @param handler
77
+
78
+ * @example
79
+ * ```ts
80
+ * SessionReplay.setSyncCallback((metadata) => {
81
+ * return metadata.device == "Xiaomi M2007J3SY" &&
82
+ * metadata.os == "OS Level 33" &&
83
+ * metadata.appVersion == "3.1.4 (4)" ||
84
+ * metadata.sessionDurationInSeconds > 20;
85
+ * });
86
+ * ```
87
+ */
88
+ export const setSyncCallback = async (handler) => {
89
+ emitter.addListener(NativeEvents.SESSION_REPLAY_ON_SYNC_CALLBACK_INVOCATION, (payload) => {
90
+ const result = handler(payload);
91
+ const shouldSync = Boolean(result);
92
+ if (typeof result !== 'boolean') {
93
+ console.warn(`LCQ-RN: The callback passed to SessionReplay.setSyncCallback was expected to return a boolean but returned "${result}". The value has been cast to boolean, proceeding with ${shouldSync}.`);
94
+ }
95
+ NativeSessionReplay.evaluateSync(shouldSync);
96
+ });
97
+ return NativeSessionReplay.setSyncCallback();
98
+ };