@billdog.io/react-native 1.0.0-beta.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.
Files changed (309) hide show
  1. package/BillDogReactNative.podspec +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +330 -0
  4. package/android/build.gradle +99 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/kotlin/io/billdog/reactnative/BillDogABTestModule.kt +317 -0
  7. package/android/src/main/kotlin/io/billdog/reactnative/BillDogAnalyticsModule.kt +389 -0
  8. package/android/src/main/kotlin/io/billdog/reactnative/BillDogModule.kt +817 -0
  9. package/android/src/main/kotlin/io/billdog/reactnative/BillDogPaywallViewManager.kt +383 -0
  10. package/android/src/main/kotlin/io/billdog/reactnative/BillDogSurveyModule.kt +427 -0
  11. package/android/src/main/kotlin/io/billdog/reactnative/BillDogVirtualCurrencyModule.kt +407 -0
  12. package/android/src/main/kotlin/io/billdog/virtualcurrency/BillDogVirtualCurrencyPackage.kt +44 -0
  13. package/dist/AdvancedPaywallCache.d.ts +70 -0
  14. package/dist/AdvancedPaywallCache.js +344 -0
  15. package/dist/BillDog.d.ts +255 -0
  16. package/dist/BillDog.js +918 -0
  17. package/dist/BillDogConfiguration.d.ts +145 -0
  18. package/dist/BillDogConfiguration.js +229 -0
  19. package/dist/ComponentRenderer.d.ts +17 -0
  20. package/dist/ComponentRenderer.js +886 -0
  21. package/dist/LayoutEngine.d.ts +101 -0
  22. package/dist/LayoutEngine.js +394 -0
  23. package/dist/LocalizationResolver.d.ts +99 -0
  24. package/dist/LocalizationResolver.js +266 -0
  25. package/dist/NativePaywallView.d.ts +36 -0
  26. package/dist/NativePaywallView.js +59 -0
  27. package/dist/PaywallCache.d.ts +74 -0
  28. package/dist/PaywallCache.js +293 -0
  29. package/dist/PaywallStateManager.d.ts +62 -0
  30. package/dist/PaywallStateManager.js +147 -0
  31. package/dist/PaywallView.d.ts +42 -0
  32. package/dist/PaywallView.js +275 -0
  33. package/dist/ProductVariableProvider.d.ts +60 -0
  34. package/dist/ProductVariableProvider.js +239 -0
  35. package/dist/VariableResolver.d.ts +120 -0
  36. package/dist/VariableResolver.js +379 -0
  37. package/dist/WebViewPaywall.d.ts +75 -0
  38. package/dist/WebViewPaywall.js +360 -0
  39. package/dist/animations/presets.d.ts +49 -0
  40. package/dist/animations/presets.js +367 -0
  41. package/dist/components/AccoladeCpsComponent.d.ts +13 -0
  42. package/dist/components/AccoladeCpsComponent.js +248 -0
  43. package/dist/components/AccordionComponent.d.ts +10 -0
  44. package/dist/components/AccordionComponent.js +187 -0
  45. package/dist/components/AnimatedWrapper.d.ts +35 -0
  46. package/dist/components/AnimatedWrapper.js +277 -0
  47. package/dist/components/CarouselComponent.d.ts +23 -0
  48. package/dist/components/CarouselComponent.js +484 -0
  49. package/dist/components/ChartCurveComponent.d.ts +13 -0
  50. package/dist/components/ChartCurveComponent.js +333 -0
  51. package/dist/components/CheckboxComponent.d.ts +9 -0
  52. package/dist/components/CheckboxComponent.js +172 -0
  53. package/dist/components/ConfettiComponent.d.ts +9 -0
  54. package/dist/components/ConfettiComponent.js +172 -0
  55. package/dist/components/CountdownComponent.d.ts +16 -0
  56. package/dist/components/CountdownComponent.js +414 -0
  57. package/dist/components/DelayedXComponent.d.ts +12 -0
  58. package/dist/components/DelayedXComponent.js +240 -0
  59. package/dist/components/DrawerModalComponent.d.ts +20 -0
  60. package/dist/components/DrawerModalComponent.js +286 -0
  61. package/dist/components/GradientView.d.ts +38 -0
  62. package/dist/components/GradientView.js +126 -0
  63. package/dist/components/HapticFeedbackComponent.d.ts +16 -0
  64. package/dist/components/HapticFeedbackComponent.js +64 -0
  65. package/dist/components/HorizontalProductsComponent.d.ts +17 -0
  66. package/dist/components/HorizontalProductsComponent.js +284 -0
  67. package/dist/components/MultiChoiceGridComponent.d.ts +13 -0
  68. package/dist/components/MultiChoiceGridComponent.js +234 -0
  69. package/dist/components/NPSScaleComponent.d.ts +16 -0
  70. package/dist/components/NPSScaleComponent.js +260 -0
  71. package/dist/components/NavigationComponent.d.ts +26 -0
  72. package/dist/components/NavigationComponent.js +302 -0
  73. package/dist/components/OAuthButtonComponent.d.ts +20 -0
  74. package/dist/components/OAuthButtonComponent.js +237 -0
  75. package/dist/components/ProgressLoaderComponent.d.ts +13 -0
  76. package/dist/components/ProgressLoaderComponent.js +308 -0
  77. package/dist/components/ProgressStepperComponent.d.ts +18 -0
  78. package/dist/components/ProgressStepperComponent.js +228 -0
  79. package/dist/components/SegmentedPickerComponent.d.ts +10 -0
  80. package/dist/components/SegmentedPickerComponent.js +221 -0
  81. package/dist/components/ShareButtonsComponent.d.ts +21 -0
  82. package/dist/components/ShareButtonsComponent.js +265 -0
  83. package/dist/components/ShareCodeComponent.d.ts +16 -0
  84. package/dist/components/ShareCodeComponent.js +274 -0
  85. package/dist/components/SingleChoiceGridComponent.d.ts +13 -0
  86. package/dist/components/SingleChoiceGridComponent.js +210 -0
  87. package/dist/components/SliderComponent.d.ts +9 -0
  88. package/dist/components/SliderComponent.js +263 -0
  89. package/dist/components/StarRatingInputComponent.d.ts +20 -0
  90. package/dist/components/StarRatingInputComponent.js +198 -0
  91. package/dist/components/StickerCompositeComponent.d.ts +13 -0
  92. package/dist/components/StickerCompositeComponent.js +136 -0
  93. package/dist/components/TabsComponent.d.ts +19 -0
  94. package/dist/components/TabsComponent.js +431 -0
  95. package/dist/components/TextInputComponent.d.ts +18 -0
  96. package/dist/components/TextInputComponent.js +227 -0
  97. package/dist/components/TimelineComponent.d.ts +19 -0
  98. package/dist/components/TimelineComponent.js +104 -0
  99. package/dist/components/ToggleComponent.d.ts +14 -0
  100. package/dist/components/ToggleComponent.js +132 -0
  101. package/dist/components/VerticalProductsComponent.d.ts +17 -0
  102. package/dist/components/VerticalProductsComponent.js +311 -0
  103. package/dist/dynamicValues.d.ts +36 -0
  104. package/dist/dynamicValues.js +142 -0
  105. package/dist/filters/dateFilters.d.ts +50 -0
  106. package/dist/filters/dateFilters.js +390 -0
  107. package/dist/filters/index.d.ts +18 -0
  108. package/dist/filters/index.js +253 -0
  109. package/dist/hooks/useOfferings.d.ts +76 -0
  110. package/dist/hooks/useOfferings.js +99 -0
  111. package/dist/hooks/usePaywall.d.ts +27 -0
  112. package/dist/hooks/usePaywall.js +114 -0
  113. package/dist/hooks/usePlacement.d.ts +34 -0
  114. package/dist/hooks/usePlacement.js +89 -0
  115. package/dist/hooks/useSubscription.d.ts +40 -0
  116. package/dist/hooks/useSubscription.js +97 -0
  117. package/dist/index.d.ts +98 -0
  118. package/dist/index.js +198 -0
  119. package/dist/models/BillDogError.d.ts +40 -0
  120. package/dist/models/BillDogError.js +11 -0
  121. package/dist/models/CacheFetchPolicy.d.ts +8 -0
  122. package/dist/models/CacheFetchPolicy.js +4 -0
  123. package/dist/models/CustomProduct.d.ts +32 -0
  124. package/dist/models/CustomProduct.js +15 -0
  125. package/dist/models/CustomerInfo.d.ts +17 -0
  126. package/dist/models/CustomerInfo.js +11 -0
  127. package/dist/models/Delegate.d.ts +20 -0
  128. package/dist/models/Delegate.js +11 -0
  129. package/dist/models/EntitlementInfo.d.ts +19 -0
  130. package/dist/models/EntitlementInfo.js +2 -0
  131. package/dist/models/Placement.d.ts +54 -0
  132. package/dist/models/Placement.js +15 -0
  133. package/dist/models/PurchaseParams.d.ts +39 -0
  134. package/dist/models/PurchaseParams.js +60 -0
  135. package/dist/models/PurchaseResult.d.ts +30 -0
  136. package/dist/models/PurchaseResult.js +15 -0
  137. package/dist/models/RestoreResult.d.ts +30 -0
  138. package/dist/models/RestoreResult.js +22 -0
  139. package/dist/models/RestoredItem.d.ts +26 -0
  140. package/dist/models/RestoredItem.js +13 -0
  141. package/dist/modules/ABTest.d.ts +65 -0
  142. package/dist/modules/ABTest.js +113 -0
  143. package/dist/modules/Analytics.d.ts +91 -0
  144. package/dist/modules/Analytics.js +182 -0
  145. package/dist/modules/Survey.d.ts +65 -0
  146. package/dist/modules/Survey.js +82 -0
  147. package/dist/modules/VirtualCurrency.d.ts +63 -0
  148. package/dist/modules/VirtualCurrency.js +147 -0
  149. package/dist/murmur.d.ts +23 -0
  150. package/dist/murmur.js +104 -0
  151. package/dist/notifications/LiveActivitiesManager.d.ts +47 -0
  152. package/dist/notifications/LiveActivitiesManager.js +106 -0
  153. package/dist/notifications/NotificationScheduler.d.ts +55 -0
  154. package/dist/notifications/NotificationScheduler.js +199 -0
  155. package/dist/notifications/PurchaseNotificationHandler.d.ts +24 -0
  156. package/dist/notifications/PurchaseNotificationHandler.js +55 -0
  157. package/dist/notifications/useDeviceToken.d.ts +36 -0
  158. package/dist/notifications/useDeviceToken.js +97 -0
  159. package/dist/notifications/useLiveActivity.d.ts +39 -0
  160. package/dist/notifications/useLiveActivity.js +104 -0
  161. package/dist/review/ReviewAnalytics.d.ts +34 -0
  162. package/dist/review/ReviewAnalytics.js +73 -0
  163. package/dist/review/ReviewManager.d.ts +83 -0
  164. package/dist/review/ReviewManager.js +339 -0
  165. package/dist/review/ReviewTimingManager.d.ts +82 -0
  166. package/dist/review/ReviewTimingManager.js +224 -0
  167. package/dist/survey-core/types.d.ts +215 -0
  168. package/dist/survey-core/types.js +8 -0
  169. package/dist/types.d.ts +438 -0
  170. package/dist/types.js +158 -0
  171. package/dist/utils/ApiClient.d.ts +65 -0
  172. package/dist/utils/ApiClient.js +132 -0
  173. package/dist/utils/CSSConverter.d.ts +49 -0
  174. package/dist/utils/CSSConverter.js +470 -0
  175. package/dist/utils/animations.d.ts +41 -0
  176. package/dist/utils/animations.js +194 -0
  177. package/dist/utils/calendarIntegration.d.ts +36 -0
  178. package/dist/utils/calendarIntegration.js +89 -0
  179. package/dist/utils/configurationResolver.d.ts +23 -0
  180. package/dist/utils/configurationResolver.js +78 -0
  181. package/dist/utils/deviceDetection.d.ts +38 -0
  182. package/dist/utils/deviceDetection.js +59 -0
  183. package/dist/utils/hapticFeedback.d.ts +17 -0
  184. package/dist/utils/hapticFeedback.js +53 -0
  185. package/dist/utils/iconMapper.d.ts +26 -0
  186. package/dist/utils/iconMapper.js +113 -0
  187. package/dist/utils/notificationPermissions.d.ts +13 -0
  188. package/dist/utils/notificationPermissions.js +51 -0
  189. package/dist/utils/priceFormatting.d.ts +19 -0
  190. package/dist/utils/priceFormatting.js +99 -0
  191. package/dist/utils/shareSheet.d.ts +17 -0
  192. package/dist/utils/shareSheet.js +42 -0
  193. package/dist/utils/subscriptionUpgrade.d.ts +84 -0
  194. package/dist/utils/subscriptionUpgrade.js +100 -0
  195. package/dist/valueUtils.d.ts +48 -0
  196. package/dist/valueUtils.js +129 -0
  197. package/dist/xFlowTags.d.ts +18 -0
  198. package/dist/xFlowTags.js +385 -0
  199. package/ios/BillDogABTest.m +50 -0
  200. package/ios/BillDogABTest.swift +188 -0
  201. package/ios/BillDogAnalytics.m +105 -0
  202. package/ios/BillDogAnalytics.swift +324 -0
  203. package/ios/BillDogBridge.m +222 -0
  204. package/ios/BillDogBridge.swift +715 -0
  205. package/ios/BillDogLiveActivities.m +41 -0
  206. package/ios/BillDogLiveActivities.swift +104 -0
  207. package/ios/BillDogPaywallViewManager.m +39 -0
  208. package/ios/BillDogPaywallViewManager.swift +361 -0
  209. package/ios/BillDogSurvey.m +34 -0
  210. package/ios/BillDogSurvey.swift +257 -0
  211. package/ios/BillDogVirtualCurrencyBridge.m +63 -0
  212. package/ios/BillDogVirtualCurrencyBridge.swift +511 -0
  213. package/junit.xml +25 -0
  214. package/package.json +61 -0
  215. package/react-native.config.js +13 -0
  216. package/src/AdvancedPaywallCache.ts +433 -0
  217. package/src/BillDog.ts +983 -0
  218. package/src/BillDogConfiguration.ts +318 -0
  219. package/src/ComponentRenderer.tsx +1325 -0
  220. package/src/LayoutEngine.ts +459 -0
  221. package/src/LocalizationResolver.ts +311 -0
  222. package/src/NativePaywallView.tsx +132 -0
  223. package/src/PaywallCache.ts +358 -0
  224. package/src/PaywallStateManager.ts +154 -0
  225. package/src/PaywallView.tsx +328 -0
  226. package/src/ProductVariableProvider.ts +282 -0
  227. package/src/VariableResolver.ts +516 -0
  228. package/src/WebViewPaywall.tsx +454 -0
  229. package/src/animations/presets.ts +421 -0
  230. package/src/components/AccoladeCpsComponent.tsx +259 -0
  231. package/src/components/AccordionComponent.tsx +213 -0
  232. package/src/components/AnimatedWrapper.tsx +316 -0
  233. package/src/components/CarouselComponent.tsx +615 -0
  234. package/src/components/ChartCurveComponent.tsx +452 -0
  235. package/src/components/CheckboxComponent.tsx +185 -0
  236. package/src/components/ConfettiComponent.tsx +178 -0
  237. package/src/components/CountdownComponent.tsx +454 -0
  238. package/src/components/DelayedXComponent.tsx +266 -0
  239. package/src/components/DrawerModalComponent.tsx +324 -0
  240. package/src/components/GradientView.tsx +129 -0
  241. package/src/components/HapticFeedbackComponent.tsx +39 -0
  242. package/src/components/HorizontalProductsComponent.tsx +329 -0
  243. package/src/components/MultiChoiceGridComponent.tsx +265 -0
  244. package/src/components/NPSScaleComponent.tsx +294 -0
  245. package/src/components/NavigationComponent.tsx +329 -0
  246. package/src/components/OAuthButtonComponent.tsx +266 -0
  247. package/src/components/ProgressLoaderComponent.tsx +366 -0
  248. package/src/components/ProgressStepperComponent.tsx +250 -0
  249. package/src/components/SegmentedPickerComponent.tsx +245 -0
  250. package/src/components/ShareButtonsComponent.tsx +299 -0
  251. package/src/components/ShareCodeComponent.tsx +303 -0
  252. package/src/components/SingleChoiceGridComponent.tsx +229 -0
  253. package/src/components/SliderComponent.tsx +280 -0
  254. package/src/components/StarRatingInputComponent.tsx +223 -0
  255. package/src/components/StickerCompositeComponent.tsx +168 -0
  256. package/src/components/TabsComponent.tsx +496 -0
  257. package/src/components/TextInputComponent.tsx +258 -0
  258. package/src/components/TimelineComponent.tsx +129 -0
  259. package/src/components/ToggleComponent.tsx +142 -0
  260. package/src/components/VerticalProductsComponent.tsx +357 -0
  261. package/src/dynamicValues.ts +180 -0
  262. package/src/filters/dateFilters.ts +411 -0
  263. package/src/filters/index.ts +281 -0
  264. package/src/hooks/useOfferings.ts +192 -0
  265. package/src/hooks/usePaywall.ts +154 -0
  266. package/src/hooks/usePlacement.ts +143 -0
  267. package/src/hooks/useSubscription.ts +154 -0
  268. package/src/index.ts +245 -0
  269. package/src/models/BillDogError.ts +24 -0
  270. package/src/models/CacheFetchPolicy.ts +13 -0
  271. package/src/models/CustomProduct.ts +33 -0
  272. package/src/models/CustomerInfo.ts +26 -0
  273. package/src/models/Delegate.ts +22 -0
  274. package/src/models/EntitlementInfo.ts +27 -0
  275. package/src/models/Placement.ts +50 -0
  276. package/src/models/PurchaseParams.ts +81 -0
  277. package/src/models/PurchaseResult.ts +32 -0
  278. package/src/models/RestoreResult.ts +27 -0
  279. package/src/models/RestoredItem.ts +25 -0
  280. package/src/modules/ABTest.ts +131 -0
  281. package/src/modules/Analytics.ts +227 -0
  282. package/src/modules/Survey.ts +126 -0
  283. package/src/modules/VirtualCurrency.ts +223 -0
  284. package/src/murmur.ts +102 -0
  285. package/src/notifications/LiveActivitiesManager.ts +140 -0
  286. package/src/notifications/NotificationScheduler.ts +292 -0
  287. package/src/notifications/PurchaseNotificationHandler.ts +67 -0
  288. package/src/notifications/useDeviceToken.ts +116 -0
  289. package/src/notifications/useLiveActivity.ts +125 -0
  290. package/src/review/ReviewAnalytics.ts +89 -0
  291. package/src/review/ReviewManager.ts +355 -0
  292. package/src/review/ReviewTimingManager.ts +265 -0
  293. package/src/survey-core/types.ts +244 -0
  294. package/src/types/ambient.d.ts +9 -0
  295. package/src/types.ts +680 -0
  296. package/src/utils/ApiClient.ts +163 -0
  297. package/src/utils/CSSConverter.ts +552 -0
  298. package/src/utils/animations.ts +232 -0
  299. package/src/utils/calendarIntegration.ts +113 -0
  300. package/src/utils/configurationResolver.ts +106 -0
  301. package/src/utils/deviceDetection.ts +83 -0
  302. package/src/utils/hapticFeedback.ts +55 -0
  303. package/src/utils/iconMapper.ts +102 -0
  304. package/src/utils/notificationPermissions.ts +48 -0
  305. package/src/utils/priceFormatting.ts +119 -0
  306. package/src/utils/shareSheet.ts +55 -0
  307. package/src/utils/subscriptionUpgrade.ts +183 -0
  308. package/src/valueUtils.ts +108 -0
  309. package/src/xFlowTags.ts +463 -0
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useDeviceToken = useDeviceToken;
7
+ exports.registerDeviceToken = registerDeviceToken;
8
+ const react_1 = require("react");
9
+ const react_native_push_notification_1 = __importDefault(require("react-native-push-notification"));
10
+ const react_native_1 = require("react-native");
11
+ const ApiClient_1 = require("../utils/ApiClient");
12
+ /**
13
+ * Hook to register device token for push notifications.
14
+ * Automatically registers the device token when the component mounts.
15
+ *
16
+ * Credentials are resolved from `BillDogConfiguration` by default.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * import { useDeviceToken } from '@billdog.io/react-native';
21
+ *
22
+ * function App() {
23
+ * useDeviceToken({
24
+ * userId: 'user-123',
25
+ * projectId: 'project-456',
26
+ * onTokenRegistered: (token) => console.log('Token registered:', token),
27
+ * });
28
+ *
29
+ * return <YourApp />;
30
+ * }
31
+ * ```
32
+ */
33
+ function useDeviceToken({ userId, projectId, apiKey: apiKeyOverride, onTokenRegistered, onError, }) {
34
+ const registeredRef = (0, react_1.useRef)(false);
35
+ (0, react_1.useEffect)(() => {
36
+ if (registeredRef.current)
37
+ return;
38
+ const registerToken = async () => {
39
+ try {
40
+ react_native_push_notification_1.default.configure({
41
+ onRegister: async (tokenData) => {
42
+ try {
43
+ const token = tokenData.token;
44
+ const platform = react_native_1.Platform.OS;
45
+ await ApiClient_1.ApiClient.post('register-device-token', {
46
+ userId,
47
+ projectId,
48
+ token,
49
+ platform,
50
+ }, {
51
+ apiKey: apiKeyOverride,
52
+ });
53
+ registeredRef.current = true;
54
+ onTokenRegistered === null || onTokenRegistered === void 0 ? void 0 : onTokenRegistered(token);
55
+ }
56
+ catch (error) {
57
+ console.error('Failed to register device token:', error);
58
+ onError === null || onError === void 0 ? void 0 : onError(error);
59
+ }
60
+ },
61
+ onNotification: (notification) => {
62
+ console.log('Notification received:', notification);
63
+ },
64
+ permissions: {
65
+ alert: true,
66
+ badge: true,
67
+ sound: true,
68
+ },
69
+ popInitialNotification: true,
70
+ requestPermissions: true,
71
+ });
72
+ }
73
+ catch (error) {
74
+ console.error('Failed to register device token:', error);
75
+ onError === null || onError === void 0 ? void 0 : onError(error);
76
+ }
77
+ };
78
+ registerToken();
79
+ return () => {
80
+ react_native_push_notification_1.default.unregister();
81
+ };
82
+ }, [userId, projectId, apiKeyOverride, onTokenRegistered, onError]);
83
+ }
84
+ /**
85
+ * Manually register a device token.
86
+ * Resolves the endpoint from BillDogConfiguration (api.billdog.io/v1).
87
+ */
88
+ async function registerDeviceToken(token, userId, projectId, apiKey, platform) {
89
+ await ApiClient_1.ApiClient.post('register-device-token', {
90
+ userId,
91
+ projectId,
92
+ token,
93
+ platform: platform || 'ios',
94
+ }, {
95
+ apiKey,
96
+ });
97
+ }
@@ -0,0 +1,39 @@
1
+ import { LiveActivityConfig, LiveActivityUpdate } from './LiveActivitiesManager';
2
+ export interface UseLiveActivityOptions {
3
+ autoStart?: boolean;
4
+ config?: LiveActivityConfig;
5
+ }
6
+ export interface UseLiveActivityReturn {
7
+ activityId: string | null;
8
+ isActive: boolean;
9
+ isSupported: boolean;
10
+ areEnabled: boolean;
11
+ startActivity: (config: LiveActivityConfig) => Promise<string>;
12
+ updateActivity: (update: LiveActivityUpdate) => Promise<void>;
13
+ endActivity: (finalState?: Record<string, any>) => Promise<void>;
14
+ error: Error | null;
15
+ }
16
+ /**
17
+ * React hook for managing a Live Activity
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * const { activityId, isActive, startActivity, updateActivity, endActivity } = useLiveActivity();
22
+ *
23
+ * // Start activity
24
+ * await startActivity({
25
+ * activityType: 'order_tracking',
26
+ * attributes: { orderNumber: '12345' },
27
+ * contentState: { status: 'preparing' }
28
+ * });
29
+ *
30
+ * // Update activity
31
+ * await updateActivity({
32
+ * contentState: { status: 'shipped' }
33
+ * });
34
+ *
35
+ * // End activity
36
+ * await endActivity({ status: 'delivered' });
37
+ * ```
38
+ */
39
+ export declare function useLiveActivity(options?: UseLiveActivityOptions): UseLiveActivityReturn;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLiveActivity = useLiveActivity;
4
+ const react_1 = require("react");
5
+ const LiveActivitiesManager_1 = require("./LiveActivitiesManager");
6
+ /**
7
+ * React hook for managing a Live Activity
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const { activityId, isActive, startActivity, updateActivity, endActivity } = useLiveActivity();
12
+ *
13
+ * // Start activity
14
+ * await startActivity({
15
+ * activityType: 'order_tracking',
16
+ * attributes: { orderNumber: '12345' },
17
+ * contentState: { status: 'preparing' }
18
+ * });
19
+ *
20
+ * // Update activity
21
+ * await updateActivity({
22
+ * contentState: { status: 'shipped' }
23
+ * });
24
+ *
25
+ * // End activity
26
+ * await endActivity({ status: 'delivered' });
27
+ * ```
28
+ */
29
+ function useLiveActivity(options = {}) {
30
+ const [activityId, setActivityId] = (0, react_1.useState)(null);
31
+ const [isSupported, setIsSupported] = (0, react_1.useState)(false);
32
+ const [areEnabled, setAreEnabled] = (0, react_1.useState)(false);
33
+ const [error, setError] = (0, react_1.useState)(null);
34
+ (0, react_1.useEffect)(() => {
35
+ const checkSupport = async () => {
36
+ const supported = LiveActivitiesManager_1.liveActivities.isSupported();
37
+ setIsSupported(supported);
38
+ if (supported) {
39
+ const enabled = await LiveActivitiesManager_1.liveActivities.areActivitiesEnabled();
40
+ setAreEnabled(enabled);
41
+ }
42
+ };
43
+ checkSupport();
44
+ }, []);
45
+ (0, react_1.useEffect)(() => {
46
+ if (options.autoStart && options.config && isSupported && areEnabled && !activityId) {
47
+ startActivity(options.config).catch((err) => {
48
+ console.error('[useLiveActivity] Auto-start failed:', err);
49
+ });
50
+ }
51
+ }, [options.autoStart, options.config, isSupported, areEnabled, activityId]);
52
+ const startActivity = (0, react_1.useCallback)(async (config) => {
53
+ try {
54
+ setError(null);
55
+ const id = await LiveActivitiesManager_1.liveActivities.startActivity(config);
56
+ setActivityId(id);
57
+ return id;
58
+ }
59
+ catch (err) {
60
+ const error = err instanceof Error ? err : new Error('Failed to start activity');
61
+ setError(error);
62
+ throw error;
63
+ }
64
+ }, []);
65
+ const updateActivity = (0, react_1.useCallback)(async (update) => {
66
+ if (!activityId) {
67
+ throw new Error('No active activity to update');
68
+ }
69
+ try {
70
+ setError(null);
71
+ await LiveActivitiesManager_1.liveActivities.updateActivity(activityId, update);
72
+ }
73
+ catch (err) {
74
+ const error = err instanceof Error ? err : new Error('Failed to update activity');
75
+ setError(error);
76
+ throw error;
77
+ }
78
+ }, [activityId]);
79
+ const endActivity = (0, react_1.useCallback)(async (finalState) => {
80
+ if (!activityId) {
81
+ throw new Error('No active activity to end');
82
+ }
83
+ try {
84
+ setError(null);
85
+ await LiveActivitiesManager_1.liveActivities.endActivity(activityId, finalState);
86
+ setActivityId(null);
87
+ }
88
+ catch (err) {
89
+ const error = err instanceof Error ? err : new Error('Failed to end activity');
90
+ setError(error);
91
+ throw error;
92
+ }
93
+ }, [activityId]);
94
+ return {
95
+ activityId,
96
+ isActive: !!activityId,
97
+ isSupported,
98
+ areEnabled,
99
+ startActivity,
100
+ updateActivity,
101
+ endActivity,
102
+ error,
103
+ };
104
+ }
@@ -0,0 +1,34 @@
1
+ export interface ReviewAnalyticsEvent {
2
+ eventType: 'requested' | 'shown' | 'dismissed' | 'completed' | 'error';
3
+ platform: 'ios' | 'android' | 'other';
4
+ customerId?: string;
5
+ sdkVersion?: string;
6
+ appVersion?: string;
7
+ osVersion?: string;
8
+ deviceModel?: string;
9
+ success?: boolean;
10
+ errorMessage?: string;
11
+ timeToShowMs?: number;
12
+ userContext?: Record<string, any>;
13
+ metadata?: Record<string, any>;
14
+ }
15
+ export declare class ReviewAnalytics {
16
+ /**
17
+ * @deprecated No longer needed. Credentials are read from BillDogConfiguration.
18
+ * This method is a no-op retained for backward compatibility.
19
+ */
20
+ static initialize(_apiKey: string, _projectUrl: string): void;
21
+ /**
22
+ * Track a review event via the canonical `ingest-events` pipeline.
23
+ *
24
+ * Event naming follows `review_<eventType>` to preserve historical
25
+ * `bdanalytics_events.event_name` values written by the deprecated
26
+ * `track?type=review` router. Analytics surfaces (MessagingAnalytics,
27
+ * useReport, analytics-query) require no schema change.
28
+ *
29
+ * Per `mem://architecture/analytics-system-standard`: `ingest-events` is
30
+ * the sole analytics ingestion endpoint. Do not introduce alternative paths.
31
+ */
32
+ static trackEvent(event: ReviewAnalyticsEvent): Promise<void>;
33
+ private static getPlatform;
34
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReviewAnalytics = void 0;
4
+ const react_native_1 = require("react-native");
5
+ const BillDogConfiguration_1 = require("../BillDogConfiguration");
6
+ const ApiClient_1 = require("../utils/ApiClient");
7
+ class ReviewAnalytics {
8
+ /**
9
+ * @deprecated No longer needed. Credentials are read from BillDogConfiguration.
10
+ * This method is a no-op retained for backward compatibility.
11
+ */
12
+ static initialize(_apiKey, _projectUrl) {
13
+ console.warn('[ReviewAnalytics] initialize() is deprecated. ' +
14
+ 'Credentials are now read from BillDogConfiguration.configure(). This call is a no-op.');
15
+ }
16
+ /**
17
+ * Track a review event via the canonical `ingest-events` pipeline.
18
+ *
19
+ * Event naming follows `review_<eventType>` to preserve historical
20
+ * `bdanalytics_events.event_name` values written by the deprecated
21
+ * `track?type=review` router. Analytics surfaces (MessagingAnalytics,
22
+ * useReport, analytics-query) require no schema change.
23
+ *
24
+ * Per `mem://architecture/analytics-system-standard`: `ingest-events` is
25
+ * the sole analytics ingestion endpoint. Do not introduce alternative paths.
26
+ */
27
+ static async trackEvent(event) {
28
+ if (BillDogConfiguration_1.BillDogConfiguration.config.analyticsEnabled === false) {
29
+ console.log('[ReviewAnalytics] Analytics disabled, skipping event:', event.eventType);
30
+ return;
31
+ }
32
+ if (!BillDogConfiguration_1.BillDogConfiguration.isConfigured()) {
33
+ console.warn('[ReviewAnalytics] BillDogConfiguration not configured. Call BillDogConfiguration.configure() first.');
34
+ return;
35
+ }
36
+ const platform = event.platform || this.getPlatform();
37
+ const properties = {
38
+ platform,
39
+ sdk_version: event.sdkVersion,
40
+ app_version: event.appVersion,
41
+ os_version: event.osVersion || react_native_1.Platform.Version.toString(),
42
+ device_model: event.deviceModel,
43
+ success: event.success,
44
+ error_message: event.errorMessage,
45
+ time_to_show_ms: event.timeToShowMs,
46
+ user_context: event.userContext,
47
+ ...(event.metadata || {}),
48
+ };
49
+ try {
50
+ await ApiClient_1.ApiClient.post('ingest-events', {
51
+ events: [
52
+ {
53
+ event_name: `review_${event.eventType}`,
54
+ timestamp: new Date().toISOString(),
55
+ distinct_id: event.customerId,
56
+ properties,
57
+ },
58
+ ],
59
+ });
60
+ }
61
+ catch (error) {
62
+ console.error('[ReviewAnalytics] Error tracking event:', error);
63
+ }
64
+ }
65
+ static getPlatform() {
66
+ if (react_native_1.Platform.OS === 'ios')
67
+ return 'ios';
68
+ if (react_native_1.Platform.OS === 'android')
69
+ return 'android';
70
+ return 'other';
71
+ }
72
+ }
73
+ exports.ReviewAnalytics = ReviewAnalytics;
@@ -0,0 +1,83 @@
1
+ import { ReviewTimingConfig } from './ReviewTimingManager';
2
+ /**
3
+ * Initialize review timing manager with configuration
4
+ * Call this on app launch to enable smart timing
5
+ *
6
+ * @param config - Timing configuration options
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { initializeReviewTiming } from '@billdog.io/react-native';
11
+ *
12
+ * await initializeReviewTiming({
13
+ * minDaysSinceInstall: 7,
14
+ * minSessionCount: 5,
15
+ * minSignificantEvents: 3,
16
+ * enableAutomaticTiming: true,
17
+ * });
18
+ * ```
19
+ */
20
+ export declare function initializeReviewTiming(config?: ReviewTimingConfig): Promise<void>;
21
+ /**
22
+ * Record a new app session (call on app launch)
23
+ */
24
+ export declare function recordReviewSession(): Promise<void>;
25
+ /**
26
+ * Record a significant event (e.g., purchase, completed action)
27
+ * These events help determine optimal timing for review requests
28
+ */
29
+ export declare function recordSignificantEvent(): Promise<void>;
30
+ /**
31
+ * Check if it's a good time to request a review based on timing logic
32
+ *
33
+ * @returns Object with shouldRequest flag, reason, and timing data
34
+ */
35
+ export declare function shouldRequestReview(): Promise<{
36
+ shouldRequest: boolean;
37
+ reason?: string;
38
+ timingData?: any;
39
+ }>;
40
+ /**
41
+ * Request in-app review from the user
42
+ * Optionally checks timing logic before showing
43
+ *
44
+ * @param options - Options for review request
45
+ * @param options.checkTiming - Whether to check timing logic before showing (default: true)
46
+ * @returns Promise with success status and whether review was shown
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { requestReview } from '@billdog.io/react-native';
51
+ *
52
+ * const { success, shown } = await requestReview();
53
+ * if (shown) {
54
+ * console.log('Review prompt shown to user');
55
+ * }
56
+ * ```
57
+ */
58
+ export declare function requestReview(options?: {
59
+ checkTiming?: boolean;
60
+ }): Promise<{
61
+ success: boolean;
62
+ shown: boolean;
63
+ reason?: string;
64
+ }>;
65
+ /**
66
+ * Check if review request is available
67
+ * Respects platform rate limiting
68
+ *
69
+ * @returns Promise with availability status
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import { canRequestReview } from '@billdog.io/react-native';
74
+ *
75
+ * const { available } = await canRequestReview();
76
+ * if (available) {
77
+ * await requestReview();
78
+ * }
79
+ * ```
80
+ */
81
+ export declare function canRequestReview(): Promise<{
82
+ available: boolean;
83
+ }>;