@quiltt/react-native 3.6.2 → 3.6.4

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/src/index.ts CHANGED
@@ -6,19 +6,6 @@ if (!global.atob) {
6
6
  global.atob = decode
7
7
  }
8
8
 
9
- /* export type {
10
- ConnectorSDK,
11
- ConnectorSDKCallbacks,
12
- ConnectorSDKOnEventCallback,
13
- ConnectorSDKOnLoadCallback,
14
- ConnectorSDKOnExitSuccessCallback,
15
- ConnectorSDKOnExitAbortCallback,
16
- ConnectorSDKOnExitErrorCallback,
17
- ConnectorSDKEventType,
18
- ConnectorSDKCallbackMetadata,
19
- ConnectorSDKConnectOptions,
20
- } */
21
-
22
9
  export * from '@quiltt/core'
23
10
 
24
11
  export {
@@ -0,0 +1,47 @@
1
+ import { getErrorMessage, ErrorReporter } from '../error'
2
+ import { Platform } from 'react-native'
3
+
4
+ const errorReporter = new ErrorReporter(`${Platform.OS} ${Platform.Version}`)
5
+ const PREFLIGHT_RETRY_COUNT = 3
6
+
7
+ export type PreFlightCheck = {
8
+ checked: boolean
9
+ error?: string
10
+ }
11
+
12
+ export const checkConnectorUrl = async (
13
+ connectorUrl: string,
14
+ retryCount = 0
15
+ ): Promise<PreFlightCheck> => {
16
+ let responseStatus
17
+ let error
18
+ let errorOccurred = false
19
+ try {
20
+ const response = await fetch(connectorUrl)
21
+ if (!response.ok) {
22
+ console.error(`The URL ${connectorUrl} is not routable.`)
23
+ responseStatus = response.status
24
+ errorOccurred = true
25
+ } else {
26
+ console.log(`The URL ${connectorUrl} is routable.`)
27
+ return { checked: true }
28
+ }
29
+ } catch (e) {
30
+ error = e
31
+ console.error(`An error occurred while checking the connector URL: ${error}`)
32
+ errorOccurred = true
33
+ }
34
+
35
+ if (errorOccurred && retryCount < PREFLIGHT_RETRY_COUNT) {
36
+ const delay = 50 * Math.pow(2, retryCount)
37
+ await new Promise((resolve) => setTimeout(resolve, delay))
38
+ console.log(`Retrying... Attempt number ${retryCount + 1}`)
39
+ return checkConnectorUrl(connectorUrl, retryCount + 1)
40
+ }
41
+
42
+ const errorMessage = getErrorMessage(responseStatus, error as Error)
43
+ const errorToSend = (error as Error) || new Error(errorMessage)
44
+ const context = { connectorUrl, responseStatus }
45
+ if (responseStatus !== 404) await errorReporter.send(errorToSend, context)
46
+ return { checked: true, error: errorMessage }
47
+ }
@@ -0,0 +1,9 @@
1
+ import { Linking } from 'react-native'
2
+
3
+ export const handleOAuthUrl = (oauthUrl: URL) => {
4
+ if (oauthUrl.protocol !== 'https:') {
5
+ console.log(`handleOAuthUrl - Skipping non https url - ${oauthUrl.href}`)
6
+ return
7
+ }
8
+ Linking.openURL(oauthUrl.href)
9
+ }
File without changes
@@ -0,0 +1,2 @@
1
+ export * from './checkConnectorUrl'
2
+ export * from './handleOAuthUrl'
@@ -1,10 +1,9 @@
1
1
  // Quick hack to send error to Honeybadger to debug why the connector is not routable
2
-
3
2
  import type { Notice, NoticeTransportPayload } from '@honeybadger-io/core/build/src/types'
4
3
  import { generateStackTrace, getCauses, makeBacktrace } from '@honeybadger-io/core/build/src/util'
5
4
 
6
5
  import { ErrorReporterConfig } from './ErrorReporterConfig'
7
- import { version } from '../version'
6
+ import { version } from '../../version'
8
7
 
9
8
  const notifier = {
10
9
  name: 'Quiltt React Native SDK Reporter',
@@ -1,4 +1,3 @@
1
-
2
1
  export const ErrorReporterConfig = {
3
2
  honeybadger_api_key: 'undefined',
4
3
  }
@@ -1,9 +1,7 @@
1
- const getErrorMessage = (responseStatus?: number, error?: Error): string => {
1
+ export const getErrorMessage = (responseStatus?: number, error?: Error): string => {
2
2
  if (error)
3
3
  return `An error occurred while checking the connector URL: ${error?.name} \n${error?.message}`
4
4
  return responseStatus
5
5
  ? `The URL is not routable. Response status: ${responseStatus}`
6
6
  : 'An error occurred while checking the connector URL'
7
7
  }
8
-
9
- export { getErrorMessage }
@@ -0,0 +1,2 @@
1
+ export * from './ErrorReporter'
2
+ export * from './getErrorMessage'
@@ -1,2 +1,2 @@
1
- export * from './ErrorReporter'
2
- export * from './getErrorMessage'
1
+ export * from './connector'
2
+ export * from './error'
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '3.6.2'
2
+ export const version = '3.6.4'