react-native-acoustic-connect-beta 18.0.14 → 18.0.15

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 (97) hide show
  1. package/Examples/SampleUI/.detoxrc.js +83 -0
  2. package/Examples/SampleUI/ConnectConfig.json +2 -2
  3. package/Examples/SampleUI/android/app/build.gradle +3 -0
  4. package/Examples/SampleUI/android/app/src/main/java/com/sampleui/MainActivity.kt +0 -35
  5. package/Examples/SampleUI/android/settings.gradle +1 -1
  6. package/Examples/SampleUI/package.json +8 -6
  7. package/Examples/SampleUI/scripts/integration-test-android.sh +292 -0
  8. package/Examples/SampleUI/src/Examples/DialogExample.tsx +88 -2
  9. package/Examples/SampleUI/src/Examples/Dialogs/DialogTrackingTest.tsx +307 -0
  10. package/Examples/SampleUI/src/Examples/Dialogs/index.tsx +37 -0
  11. package/Examples/SampleUI/src/index.native.tsx +4 -5
  12. package/android/build.gradle +2 -2
  13. package/android/src/main/assets/ConnectAdvancedConfig.json +1 -1
  14. package/android/src/main/java/com/acousticconnectrn/HybridAcousticConnectRN.kt +787 -490
  15. package/ios/HybridAcousticConnectRN.swift +75 -0
  16. package/lib/commonjs/TLTRN.js +69 -0
  17. package/lib/commonjs/TLTRN.js.map +1 -1
  18. package/lib/commonjs/components/Connect.js +5 -1
  19. package/lib/commonjs/components/Connect.js.map +1 -1
  20. package/lib/commonjs/docs/DialogTracking.md +252 -0
  21. package/lib/commonjs/docs/NativeImplementation.md +176 -0
  22. package/lib/commonjs/examples/DialogTrackingExample.js +175 -0
  23. package/lib/commonjs/examples/DialogTrackingExample.js.map +1 -0
  24. package/lib/commonjs/examples/HOCDialogExample.js +296 -0
  25. package/lib/commonjs/examples/HOCDialogExample.js.map +1 -0
  26. package/lib/commonjs/index.js +28 -0
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/commonjs/utils/DialogDebugger.js +216 -0
  29. package/lib/commonjs/utils/DialogDebugger.js.map +1 -0
  30. package/lib/commonjs/utils/DialogListener.js +203 -0
  31. package/lib/commonjs/utils/DialogListener.js.map +1 -0
  32. package/lib/commonjs/utils/useDialogTracking.js +107 -0
  33. package/lib/commonjs/utils/useDialogTracking.js.map +1 -0
  34. package/lib/commonjs/utils/withAcousticAutoDialog.js +282 -0
  35. package/lib/commonjs/utils/withAcousticAutoDialog.js.map +1 -0
  36. package/lib/module/TLTRN.js +69 -0
  37. package/lib/module/TLTRN.js.map +1 -1
  38. package/lib/module/components/Connect.js +5 -1
  39. package/lib/module/components/Connect.js.map +1 -1
  40. package/lib/module/docs/DialogTracking.md +252 -0
  41. package/lib/module/docs/NativeImplementation.md +176 -0
  42. package/lib/module/examples/DialogTrackingExample.js +172 -0
  43. package/lib/module/examples/DialogTrackingExample.js.map +1 -0
  44. package/lib/module/examples/HOCDialogExample.js +292 -0
  45. package/lib/module/examples/HOCDialogExample.js.map +1 -0
  46. package/lib/module/index.js +5 -1
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/utils/DialogDebugger.js +211 -0
  49. package/lib/module/utils/DialogDebugger.js.map +1 -0
  50. package/lib/module/utils/DialogListener.js +199 -0
  51. package/lib/module/utils/DialogListener.js.map +1 -0
  52. package/lib/module/utils/useDialogTracking.js +102 -0
  53. package/lib/module/utils/useDialogTracking.js.map +1 -0
  54. package/lib/module/utils/withAcousticAutoDialog.js +275 -0
  55. package/lib/module/utils/withAcousticAutoDialog.js.map +1 -0
  56. package/lib/typescript/src/TLTRN.d.ts +7 -0
  57. package/lib/typescript/src/TLTRN.d.ts.map +1 -1
  58. package/lib/typescript/src/components/Connect.d.ts +1 -0
  59. package/lib/typescript/src/components/Connect.d.ts.map +1 -1
  60. package/lib/typescript/src/examples/DialogTrackingExample.d.ts +17 -0
  61. package/lib/typescript/src/examples/DialogTrackingExample.d.ts.map +1 -0
  62. package/lib/typescript/src/examples/HOCDialogExample.d.ts +21 -0
  63. package/lib/typescript/src/examples/HOCDialogExample.d.ts.map +1 -0
  64. package/lib/typescript/src/index.d.ts +5 -1
  65. package/lib/typescript/src/index.d.ts.map +1 -1
  66. package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts +4 -0
  67. package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts.map +1 -1
  68. package/lib/typescript/src/utils/DialogDebugger.d.ts +58 -0
  69. package/lib/typescript/src/utils/DialogDebugger.d.ts.map +1 -0
  70. package/lib/typescript/src/utils/DialogListener.d.ts +85 -0
  71. package/lib/typescript/src/utils/DialogListener.d.ts.map +1 -0
  72. package/lib/typescript/src/utils/useDialogTracking.d.ts +25 -0
  73. package/lib/typescript/src/utils/useDialogTracking.d.ts.map +1 -0
  74. package/lib/typescript/src/utils/withAcousticAutoDialog.d.ts +37 -0
  75. package/lib/typescript/src/utils/withAcousticAutoDialog.d.ts.map +1 -0
  76. package/nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.cpp +26 -0
  77. package/nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.hpp +4 -0
  78. package/nitrogen/generated/android/kotlin/com/margelo/nitro/acousticconnectrn/HybridAcousticConnectRNSpec.kt +16 -0
  79. package/nitrogen/generated/ios/c++/HybridAcousticConnectRNSpecSwift.hpp +32 -0
  80. package/nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec.swift +4 -0
  81. package/nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec_cxx.swift +71 -0
  82. package/nitrogen/generated/shared/c++/HybridAcousticConnectRNSpec.cpp +4 -0
  83. package/nitrogen/generated/shared/c++/HybridAcousticConnectRNSpec.hpp +4 -0
  84. package/package.json +1 -1
  85. package/scripts/ConnectConfig.json +1 -1
  86. package/src/TLTRN.ts +75 -0
  87. package/src/components/Connect.tsx +6 -1
  88. package/src/docs/DialogTracking.md +252 -0
  89. package/src/docs/NativeImplementation.md +176 -0
  90. package/src/examples/DialogTrackingExample.tsx +163 -0
  91. package/src/examples/HOCDialogExample.tsx +253 -0
  92. package/src/index.ts +5 -1
  93. package/src/specs/react-native-acoustic-connect.nitro.ts +5 -0
  94. package/src/utils/DialogDebugger.ts +224 -0
  95. package/src/utils/DialogListener.ts +238 -0
  96. package/src/utils/useDialogTracking.ts +102 -0
  97. package/src/utils/withAcousticAutoDialog.tsx +312 -0
