@loyalytics/swan-react-native-sdk 2.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.
Files changed (204) hide show
  1. package/LICENSE +55 -0
  2. package/README.md +67 -0
  3. package/docs/IOS_NOTIFICATION_EXTENSION_SETUP.md +335 -0
  4. package/ios/README.md +64 -0
  5. package/ios/SwanNotificationServiceExtension/Info.plist +31 -0
  6. package/ios/SwanNotificationServiceExtension/NotificationService.swift +337 -0
  7. package/ios/SwanNotificationServiceExtension/SwanNotificationServiceExtension.entitlements +10 -0
  8. package/lib/commonjs/components/FooterView.js +125 -0
  9. package/lib/commonjs/components/FooterView.js.map +1 -0
  10. package/lib/commonjs/components/FullScreenView.js +172 -0
  11. package/lib/commonjs/components/FullScreenView.js.map +1 -0
  12. package/lib/commonjs/components/HeaderView.js +205 -0
  13. package/lib/commonjs/components/HeaderView.js.map +1 -0
  14. package/lib/commonjs/components/PopUpView.js +186 -0
  15. package/lib/commonjs/components/PopUpView.js.map +1 -0
  16. package/lib/commonjs/config/BatchConfig.js +53 -0
  17. package/lib/commonjs/config/BatchConfig.js.map +1 -0
  18. package/lib/commonjs/constants/ApiUrls.js +56 -0
  19. package/lib/commonjs/constants/ApiUrls.js.map +1 -0
  20. package/lib/commonjs/core/EventQueueManager.js +345 -0
  21. package/lib/commonjs/core/EventQueueManager.js.map +1 -0
  22. package/lib/commonjs/core/FlushManager.js +245 -0
  23. package/lib/commonjs/core/FlushManager.js.map +1 -0
  24. package/lib/commonjs/core/NetworkMonitor.js +97 -0
  25. package/lib/commonjs/core/NetworkMonitor.js.map +1 -0
  26. package/lib/commonjs/index.js +3506 -0
  27. package/lib/commonjs/index.js.map +1 -0
  28. package/lib/commonjs/providers/FirebasePushProvider.js +130 -0
  29. package/lib/commonjs/providers/FirebasePushProvider.js.map +1 -0
  30. package/lib/commonjs/providers/NullPushProvider.js +59 -0
  31. package/lib/commonjs/providers/NullPushProvider.js.map +1 -0
  32. package/lib/commonjs/providers/PushNotificationProvider.js +30 -0
  33. package/lib/commonjs/providers/PushNotificationProvider.js.map +1 -0
  34. package/lib/commonjs/services/DeviceRegistrationService.js +248 -0
  35. package/lib/commonjs/services/DeviceRegistrationService.js.map +1 -0
  36. package/lib/commonjs/services/PushTokenService.js +284 -0
  37. package/lib/commonjs/services/PushTokenService.js.map +1 -0
  38. package/lib/commonjs/state/AuthStateMachine.js +161 -0
  39. package/lib/commonjs/state/AuthStateMachine.js.map +1 -0
  40. package/lib/commonjs/state/DeviceStateMachine.js +104 -0
  41. package/lib/commonjs/state/DeviceStateMachine.js.map +1 -0
  42. package/lib/commonjs/state/PushStateMachine.js +129 -0
  43. package/lib/commonjs/state/PushStateMachine.js.map +1 -0
  44. package/lib/commonjs/types/EventQueue.js +50 -0
  45. package/lib/commonjs/types/EventQueue.js.map +1 -0
  46. package/lib/commonjs/types/SDK.js +2 -0
  47. package/lib/commonjs/types/SDK.js.map +1 -0
  48. package/lib/commonjs/utils/FirebaseNotificationManager.js +492 -0
  49. package/lib/commonjs/utils/FirebaseNotificationManager.js.map +1 -0
  50. package/lib/commonjs/utils/Logger.js +56 -0
  51. package/lib/commonjs/utils/Logger.js.map +1 -0
  52. package/lib/commonjs/utils/SharedCredentialsManager.js +146 -0
  53. package/lib/commonjs/utils/SharedCredentialsManager.js.map +1 -0
  54. package/lib/commonjs/version.js +12 -0
  55. package/lib/commonjs/version.js.map +1 -0
  56. package/lib/module/components/FooterView.js +121 -0
  57. package/lib/module/components/FooterView.js.map +1 -0
  58. package/lib/module/components/FullScreenView.js +167 -0
  59. package/lib/module/components/FullScreenView.js.map +1 -0
  60. package/lib/module/components/HeaderView.js +199 -0
  61. package/lib/module/components/HeaderView.js.map +1 -0
  62. package/lib/module/components/PopUpView.js +181 -0
  63. package/lib/module/components/PopUpView.js.map +1 -0
  64. package/lib/module/config/BatchConfig.js +49 -0
  65. package/lib/module/config/BatchConfig.js.map +1 -0
  66. package/lib/module/constants/ApiUrls.js +52 -0
  67. package/lib/module/constants/ApiUrls.js.map +1 -0
  68. package/lib/module/core/EventQueueManager.js +340 -0
  69. package/lib/module/core/EventQueueManager.js.map +1 -0
  70. package/lib/module/core/FlushManager.js +240 -0
  71. package/lib/module/core/FlushManager.js.map +1 -0
  72. package/lib/module/core/NetworkMonitor.js +92 -0
  73. package/lib/module/core/NetworkMonitor.js.map +1 -0
  74. package/lib/module/index.js +3494 -0
  75. package/lib/module/index.js.map +1 -0
  76. package/lib/module/providers/FirebasePushProvider.js +124 -0
  77. package/lib/module/providers/FirebasePushProvider.js.map +1 -0
  78. package/lib/module/providers/NullPushProvider.js +53 -0
  79. package/lib/module/providers/NullPushProvider.js.map +1 -0
  80. package/lib/module/providers/PushNotificationProvider.js +26 -0
  81. package/lib/module/providers/PushNotificationProvider.js.map +1 -0
  82. package/lib/module/services/DeviceRegistrationService.js +243 -0
  83. package/lib/module/services/DeviceRegistrationService.js.map +1 -0
  84. package/lib/module/services/PushTokenService.js +278 -0
  85. package/lib/module/services/PushTokenService.js.map +1 -0
  86. package/lib/module/state/AuthStateMachine.js +155 -0
  87. package/lib/module/state/AuthStateMachine.js.map +1 -0
  88. package/lib/module/state/DeviceStateMachine.js +98 -0
  89. package/lib/module/state/DeviceStateMachine.js.map +1 -0
  90. package/lib/module/state/PushStateMachine.js +123 -0
  91. package/lib/module/state/PushStateMachine.js.map +1 -0
  92. package/lib/module/types/EventQueue.js +46 -0
  93. package/lib/module/types/EventQueue.js.map +1 -0
  94. package/lib/module/types/SDK.js +2 -0
  95. package/lib/module/types/SDK.js.map +1 -0
  96. package/lib/module/utils/FirebaseNotificationManager.js +486 -0
  97. package/lib/module/utils/FirebaseNotificationManager.js.map +1 -0
  98. package/lib/module/utils/Logger.js +52 -0
  99. package/lib/module/utils/Logger.js.map +1 -0
  100. package/lib/module/utils/SharedCredentialsManager.js +140 -0
  101. package/lib/module/utils/SharedCredentialsManager.js.map +1 -0
  102. package/lib/module/version.js +8 -0
  103. package/lib/module/version.js.map +1 -0
  104. package/lib/typescript/commonjs/package.json +1 -0
  105. package/lib/typescript/commonjs/src/components/FooterView.d.ts +3 -0
  106. package/lib/typescript/commonjs/src/components/FooterView.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/src/components/FullScreenView.d.ts +3 -0
  108. package/lib/typescript/commonjs/src/components/FullScreenView.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/src/components/HeaderView.d.ts +3 -0
  110. package/lib/typescript/commonjs/src/components/HeaderView.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/src/components/PopUpView.d.ts +3 -0
  112. package/lib/typescript/commonjs/src/components/PopUpView.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/config/BatchConfig.d.ts +7 -0
  114. package/lib/typescript/commonjs/src/config/BatchConfig.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/src/constants/ApiUrls.d.ts +56 -0
  116. package/lib/typescript/commonjs/src/constants/ApiUrls.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/src/core/EventQueueManager.d.ts +63 -0
  118. package/lib/typescript/commonjs/src/core/EventQueueManager.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/src/core/FlushManager.d.ts +63 -0
  120. package/lib/typescript/commonjs/src/core/FlushManager.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/src/core/NetworkMonitor.d.ts +38 -0
  122. package/lib/typescript/commonjs/src/core/NetworkMonitor.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/src/index.d.ts +663 -0
  124. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/src/providers/FirebasePushProvider.d.ts +28 -0
  126. package/lib/typescript/commonjs/src/providers/FirebasePushProvider.d.ts.map +1 -0
  127. package/lib/typescript/commonjs/src/providers/NullPushProvider.d.ts +25 -0
  128. package/lib/typescript/commonjs/src/providers/NullPushProvider.d.ts.map +1 -0
  129. package/lib/typescript/commonjs/src/providers/PushNotificationProvider.d.ts +105 -0
  130. package/lib/typescript/commonjs/src/providers/PushNotificationProvider.d.ts.map +1 -0
  131. package/lib/typescript/commonjs/src/services/DeviceRegistrationService.d.ts +60 -0
  132. package/lib/typescript/commonjs/src/services/DeviceRegistrationService.d.ts.map +1 -0
  133. package/lib/typescript/commonjs/src/services/PushTokenService.d.ts +82 -0
  134. package/lib/typescript/commonjs/src/services/PushTokenService.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/src/state/AuthStateMachine.d.ts +61 -0
  136. package/lib/typescript/commonjs/src/state/AuthStateMachine.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/src/state/DeviceStateMachine.d.ts +51 -0
  138. package/lib/typescript/commonjs/src/state/DeviceStateMachine.d.ts.map +1 -0
  139. package/lib/typescript/commonjs/src/state/PushStateMachine.d.ts +61 -0
  140. package/lib/typescript/commonjs/src/state/PushStateMachine.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/src/types/EventQueue.d.ts +85 -0
  142. package/lib/typescript/commonjs/src/types/EventQueue.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/src/types/SDK.d.ts +54 -0
  144. package/lib/typescript/commonjs/src/types/SDK.d.ts.map +1 -0
  145. package/lib/typescript/commonjs/src/utils/FirebaseNotificationManager.d.ts +169 -0
  146. package/lib/typescript/commonjs/src/utils/FirebaseNotificationManager.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/src/utils/Logger.d.ts +32 -0
  148. package/lib/typescript/commonjs/src/utils/Logger.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/src/utils/SharedCredentialsManager.d.ts +54 -0
  150. package/lib/typescript/commonjs/src/utils/SharedCredentialsManager.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/src/version.d.ts +2 -0
  152. package/lib/typescript/commonjs/src/version.d.ts.map +1 -0
  153. package/lib/typescript/module/package.json +1 -0
  154. package/lib/typescript/module/src/components/FooterView.d.ts +3 -0
  155. package/lib/typescript/module/src/components/FooterView.d.ts.map +1 -0
  156. package/lib/typescript/module/src/components/FullScreenView.d.ts +3 -0
  157. package/lib/typescript/module/src/components/FullScreenView.d.ts.map +1 -0
  158. package/lib/typescript/module/src/components/HeaderView.d.ts +3 -0
  159. package/lib/typescript/module/src/components/HeaderView.d.ts.map +1 -0
  160. package/lib/typescript/module/src/components/PopUpView.d.ts +3 -0
  161. package/lib/typescript/module/src/components/PopUpView.d.ts.map +1 -0
  162. package/lib/typescript/module/src/config/BatchConfig.d.ts +7 -0
  163. package/lib/typescript/module/src/config/BatchConfig.d.ts.map +1 -0
  164. package/lib/typescript/module/src/constants/ApiUrls.d.ts +56 -0
  165. package/lib/typescript/module/src/constants/ApiUrls.d.ts.map +1 -0
  166. package/lib/typescript/module/src/core/EventQueueManager.d.ts +63 -0
  167. package/lib/typescript/module/src/core/EventQueueManager.d.ts.map +1 -0
  168. package/lib/typescript/module/src/core/FlushManager.d.ts +63 -0
  169. package/lib/typescript/module/src/core/FlushManager.d.ts.map +1 -0
  170. package/lib/typescript/module/src/core/NetworkMonitor.d.ts +38 -0
  171. package/lib/typescript/module/src/core/NetworkMonitor.d.ts.map +1 -0
  172. package/lib/typescript/module/src/index.d.ts +663 -0
  173. package/lib/typescript/module/src/index.d.ts.map +1 -0
  174. package/lib/typescript/module/src/providers/FirebasePushProvider.d.ts +28 -0
  175. package/lib/typescript/module/src/providers/FirebasePushProvider.d.ts.map +1 -0
  176. package/lib/typescript/module/src/providers/NullPushProvider.d.ts +25 -0
  177. package/lib/typescript/module/src/providers/NullPushProvider.d.ts.map +1 -0
  178. package/lib/typescript/module/src/providers/PushNotificationProvider.d.ts +105 -0
  179. package/lib/typescript/module/src/providers/PushNotificationProvider.d.ts.map +1 -0
  180. package/lib/typescript/module/src/services/DeviceRegistrationService.d.ts +60 -0
  181. package/lib/typescript/module/src/services/DeviceRegistrationService.d.ts.map +1 -0
  182. package/lib/typescript/module/src/services/PushTokenService.d.ts +82 -0
  183. package/lib/typescript/module/src/services/PushTokenService.d.ts.map +1 -0
  184. package/lib/typescript/module/src/state/AuthStateMachine.d.ts +61 -0
  185. package/lib/typescript/module/src/state/AuthStateMachine.d.ts.map +1 -0
  186. package/lib/typescript/module/src/state/DeviceStateMachine.d.ts +51 -0
  187. package/lib/typescript/module/src/state/DeviceStateMachine.d.ts.map +1 -0
  188. package/lib/typescript/module/src/state/PushStateMachine.d.ts +61 -0
  189. package/lib/typescript/module/src/state/PushStateMachine.d.ts.map +1 -0
  190. package/lib/typescript/module/src/types/EventQueue.d.ts +85 -0
  191. package/lib/typescript/module/src/types/EventQueue.d.ts.map +1 -0
  192. package/lib/typescript/module/src/types/SDK.d.ts +54 -0
  193. package/lib/typescript/module/src/types/SDK.d.ts.map +1 -0
  194. package/lib/typescript/module/src/utils/FirebaseNotificationManager.d.ts +169 -0
  195. package/lib/typescript/module/src/utils/FirebaseNotificationManager.d.ts.map +1 -0
  196. package/lib/typescript/module/src/utils/Logger.d.ts +32 -0
  197. package/lib/typescript/module/src/utils/Logger.d.ts.map +1 -0
  198. package/lib/typescript/module/src/utils/SharedCredentialsManager.d.ts +54 -0
  199. package/lib/typescript/module/src/utils/SharedCredentialsManager.d.ts.map +1 -0
  200. package/lib/typescript/module/src/version.d.ts +2 -0
  201. package/lib/typescript/module/src/version.d.ts.map +1 -0
  202. package/package.json +230 -0
  203. package/scripts/generate-version.js +25 -0
  204. package/scripts/setup-ios-extension.js +275 -0
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * SharedCredentialsManager
5
+ *
6
+ * Manages credentials storage in iOS App Groups for sharing between
7
+ * the main app and Notification Service Extension.
8
+ *
9
+ * This allows the extension to send delivery ACKs even when the app is killed.
10
+ */
11
+
12
+ import { Platform } from 'react-native';
13
+ import SharedGroupPreferences from 'react-native-shared-group-preferences';
14
+ import Base64 from 'react-native-base64';
15
+ import Logger from "./Logger.js";
16
+ export class SharedCredentialsManager {
17
+ static APP_GROUP_ID = 'group.swan.sdk.notifications';
18
+ static CREDENTIALS_KEY = 'swanCredentials';
19
+
20
+ /**
21
+ * Save credentials to iOS App Group (for Notification Service Extension)
22
+ * On Android, this is a no-op as extensions don't exist.
23
+ */
24
+ static async saveToAppGroup(credentials) {
25
+ if (Platform.OS !== 'ios') {
26
+ // Android doesn't need shared App Group
27
+ Logger.log('[SharedCredentials] Skipping App Group save on Android');
28
+ return;
29
+ }
30
+ try {
31
+ // Encode credentials as base64 JSON
32
+ const credentialsJson = JSON.stringify(credentials);
33
+ const credentialsBase64 = Base64.encode(credentialsJson);
34
+
35
+ // Save to App Group
36
+ await SharedGroupPreferences.setItem(this.CREDENTIALS_KEY, credentialsBase64, this.APP_GROUP_ID);
37
+ Logger.log('[SharedCredentials] ✅ Credentials saved to iOS App Group');
38
+ Logger.log('[SharedCredentials] App Group ID:', this.APP_GROUP_ID);
39
+ Logger.log('[SharedCredentials] Saved credentials:', {
40
+ appId: credentials.appId,
41
+ deviceId: credentials.deviceId,
42
+ hasCDID: !!credentials.cdid,
43
+ isProduction: credentials.isProduction
44
+ });
45
+ } catch (error) {
46
+ Logger.error('[SharedCredentials] ❌ Failed to save to App Group:', error);
47
+ Logger.error('[SharedCredentials] Make sure react-native-shared-group-preferences is installed');
48
+ Logger.error('[SharedCredentials] Make sure App Group is configured in Xcode');
49
+ // Don't throw - this is not critical for main app functionality
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Read credentials from iOS App Group
55
+ * Useful for debugging or fallback scenarios.
56
+ */
57
+ static async readFromAppGroup() {
58
+ if (Platform.OS !== 'ios') {
59
+ return null;
60
+ }
61
+ try {
62
+ const credentialsBase64 = await SharedGroupPreferences.getItem(this.CREDENTIALS_KEY, this.APP_GROUP_ID);
63
+ if (!credentialsBase64) {
64
+ Logger.log('[SharedCredentials] No credentials found in App Group');
65
+ return null;
66
+ }
67
+ const credentialsJson = Base64.decode(credentialsBase64);
68
+ const credentials = JSON.parse(credentialsJson);
69
+ Logger.log('[SharedCredentials] ✅ Credentials read from App Group');
70
+ return credentials;
71
+ } catch (error) {
72
+ Logger.error('[SharedCredentials] ❌ Failed to read from App Group:', error);
73
+ return null;
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Clear credentials from iOS App Group
79
+ * Useful during logout or SDK reset.
80
+ */
81
+ static async clearFromAppGroup() {
82
+ if (Platform.OS !== 'ios') {
83
+ return;
84
+ }
85
+ try {
86
+ await SharedGroupPreferences.setItem(this.CREDENTIALS_KEY, '', this.APP_GROUP_ID);
87
+ Logger.log('[SharedCredentials] ✅ Credentials cleared from App Group');
88
+ } catch (error) {
89
+ Logger.error('[SharedCredentials] ❌ Failed to clear from App Group:', error);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Configure custom App Group ID
95
+ * Call this before SDK init if you want to use a different App Group ID.
96
+ *
97
+ * @param appGroupId - Custom App Group ID (e.g., "group.com.yourcompany.app")
98
+ */
99
+ static setAppGroupId(appGroupId) {
100
+ this.APP_GROUP_ID = appGroupId;
101
+ Logger.log('[SharedCredentials] App Group ID configured:', appGroupId);
102
+ }
103
+
104
+ /**
105
+ * Get current App Group ID
106
+ */
107
+ static getAppGroupId() {
108
+ return this.APP_GROUP_ID;
109
+ }
110
+
111
+ /**
112
+ * Check if iOS Notification Service Extension is active/configured
113
+ * Returns true if App Group is accessible (meaning NES is configured)
114
+ *
115
+ * This is used to determine if delivery ACKs should be skipped in the
116
+ * React Native background handler (since NES handles them)
117
+ */
118
+ static async isNotificationServiceExtensionActive() {
119
+ if (Platform.OS !== 'ios') {
120
+ return false; // Android doesn't have extension
121
+ }
122
+ try {
123
+ // Try to access App Group - if successful, NES is configured
124
+ const isNesActive = await SharedGroupPreferences.getItem('swanNESActive', this.APP_GROUP_ID);
125
+ if (!isNesActive) {
126
+ Logger.log('[SharedCredentials] Notification Service Extension is not configured');
127
+ return false;
128
+ }
129
+
130
+ // If we can access App Group, NES is configured
131
+ Logger.log('[SharedCredentials] ✅ Notification Service Extension is active');
132
+ return true;
133
+ } catch (error) {
134
+ // If App Group is not accessible, NES is not configured
135
+ Logger.log('[SharedCredentials] Notification Service Extension is not configured');
136
+ return false;
137
+ }
138
+ }
139
+ }
140
+ //# sourceMappingURL=SharedCredentialsManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","SharedGroupPreferences","Base64","Logger","SharedCredentialsManager","APP_GROUP_ID","CREDENTIALS_KEY","saveToAppGroup","credentials","OS","log","credentialsJson","JSON","stringify","credentialsBase64","encode","setItem","appId","deviceId","hasCDID","cdid","isProduction","error","readFromAppGroup","getItem","decode","parse","clearFromAppGroup","setAppGroupId","appGroupId","getAppGroupId","isNotificationServiceExtensionActive","isNesActive"],"sourceRoot":"../../../src","sources":["utils/SharedCredentialsManager.ts"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ // Auto-generated file. Do not edit manually.
4
+ // This file is generated from package.json version during build.
5
+ // See scripts/generate-version.js
6
+
7
+ export const SDK_VERSION = '2.0.1';
8
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SDK_VERSION"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,OAAO,MAAMA,WAAW,GAAG,OAAO","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,3 @@
1
+ declare const FooterNotification: ({ designConfig, onClose, onButtonClick }: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default FooterNotification;
3
+ //# sourceMappingURL=FooterView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FooterView.d.ts","sourceRoot":"","sources":["../../../../../src/components/FooterView.tsx"],"names":[],"mappings":"AAWA,QAAA,MAAM,kBAAkB,GAAI,0CAA0C,GAAG,4CA+DxE,CAAC;AAiDF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const FullScreenView: ({ designConfig, onClose, onButtonClick }: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default FullScreenView;
3
+ //# sourceMappingURL=FullScreenView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FullScreenView.d.ts","sourceRoot":"","sources":["../../../../../src/components/FullScreenView.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,cAAc,GAAI,0CAA0C,GAAG,4CAsGpE,CAAC;AA+DF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const HeaderView: ({ designConfig, onClose, onButtonClick }: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default HeaderView;
3
+ //# sourceMappingURL=HeaderView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderView.d.ts","sourceRoot":"","sources":["../../../../../src/components/HeaderView.tsx"],"names":[],"mappings":"AAYA,QAAA,MAAM,UAAU,GAAI,0CAA+C,GAAG,4CAoIrE,CAAC;AA+EF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const PopUpView: ({ designConfig, onClose, onButtonClick }: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default PopUpView;
3
+ //# sourceMappingURL=PopUpView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PopUpView.d.ts","sourceRoot":"","sources":["../../../../../src/components/PopUpView.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS,GAAI,0CAA0C,GAAG,4CAoH/D,CAAC;AAuEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type BatchConfiguration } from '../types/EventQueue';
2
+ /**
3
+ * Default configuration for event batching
4
+ * Based on industry standards (CleverTap, Segment, Mixpanel)
5
+ */
6
+ export declare const DEFAULT_BATCH_CONFIG: BatchConfiguration;
7
+ //# sourceMappingURL=BatchConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BatchConfig.d.ts","sourceRoot":"","sources":["../../../../../src/config/BatchConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBA+ClC,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * API URLs used across the SDK
3
+ * Centralized to avoid circular dependencies
4
+ */
5
+ export declare const ECOM_ENRICH_PROFILE_URL: {
6
+ STAGE: string;
7
+ PROD: string;
8
+ };
9
+ export declare const ECOM_TRACK_EVENT_URL: {
10
+ STAGE: string;
11
+ PROD: string;
12
+ };
13
+ export declare const ECOM_DEVICE_REGISTER_URL: {
14
+ STAGE: string;
15
+ PROD: string;
16
+ };
17
+ export declare const ECOM_PUSH_SUBSCRIPTION_URL: {
18
+ STAGE: string;
19
+ PROD: string;
20
+ };
21
+ export declare const WEBHOOK_MOBILE_PUSH_URL: {
22
+ STAGE: string;
23
+ PROD: string;
24
+ };
25
+ export declare const NOTIFICATION_GET_URL: {
26
+ STAGE: string;
27
+ PROD: string;
28
+ };
29
+ declare const _default: {
30
+ ECOM_ENRICH_PROFILE_URL: {
31
+ STAGE: string;
32
+ PROD: string;
33
+ };
34
+ ECOM_TRACK_EVENT_URL: {
35
+ STAGE: string;
36
+ PROD: string;
37
+ };
38
+ ECOM_DEVICE_REGISTER_URL: {
39
+ STAGE: string;
40
+ PROD: string;
41
+ };
42
+ ECOM_PUSH_SUBSCRIPTION_URL: {
43
+ STAGE: string;
44
+ PROD: string;
45
+ };
46
+ WEBHOOK_MOBILE_PUSH_URL: {
47
+ STAGE: string;
48
+ PROD: string;
49
+ };
50
+ NOTIFICATION_GET_URL: {
51
+ STAGE: string;
52
+ PROD: string;
53
+ };
54
+ };
55
+ export default _default;
56
+ //# sourceMappingURL=ApiUrls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiUrls.d.ts","sourceRoot":"","sources":["../../../../../src/constants/ApiUrls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,eAAO,MAAM,uBAAuB;;;CAGnC,CAAA;AAED,eAAO,MAAM,oBAAoB;;;CAGhC,CAAA;AAED,eAAO,MAAM,wBAAwB;;;CAGpC,CAAA;AAED,eAAO,MAAM,0BAA0B;;;CAGtC,CAAA;AAED,eAAO,MAAM,uBAAuB;;;CAGnC,CAAA;AAED,eAAO,MAAM,oBAAoB;;;CAGhC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,wBAOC"}
@@ -0,0 +1,63 @@
1
+ import { type QueuedEvent } from '../types/EventQueue';
2
+ /**
3
+ * EventQueueManager
4
+ * Manages persistent event queue using SQLite
5
+ * Handles enqueue, dequeue, status updates, and cleanup operations
6
+ */
7
+ export declare class EventQueueManager {
8
+ private db;
9
+ private maxRetries;
10
+ constructor(db: any, maxRetries?: number);
11
+ /**
12
+ * Create EventQueue table with indexes
13
+ * Called during SDK initialization
14
+ */
15
+ createTable(): Promise<void>;
16
+ /**
17
+ * Add event to queue
18
+ * @param event Event to enqueue
19
+ */
20
+ enqueue(event: QueuedEvent): Promise<void>;
21
+ /**
22
+ * Retrieve events from queue for batch sending
23
+ * Priority events first, then FIFO
24
+ * @param batchSize Maximum number of events to retrieve
25
+ * @returns Array of queued events
26
+ */
27
+ dequeue(batchSize: number): Promise<QueuedEvent[]>;
28
+ /**
29
+ * Mark events as successfully sent and remove from queue
30
+ * @param eventIds Array of event IDs to mark as sent
31
+ */
32
+ markAsSent(eventIds: string[]): Promise<void>;
33
+ /**
34
+ * Mark events as failed and update retry count
35
+ * @param eventIds Array of event IDs that failed
36
+ * @param retryCount New retry count
37
+ */
38
+ markAsFailed(eventIds: string[], retryCount: number): Promise<void>;
39
+ /**
40
+ * Get current queue size (pending events only)
41
+ * @returns Number of pending events in queue
42
+ */
43
+ getQueueSize(): Promise<number>;
44
+ /**
45
+ * Clean up old failed events
46
+ * Deletes events older than specified days with status 'failed'
47
+ * @param daysOld Number of days old to consider for deletion
48
+ */
49
+ clearOldEvents(daysOld: number): Promise<void>;
50
+ /**
51
+ * Drop oldest events when queue is full
52
+ * Keeps queue size within limits by removing oldest pending events
53
+ * @param maxSize Maximum queue size to maintain
54
+ */
55
+ enforceQueueLimit(maxSize: number): Promise<void>;
56
+ /**
57
+ * Recover stale 'sending' events back to 'pending'
58
+ * Called on SDK initialization to handle app crashes during flush
59
+ * Resets events stuck in 'sending' status for more than 5 minutes
60
+ */
61
+ recoverStaleEvents(): Promise<void>;
62
+ }
63
+ //# sourceMappingURL=EventQueueManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventQueueManager.d.ts","sourceRoot":"","sources":["../../../../../src/core/EventQueueManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,EAAE,CAAM;IAChB,OAAO,CAAC,UAAU,CAAS;gBAEf,EAAE,EAAE,GAAG,EAAE,UAAU,GAAE,MAAU;IAK3C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAkElC;;;OAGG;IACG,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAuChD;;;;;OAKG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IA2ExD;;;OAGG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCnD;;;;OAIG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CzE;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IA4BrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BpD;;;;OAIG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCvD;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAoC1C"}
@@ -0,0 +1,63 @@
1
+ import { EventQueueManager } from './EventQueueManager';
2
+ import { NetworkMonitor } from './NetworkMonitor';
3
+ import { type BatchConfiguration, type QueuedEvent } from '../types/EventQueue';
4
+ /**
5
+ * FlushManager
6
+ * Orchestrates batch sending with multiple flush triggers:
7
+ * - Time interval (every 30s)
8
+ * - Queue size (when batchSize reached)
9
+ * - App lifecycle (on background)
10
+ * - Network restoration (when back online)
11
+ */
12
+ export declare class FlushManager {
13
+ private queueManager;
14
+ private networkMonitor;
15
+ private config;
16
+ private sendBatchCallback;
17
+ private flushTimer;
18
+ private isFlushing;
19
+ private appStateSubscription;
20
+ private retryTimeouts;
21
+ constructor(queueManager: EventQueueManager, networkMonitor: NetworkMonitor, config: BatchConfiguration, sendBatchCallback: (events: QueuedEvent[]) => Promise<any>);
22
+ /**
23
+ * Start flush manager
24
+ * - Initializes timer-based flushing
25
+ * - Sets up AppState listener
26
+ * - Sets up network state listener
27
+ */
28
+ start(): void;
29
+ /**
30
+ * Stop flush manager
31
+ * - Clears timer
32
+ * - Removes listeners
33
+ * - Cancels pending retries
34
+ */
35
+ stop(): void;
36
+ /**
37
+ * Trigger batch flush
38
+ * Prevents concurrent flushes using promise-based lock
39
+ * @param force If true, bypasses online check
40
+ * @returns Batch response from server
41
+ */
42
+ flush(force?: boolean): Promise<any>;
43
+ /**
44
+ * Handle batch response with granular event-level success/failure
45
+ * Parses individual event results and handles each one appropriately
46
+ * @param events Events that were sent in the batch
47
+ * @param batchResponse Response from server with individual event results
48
+ */
49
+ private handleBatchResponse;
50
+ /**
51
+ * Handle failed batch with retry logic (entire batch failed due to network/server error)
52
+ * Implements exponential backoff: 2s, 4s, 8s, 16s, 32s
53
+ * @param events Events that failed to send
54
+ * @param error Error that occurred
55
+ */
56
+ private handleFailedBatch;
57
+ /**
58
+ * Check if flush is needed based on queue size
59
+ * Called after each event is enqueued
60
+ */
61
+ checkFlushNeeded(): Promise<void>;
62
+ }
63
+ //# sourceMappingURL=FlushManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlushManager.d.ts","sourceRoot":"","sources":["../../../../../src/core/FlushManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGhF;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,iBAAiB,CAA0C;IAEnE,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,oBAAoB,CAAa;IACzC,OAAO,CAAC,aAAa,CAA0C;gBAG7D,YAAY,EAAE,iBAAiB,EAC/B,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,kBAAkB,EAC1B,iBAAiB,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC;IAQ5D;;;;;OAKG;IACH,KAAK,IAAI,IAAI;IA8Bb;;;;;OAKG;IACH,IAAI,IAAI,IAAI;IAoBZ;;;;;OAKG;IACG,KAAK,CAAC,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAoDjD;;;;;OAKG;YACW,mBAAmB;IAgFjC;;;;;OAKG;YACW,iBAAiB;IAmC/B;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAcxC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * NetworkMonitor
3
+ * Monitors network connectivity status
4
+ * Notifies when connection status changes
5
+ */
6
+ export declare class NetworkMonitor {
7
+ private isOnline;
8
+ private unsubscribe;
9
+ private listeners;
10
+ /**
11
+ * Start monitoring network state
12
+ */
13
+ start(): void;
14
+ /**
15
+ * Stop monitoring network state
16
+ */
17
+ stop(): void;
18
+ /**
19
+ * Check if currently connected to network
20
+ * @returns true if connected, false otherwise
21
+ */
22
+ isConnected(): boolean;
23
+ /**
24
+ * Add listener for connection state changes
25
+ * @param callback Function called when connection state changes
26
+ */
27
+ addListener(callback: (isOnline: boolean) => void): void;
28
+ /**
29
+ * Remove listener
30
+ * @param callback Listener to remove
31
+ */
32
+ removeListener(callback: (isOnline: boolean) => void): void;
33
+ /**
34
+ * Notify all listeners of connection state change
35
+ */
36
+ private notifyListeners;
37
+ }
38
+ //# sourceMappingURL=NetworkMonitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkMonitor.d.ts","sourceRoot":"","sources":["../../../../../src/core/NetworkMonitor.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,SAAS,CAA+C;IAEhE;;OAEG;IACH,KAAK,IAAI,IAAI;IA8Bb;;OAEG;IACH,IAAI,IAAI,IAAI;IAQZ;;;OAGG;IACH,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAIxD;;;OAGG;IACH,cAAc,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAI3D;;OAEG;IACH,OAAO,CAAC,eAAe;CASxB"}