@quiltt/react-native 4.5.1 → 5.0.1
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/CHANGELOG.md +34 -0
- package/README.md +7 -1
- package/dist/components/index.cjs +534 -0
- package/dist/components/index.d.ts +27 -0
- package/dist/components/index.js +530 -0
- package/dist/index.cjs +76 -0
- package/dist/index.d.ts +3 -27
- package/dist/index.js +3 -642
- package/dist/providers/index.cjs +107 -0
- package/dist/providers/index.d.ts +24 -0
- package/dist/providers/index.js +100 -0
- package/dist/utils/index.cjs +221 -0
- package/dist/utils/index.d.ts +66 -0
- package/dist/utils/index.js +201 -0
- package/package.json +30 -10
- package/src/components/QuilttConnector.tsx +30 -8
- package/src/index.ts +24 -2
- package/src/providers/QuilttAuthProvider.tsx +46 -0
- package/src/providers/QuilttProvider.tsx +30 -0
- package/src/providers/index.ts +2 -0
- package/src/utils/error/ErrorReporter.ts +31 -88
- package/src/utils/index.ts +1 -0
- package/src/utils/telemetry.ts +97 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Platform } from 'react-native'
|
|
3
|
+
|
|
4
|
+
import { getUserAgent as coreGetUserAgent } from '@quiltt/core'
|
|
5
|
+
import DeviceInfo from 'react-native-device-info'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets the React version from the runtime
|
|
9
|
+
*/
|
|
10
|
+
export const getReactVersion = (): string => {
|
|
11
|
+
return React.version || 'unknown'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the React Native version from Platform constants
|
|
16
|
+
*/
|
|
17
|
+
export const getReactNativeVersion = (): string => {
|
|
18
|
+
try {
|
|
19
|
+
const rnVersion = Platform.constants?.reactNativeVersion
|
|
20
|
+
if (rnVersion) {
|
|
21
|
+
return `${rnVersion.major}.${rnVersion.minor}.${rnVersion.patch}`
|
|
22
|
+
}
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.warn('Failed to get React Native version:', error)
|
|
25
|
+
}
|
|
26
|
+
return 'unknown'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Gets OS information (platform and version)
|
|
31
|
+
*/
|
|
32
|
+
export const getOSInfo = (): string => {
|
|
33
|
+
try {
|
|
34
|
+
const os = Platform.OS // 'ios' or 'android'
|
|
35
|
+
const osVersion = Platform.Version // string (iOS) or number (Android)
|
|
36
|
+
|
|
37
|
+
// Map platform names to correct capitalization
|
|
38
|
+
const platformNames: Record<string, string> = {
|
|
39
|
+
ios: 'iOS',
|
|
40
|
+
android: 'Android',
|
|
41
|
+
}
|
|
42
|
+
const osName = platformNames[os] || 'Unknown'
|
|
43
|
+
|
|
44
|
+
return `${osName}/${osVersion}`
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.warn('Failed to get OS info:', error)
|
|
47
|
+
return 'Unknown/Unknown'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Gets device model information
|
|
53
|
+
*/
|
|
54
|
+
export const getDeviceModel = async (): Promise<string> => {
|
|
55
|
+
try {
|
|
56
|
+
const model = await DeviceInfo.getModel()
|
|
57
|
+
return model || 'Unknown'
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.warn('Failed to get device model:', error)
|
|
60
|
+
return 'Unknown'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Generates platform information string for React Native
|
|
66
|
+
* Format: React/<version>; ReactNative/<version>; <OS>/<version>; <device-model>
|
|
67
|
+
*/
|
|
68
|
+
export const getPlatformInfo = async (): Promise<string> => {
|
|
69
|
+
const reactVersion = getReactVersion()
|
|
70
|
+
const rnVersion = getReactNativeVersion()
|
|
71
|
+
const osInfo = getOSInfo()
|
|
72
|
+
const deviceModel = await getDeviceModel()
|
|
73
|
+
|
|
74
|
+
return `React/${reactVersion}; ReactNative/${rnVersion}; ${osInfo}; ${deviceModel}`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Synchronously generates platform information string for React Native
|
|
79
|
+
* Format: React/<version>; ReactNative/<version>; <OS>/<version>; Unknown
|
|
80
|
+
* Note: Device model is set to 'Unknown' since it requires async DeviceInfo call
|
|
81
|
+
*/
|
|
82
|
+
export const getPlatformInfoSync = (): string => {
|
|
83
|
+
const reactVersion = getReactVersion()
|
|
84
|
+
const rnVersion = getReactNativeVersion()
|
|
85
|
+
const osInfo = getOSInfo()
|
|
86
|
+
|
|
87
|
+
return `React/${reactVersion}; ReactNative/${rnVersion}; ${osInfo}; Unknown`
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Generates User-Agent string for React Native SDK
|
|
92
|
+
* Format: Quiltt/<sdk-version> (React/<version>; ReactNative/<version>; <OS>/<version>; <device-model>)
|
|
93
|
+
*/
|
|
94
|
+
export const getUserAgent = async (sdkVersion: string): Promise<string> => {
|
|
95
|
+
const platformInfo = await getPlatformInfo()
|
|
96
|
+
return coreGetUserAgent(sdkVersion, platformInfo)
|
|
97
|
+
}
|