@@ -0,0 +1,252 @@
1
+ # Dialog Event Tracking
2
+
3
+ This document describes the dialog event tracking functionality added to the Acoustic Connect React Native SDK.
4
+
5
+ ## Overview
6
+
7
+ The dialog tracking system provides automatic and manual tracking of dialog popup events and user interactions. It supports:
8
+
9
+ - **Automatic tracking** of React Native's `Alert.alert()` calls
10
+ - **Manual tracking** of custom dialog components
11
+ - **Button click tracking** for both automatic and custom dialogs
12
+ - **Event logging** to the Acoustic Connect backend
13
+
14
+ ## Features
15
+
16
+ ### 1. Automatic Alert.alert Interception
17
+
18
+ The system automatically intercepts and tracks all `Alert.alert()` calls without requiring any code changes:
19
+
20
+ ```typescript
21
+ // This will be automatically tracked
22
+ Alert.alert(
23
+ 'Confirmation',
24
+ 'Are you sure?',
25
+ [
26
+ { text: 'Cancel', style: 'cancel' },
27
+ { text: 'OK', onPress: () => console.log('OK pressed') }
28
+ ]
29
+ );
30
+ ```
31
+
32
+ ### 2. Manual Custom Dialog Tracking
33
+
34
+ For custom dialog components, you can manually track events:
35
+
36
+ ```typescript
37
+ import { useDialogTracking } from 'react-native-acoustic-connect-beta';
38
+
39
+ const MyComponent = () => {
40
+ const { generateDialogId, trackDialogShow, trackDialogDismiss } = useDialogTracking();
41
+
42
+ const showDialog = () => {
43
+ const dialogId = generateDialogId();
44
+ trackDialogShow(dialogId, 'My Custom Dialog', [
45
+ { text: 'Cancel', style: 'cancel' },
46
+ { text: 'OK' }
47
+ ]);
48
+ // Show your custom dialog
49
+ };
50
+
51
+ const hideDialog = () => {
52
+ const dialogId = generateDialogId(); // Store this in your component state
53
+ trackDialogDismiss(dialogId, 'user_dismiss');
54
+ // Hide your custom dialog
55
+ };
56
+ };
57
+ ```
58
+
59
+ ### 3. Button Click Tracking
60
+
61
+ Track button clicks in custom dialogs:
62
+
63
+ ```typescript
64
+ const { createTrackedButton } = useDialogTracking();
65
+
66
+ const showDialogWithTrackedButtons = () => {
67
+ const dialogId = generateDialogId();
68
+ const originalButtons = [
69
+ { text: 'No', style: 'cancel' },
70
+ { text: 'Yes', onPress: () => console.log('Yes pressed') }
71
+ ];
72
+
73
+ // Create tracked buttons
74
+ const trackedButtons = originalButtons.map((button, index) =>
75
+ createTrackedButton(dialogId, button, index)
76
+ );
77
+
78
+ trackDialogShow(dialogId, 'Confirmation', trackedButtons);
79
+ };
80
+ ```
81
+
82
+ ### 4. HOC-Based Automatic Tracking
83
+
84
+ For the easiest integration, use the HOC (Higher-Order Component) approach:
85
+
86
+ ```typescript
87
+ import { withAcousticAutoDialog } from 'react-native-acoustic-connect-beta';
88
+ import { Dialog } from 'react-native-paper';
89
+
90
+ // Create tracked version of your dialog component
91
+ const TrackedDialog = withAcousticAutoDialog(Dialog);
92
+
93
+ // Use normally - all events automatically tracked!
94
+ <TrackedDialog
95
+ visible={dialogVisible}
96
+ onDismiss={hideDialog}
97
+ title="My Dialog"
98
+ >
99
+ <Dialog.Content>
100
+ <Text>Dialog content</Text>
101
+ </Dialog.Content>
102
+ <Dialog.Actions>
103
+ <Button onPress={hideDialog}>Cancel</Button>
104
+ <Button onPress={confirmAction}>Confirm</Button>
105
+ </Dialog.Actions>
106
+ </TrackedDialog>
107
+ ```
108
+
109
+ The HOC automatically tracks:
110
+ - Dialog show events
111
+ - Dialog dismiss events
112
+ - Button click events within the dialog
113
+ - Recursively scans dialog children for buttons
114
+
115
+ ## Setup
116
+
117
+ ### 1. Enable Dialog Tracking in Connect Component
118
+
119
+ ```typescript
120
+ import { Connect } from 'react-native-acoustic-connect-beta';
121
+
122
+ <Connect
123
+ captureKeyboardEvents={true}
124
+ captureDialogEvents={true} // Enable dialog tracking
125
+ >
126
+ <NavigationContainer ref={navigationRef}>
127
+ {/* Your app content */}
128
+ </NavigationContainer>
129
+ </Connect>
130
+ ```
131
+
132
+ ### 2. Use the useDialogTracking Hook
133
+
134
+ ```typescript
135
+ import { useDialogTracking } from 'react-native-acoustic-connect-beta';
136
+
137
+ const MyComponent = () => {
138
+ const dialogTracking = useDialogTracking();
139
+
140
+ // Use dialogTracking methods...
141
+ };
142
+ ```
143
+
144
+ ## API Reference
145
+
146
+ ### Connect Component Props
147
+
148
+ | Prop | Type | Default | Description |
149
+ |------|------|---------|-------------|
150
+ | `captureDialogEvents` | `boolean` | `false` | Enable automatic dialog event tracking |
151
+
152
+ ### useDialogTracking Hook
153
+
154
+ Returns an object with the following methods:
155
+
156
+ #### `generateDialogId(): string`
157
+ Generates a unique dialog identifier.
158
+
159
+ #### `trackDialogShow(dialogId: string, title: string, buttons?: AlertButton[]): void`
160
+ Tracks a dialog show event.
161
+
162
+ #### `trackDialogDismiss(dialogId: string, reason: string): void`
163
+ Tracks a dialog dismiss event.
164
+
165
+ #### `trackDialogButtonClick(dialogId: string, buttonText: string, buttonIndex: number): void`
166
+ Tracks a dialog button click event.
167
+
168
+ #### `trackDialogCustomEvent(dialogId: string, eventName: string, values: Record<string, string \| number \| boolean>): void`
169
+ Tracks a custom dialog event.
170
+
171
+ #### `createTrackedButton(dialogId: string, button: AlertButton, buttonIndex: number): AlertButton`
172
+ Creates a button with automatic click tracking.
173
+
174
+ #### `cleanup(): void`
175
+ Cleans up dialog tracking state.
176
+
177
+ ### DialogListener Class
178
+
179
+ For advanced usage, you can directly use the DialogListener class:
180
+
181
+ ```typescript
182
+ import { DialogListener } from 'react-native-acoustic-connect-beta';
183
+
184
+ const dialogListener = DialogListener.getInstance();
185
+ dialogListener.startIntercepting();
186
+ dialogListener.addEventListener((event) => {
187
+ console.log('Dialog event:', event);
188
+ });
189
+ ```
190
+
191
+ ## Event Types
192
+
193
+ ### DialogEvent
194
+ ```typescript
195
+ interface DialogEvent {
196
+ dialogId: string;
197
+ dialogTitle: string;
198
+ dialogType: 'alert' | 'custom' | 'modal';
199
+ timestamp: number;
200
+ buttons?: AlertButton[];
201
+ }
202
+ ```
203
+
204
+ ### DialogButtonClickEvent
205
+ ```typescript
206
+ interface DialogButtonClickEvent {
207
+ dialogId: string;
208
+ buttonText: string;
209
+ buttonIndex: number;
210
+ timestamp: number;
211
+ }
212
+ ```
213
+
214
+ ## Native Interface Methods
215
+
216
+ The following methods are added to the AcousticConnectRN interface:
217
+
218
+ - `logDialogShowEvent(dialogId: string, dialogTitle: string, dialogType: string): boolean`
219
+ - `logDialogDismissEvent(dialogId: string, dismissReason: string): boolean`
220
+ - `logDialogButtonClickEvent(dialogId: string, buttonText: string, buttonIndex: number): boolean`
221
+ - `logDialogCustomEvent(dialogId: string, eventName: string, values: Record<string, string \| number \| boolean>): boolean`
222
+
223
+ ## Best Practices
224
+
225
+ 1. **Store Dialog IDs**: When manually tracking custom dialogs, store the dialog ID in your component state to properly track dismiss events.
226
+
227
+ 2. **Use Consistent Naming**: Use descriptive dialog titles and button text for better analytics.
228
+
229
+ 3. **Handle Errors**: Wrap dialog tracking calls in try-catch blocks to prevent app crashes.
230
+
231
+ 4. **Clean Up**: Call the cleanup method when components unmount to prevent memory leaks.
232
+
233
+ ## Example Implementation
234
+
235
+ See `src/examples/DialogTrackingExample.tsx` for a complete example showing all features.
236
+
237
+ ## Troubleshooting
238
+
239
+ ### Dialog events not being tracked
240
+ 1. Ensure `captureDialogEvents={true}` is set on the Connect component
241
+ 2. Check that the DialogListener is properly initialized
242
+ 3. Verify that the native AcousticConnectRN interface is available
243
+
244
+ ### Custom dialog tracking not working
245
+ 1. Make sure you're calling `trackDialogShow` before showing the dialog
246
+ 2. Store the dialog ID and use it consistently for dismiss events
247
+ 3. Use `createTrackedButton` for automatic button click tracking
248
+
249
+ ### Performance considerations
250
+ - Dialog tracking is lightweight and shouldn't impact app performance
251
+ - The system uses efficient event delegation and cleanup
252
+ - Dialog IDs are generated using a simple algorithm to avoid external dependencies
@@ -0,0 +1,176 @@
1
+ # Native Implementation for Dialog Event Tracking
2
+
3
+ This document summarizes the native implementation of the dialog event tracking functionality for both Android and iOS platforms.
4
+
5
+ ## Overview
6
+
7
+ The dialog event tracking system has been implemented across all three layers:
8
+ 1. **TypeScript Interface** (`src/specs/react-native-acoustic-connect.nitro.ts`)
9
+ 2. **Android Implementation** (`android/src/main/java/com/acousticconnectrn/HybridAcousticConnectRN.kt`)
10
+ 3. **iOS Implementation** (`ios/HybridAcousticConnectRN.swift`)
11
+
12
+ ## Interface Methods Added
13
+
14
+ Four new methods were added to the `AcousticConnectRN` interface:
15
+
16
+ ### 1. `logDialogShowEvent`
17
+ - **Purpose**: Logs when a dialog is shown
18
+ - **Parameters**:
19
+ - `dialogId`: Unique identifier for the dialog
20
+ - `dialogTitle`: The title of the dialog
21
+ - `dialogType`: The type of dialog (alert, custom, modal)
22
+ - **Returns**: `Boolean` indicating success/failure
23
+
24
+ ### 2. `logDialogDismissEvent`
25
+ - **Purpose**: Logs when a dialog is dismissed
26
+ - **Parameters**:
27
+ - `dialogId`: Unique identifier for the dialog
28
+ - `dismissReason`: The reason for dismissing the dialog
29
+ - **Returns**: `Boolean` indicating success/failure
30
+
31
+ ### 3. `logDialogButtonClickEvent`
32
+ - **Purpose**: Logs when a button in a dialog is clicked
33
+ - **Parameters**:
34
+ - `dialogId`: Unique identifier for the dialog
35
+ - `buttonText`: The text of the clicked button
36
+ - `buttonIndex`: The index of the clicked button
37
+ - **Returns**: `Boolean` indicating success/failure
38
+
39
+ ### 4. `logDialogCustomEvent`
40
+ - **Purpose**: Logs custom dialog events with additional data
41
+ - **Parameters**:
42
+ - `dialogId`: Unique identifier for the dialog
43
+ - `eventName`: The name of the custom event
44
+ - `values`: A map of values associated with the event
45
+ - **Returns**: `Boolean` indicating success/failure
46
+
47
+ ## Android Implementation
48
+
49
+ ### File: `android/src/main/java/com/acousticconnectrn/HybridAcousticConnectRN.kt`
50
+
51
+ All four methods have been implemented using the existing `Connect.logCustomEvent()` API:
52
+
53
+ ```kotlin
54
+ override fun logDialogShowEvent(dialogId: String, dialogTitle: String, dialogType: String): Boolean {
55
+ var result = false
56
+ try {
57
+ val values = HashMap<String?, String?>()
58
+ values["dialogId"] = dialogId
59
+ values["dialogTitle"] = dialogTitle
60
+ values["dialogType"] = dialogType
61
+ values["eventType"] = "dialog_show"
62
+ values["timestamp"] = System.currentTimeMillis().toString()
63
+
64
+ result = Connect.logCustomEvent("DialogShowEvent", values, EOMonitoringLevel.kEOMonitoringLevelInfo.value)
65
+ } catch (e: Exception) {
66
+ println("Error logging dialog show event: ${e.message}")
67
+ result = false
68
+ }
69
+ return result
70
+ }
71
+ ```
72
+
73
+ ### Key Features:
74
+ - **Error Handling**: All methods include try-catch blocks for robust error handling
75
+ - **Consistent Logging**: Uses the same `Connect.logCustomEvent()` API as other events
76
+ - **Timestamp**: Includes millisecond timestamps for event tracking
77
+ - **Event Type**: Each event includes an `eventType` field for easy filtering
78
+ - **Monitoring Level**: Uses `EOMonitoringLevel.kEOMonitoringLevelInfo.value` for consistent logging level
79
+
80
+ ## iOS Implementation
81
+
82
+ ### File: `ios/HybridAcousticConnectRN.swift`
83
+
84
+ All four methods have been implemented using the existing `ConnectCustomEvent().logEvent()` API:
85
+
86
+ ```swift
87
+ func logDialogShowEvent(dialogId: String, dialogTitle: String, dialogType: String) throws -> Bool {
88
+ let values: [String: Any] = [
89
+ "dialogId": dialogId,
90
+ "dialogTitle": dialogTitle,
91
+ "dialogType": dialogType,
92
+ "eventType": "dialog_show",
93
+ "timestamp": String(Int(Date().timeIntervalSince1970 * 1000))
94
+ ]
95
+
96
+ let result = ConnectCustomEvent().logEvent("DialogShowEvent", values: values, level: kConnectMonitoringLevelType.connectMonitoringLevelInfo)
97
+ return result
98
+ }
99
+ ```
100
+
101
+ ### Key Features:
102
+ - **Error Handling**: Uses Swift's throwing mechanism for error handling
103
+ - **Consistent Logging**: Uses the same `ConnectCustomEvent().logEvent()` API as other events
104
+ - **Timestamp**: Includes millisecond timestamps for event tracking
105
+ - **Event Type**: Each event includes an `eventType` field for easy filtering
106
+ - **Monitoring Level**: Uses `kConnectMonitoringLevelType.connectMonitoringLevelInfo` for consistent logging level
107
+ - **Type Safety**: Leverages Swift's strong typing for parameter validation
108
+
109
+ ## Generated Spec Files
110
+
111
+ The Nitro framework automatically generated the interface specifications:
112
+
113
+ ### Android: `nitrogen/generated/android/kotlin/com/margelo/nitro/acousticconnectrn/HybridAcousticConnectRNSpec.kt`
114
+ - Contains abstract method declarations for all four dialog event methods
115
+ - Properly annotated with `@DoNotStrip` and `@Keep` for ProGuard compatibility
116
+
117
+ ### iOS: `nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec.swift`
118
+ - Contains protocol method declarations for all four dialog event methods
119
+ - Includes proper Swift documentation comments
120
+
121
+ ## Data Structure
122
+
123
+ All dialog events include consistent metadata:
124
+
125
+ ```json
126
+ {
127
+ "dialogId": "unique_dialog_identifier",
128
+ "eventType": "dialog_show|dialog_dismiss|dialog_button_click|dialog_custom_event",
129
+ "timestamp": "1703123456789",
130
+ // Additional fields specific to each event type
131
+ }
132
+ ```
133
+
134
+ ## Error Handling Strategy
135
+
136
+ ### Android:
137
+ - Uses try-catch blocks to prevent app crashes
138
+ - Logs error messages to console for debugging
139
+ - Returns `false` on any exception
140
+
141
+ ### iOS:
142
+ - Uses Swift's throwing mechanism
143
+ - Errors are propagated up the call stack
144
+ - Caller can handle errors appropriately
145
+
146
+ ## Performance Considerations
147
+
148
+ - **Lightweight**: All methods are lightweight and don't perform heavy operations
149
+ - **Async Safe**: Methods can be called from any thread
150
+ - **Memory Efficient**: Uses simple data structures and minimal memory allocation
151
+ - **Network Efficient**: Events are batched and sent according to existing Connect SDK policies
152
+
153
+ ## Testing
154
+
155
+ The implementation can be tested using:
156
+
157
+ 1. **Unit Tests**: Test individual method calls
158
+ 2. **Integration Tests**: Test with actual dialog components
159
+ 3. **End-to-End Tests**: Verify events appear in Acoustic Connect dashboard
160
+
161
+ ## Future Enhancements
162
+
163
+ Potential improvements for future versions:
164
+
165
+ 1. **Event Batching**: Batch multiple dialog events for better performance
166
+ 2. **Custom Event Types**: Allow developers to define custom dialog event types
167
+ 3. **Event Filtering**: Add configuration options to filter specific dialog events
168
+ 4. **Analytics Integration**: Direct integration with analytics platforms
169
+ 5. **Performance Metrics**: Track dialog performance metrics (show time, interaction time)
170
+
171
+ ## Compatibility
172
+
173
+ - **Backward Compatible**: No breaking changes to existing functionality
174
+ - **Platform Agnostic**: Consistent API across Android and iOS
175
+ - **Framework Compatible**: Works with existing Connect SDK infrastructure
176
+ - **Version Safe**: Compatible with current React Native versions
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+
3
+ /********************************************************************************************
4
+ * Copyright (C) 2025 Acoustic, L.P. All rights reserved.
5
+ *
6
+ * NOTICE: This file contains material that is confidential and proprietary to
7
+ * Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
8
+ * industrial property rights of Acoustic, L.P. except as may be provided in an agreement with
9
+ * Acoustic, L.P. Any unauthorized copying or distribution of content from this file is
10
+ * prohibited.
11
+ ********************************************************************************************/
12
+
13
+ import React, { useState } from 'react';
14
+ import { View, Text, Button, Alert, StyleSheet } from 'react-native';
15
+ import { useDialogTracking } from '../utils/useDialogTracking';
16
+
17
+ /**
18
+ * Example component demonstrating dialog event tracking
19
+ * Shows how to use both automatic Alert.alert interception and manual custom dialog tracking
20
+ */
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ const DialogTrackingExample = () => {
23
+ const [customDialogVisible, setCustomDialogVisible] = useState(false);
24
+ const {
25
+ generateDialogId,
26
+ trackDialogShow,
27
+ trackDialogDismiss,
28
+ createTrackedButton
29
+ } = useDialogTracking();
30
+
31
+ // Example 1: Automatic Alert.alert tracking (no additional code needed)
32
+ const showAlertDialog = () => {
33
+ Alert.alert('Confirmation', 'Are you sure you want to proceed?', [{
34
+ text: 'Cancel',
35
+ style: 'cancel'
36
+ }, {
37
+ text: 'OK',
38
+ onPress: () => console.log('OK pressed')
39
+ }]);
40
+ };
41
+
42
+ // Example 2: Manual custom dialog tracking
43
+ const showCustomDialog = () => {
44
+ const dialogId = generateDialogId();
45
+ const title = 'Custom Dialog';
46
+ const buttons = [{
47
+ text: 'Cancel',
48
+ style: 'cancel'
49
+ }, {
50
+ text: 'Confirm',
51
+ onPress: () => console.log('Confirm pressed')
52
+ }];
53
+
54
+ // Track dialog show event
55
+ trackDialogShow(dialogId, title, buttons);
56
+ setCustomDialogVisible(true);
57
+ };
58
+ const hideCustomDialog = () => {
59
+ const dialogId = generateDialogId(); // In real app, you'd store this
60
+ trackDialogDismiss(dialogId, 'user_dismiss');
61
+ setCustomDialogVisible(false);
62
+ };
63
+
64
+ // Example 3: Custom dialog with tracked buttons
65
+ const showTrackedCustomDialog = () => {
66
+ const dialogId = generateDialogId();
67
+ const title = 'Tracked Custom Dialog';
68
+ const originalButtons = [{
69
+ text: 'No',
70
+ style: 'cancel'
71
+ }, {
72
+ text: 'Yes',
73
+ onPress: () => console.log('Yes pressed')
74
+ }];
75
+
76
+ // Create tracked buttons
77
+ const trackedButtons = originalButtons.map((button, index) => createTrackedButton(dialogId, button, index));
78
+ trackDialogShow(dialogId, title, trackedButtons);
79
+ setCustomDialogVisible(true);
80
+ };
81
+ return /*#__PURE__*/_jsxs(View, {
82
+ style: styles.container,
83
+ children: [/*#__PURE__*/_jsx(Text, {
84
+ style: styles.title,
85
+ children: "Dialog Tracking Examples"
86
+ }), /*#__PURE__*/_jsx(View, {
87
+ style: styles.buttonContainer,
88
+ children: /*#__PURE__*/_jsx(Button, {
89
+ title: "Show Alert Dialog (Auto-tracked)",
90
+ onPress: showAlertDialog
91
+ })
92
+ }), /*#__PURE__*/_jsx(View, {
93
+ style: styles.buttonContainer,
94
+ children: /*#__PURE__*/_jsx(Button, {
95
+ title: "Show Custom Dialog (Manual tracking)",
96
+ onPress: showCustomDialog
97
+ })
98
+ }), /*#__PURE__*/_jsx(View, {
99
+ style: styles.buttonContainer,
100
+ children: /*#__PURE__*/_jsx(Button, {
101
+ title: "Show Tracked Custom Dialog",
102
+ onPress: showTrackedCustomDialog
103
+ })
104
+ }), customDialogVisible && /*#__PURE__*/_jsxs(View, {
105
+ style: styles.customDialog,
106
+ children: [/*#__PURE__*/_jsx(Text, {
107
+ style: styles.dialogTitle,
108
+ children: "Custom Dialog"
109
+ }), /*#__PURE__*/_jsx(Text, {
110
+ style: styles.dialogMessage,
111
+ children: "This is a custom dialog with manual tracking"
112
+ }), /*#__PURE__*/_jsxs(View, {
113
+ style: styles.dialogButtons,
114
+ children: [/*#__PURE__*/_jsx(Button, {
115
+ title: "Cancel",
116
+ onPress: hideCustomDialog
117
+ }), /*#__PURE__*/_jsx(Button, {
118
+ title: "OK",
119
+ onPress: hideCustomDialog
120
+ })]
121
+ })]
122
+ })]
123
+ });
124
+ };
125
+ const styles = StyleSheet.create({
126
+ container: {
127
+ flex: 1,
128
+ padding: 20,
129
+ justifyContent: 'center'
130
+ },
131
+ title: {
132
+ fontSize: 24,
133
+ fontWeight: 'bold',
134
+ textAlign: 'center',
135
+ marginBottom: 30
136
+ },
137
+ buttonContainer: {
138
+ marginVertical: 10
139
+ },
140
+ customDialog: {
141
+ position: 'absolute',
142
+ top: '50%',
143
+ left: 20,
144
+ right: 20,
145
+ backgroundColor: 'white',
146
+ borderRadius: 10,
147
+ padding: 20,
148
+ elevation: 5,
149
+ shadowColor: '#000',
150
+ shadowOffset: {
151
+ width: 0,
152
+ height: 2
153
+ },
154
+ shadowOpacity: 0.25,
155
+ shadowRadius: 3.84
156
+ },
157
+ dialogTitle: {
158
+ fontSize: 18,
159
+ fontWeight: 'bold',
160
+ marginBottom: 10
161
+ },
162
+ dialogMessage: {
163
+ fontSize: 16,
164
+ marginBottom: 20
165
+ },
166
+ dialogButtons: {
167
+ flexDirection: 'row',
168
+ justifyContent: 'space-around'
169
+ }
170
+ });
171
+ export default DialogTrackingExample;
172
+ //# sourceMappingURL=DialogTrackingExample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useState","View","Text","Button","Alert","StyleSheet","useDialogTracking","jsx","_jsx","jsxs","_jsxs","DialogTrackingExample","customDialogVisible","setCustomDialogVisible","generateDialogId","trackDialogShow","trackDialogDismiss","createTrackedButton","showAlertDialog","alert","text","style","onPress","console","log","showCustomDialog","dialogId","title","buttons","hideCustomDialog","showTrackedCustomDialog","originalButtons","trackedButtons","map","button","index","styles","container","children","buttonContainer","customDialog","dialogTitle","dialogMessage","dialogButtons","create","flex","padding","justifyContent","fontSize","fontWeight","textAlign","marginBottom","marginVertical","position","top","left","right","backgroundColor","borderRadius","elevation","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","flexDirection"],"sourceRoot":"../../../src","sources":["examples/DialogTrackingExample.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,IAAI,EAAEC,IAAI,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,QAAQ,cAAc;AACpE,SAASC,iBAAiB,QAAQ,4BAA4B;;AAE9D;AACA;AACA;AACA;AAHA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAIA,MAAMC,qBAA+B,GAAGA,CAAA,KAAM;EAC1C,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGb,QAAQ,CAAC,KAAK,CAAC;EACrE,MAAM;IACFc,gBAAgB;IAChBC,eAAe;IACfC,kBAAkB;IAClBC;EACJ,CAAC,GAAGX,iBAAiB,CAAC,CAAC;;EAEvB;EACA,MAAMY,eAAe,GAAGA,CAAA,KAAM;IAC1Bd,KAAK,CAACe,KAAK,CACP,cAAc,EACd,mCAAmC,EACnC,CACI;MAAEC,IAAI,EAAE,QAAQ;MAAEC,KAAK,EAAE;IAAS,CAAC,EACnC;MAAED,IAAI,EAAE,IAAI;MAAEE,OAAO,EAAEA,CAAA,KAAMC,OAAO,CAACC,GAAG,CAAC,YAAY;IAAE,CAAC,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