react-native-acoustic-connect-beta 18.0.13 → 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.
- package/Examples/SampleUI/.detoxrc.js +83 -0
- package/Examples/SampleUI/ConnectConfig.json +2 -2
- package/Examples/SampleUI/android/app/build.gradle +3 -0
- package/Examples/SampleUI/android/app/src/main/java/com/sampleui/MainActivity.kt +0 -35
- package/Examples/SampleUI/android/settings.gradle +1 -1
- package/Examples/SampleUI/package.json +8 -6
- package/Examples/SampleUI/scripts/integration-test-android.sh +292 -0
- package/Examples/SampleUI/src/Examples/DialogExample.tsx +88 -2
- package/Examples/SampleUI/src/Examples/Dialogs/DialogTrackingTest.tsx +307 -0
- package/Examples/SampleUI/src/Examples/Dialogs/index.tsx +37 -0
- package/Examples/SampleUI/src/index.native.tsx +5 -5
- package/android/build.gradle +2 -2
- package/android/src/main/assets/ConnectAdvancedConfig.json +1 -1
- package/android/src/main/assets/TealeafAdvancedConfig.json +1 -1
- package/android/src/main/java/com/acousticconnectrn/HybridAcousticConnectRN.kt +787 -490
- package/ios/HybridAcousticConnectRN.swift +79 -4
- package/lib/commonjs/TLTRN.js +69 -0
- package/lib/commonjs/TLTRN.js.map +1 -1
- package/lib/commonjs/components/Connect.js +31 -29
- package/lib/commonjs/components/Connect.js.map +1 -1
- package/lib/commonjs/docs/DialogTracking.md +252 -0
- package/lib/commonjs/docs/NativeImplementation.md +176 -0
- package/lib/commonjs/examples/DialogTrackingExample.js +175 -0
- package/lib/commonjs/examples/DialogTrackingExample.js.map +1 -0
- package/lib/commonjs/examples/HOCDialogExample.js +296 -0
- package/lib/commonjs/examples/HOCDialogExample.js.map +1 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/DialogDebugger.js +216 -0
- package/lib/commonjs/utils/DialogDebugger.js.map +1 -0
- package/lib/commonjs/utils/DialogListener.js +203 -0
- package/lib/commonjs/utils/DialogListener.js.map +1 -0
- package/lib/commonjs/utils/useDialogTracking.js +107 -0
- package/lib/commonjs/utils/useDialogTracking.js.map +1 -0
- package/lib/commonjs/utils/withAcousticAutoDialog.js +282 -0
- package/lib/commonjs/utils/withAcousticAutoDialog.js.map +1 -0
- package/lib/module/TLTRN.js +69 -0
- package/lib/module/TLTRN.js.map +1 -1
- package/lib/module/components/Connect.js +32 -31
- package/lib/module/components/Connect.js.map +1 -1
- package/lib/module/docs/DialogTracking.md +252 -0
- package/lib/module/docs/NativeImplementation.md +176 -0
- package/lib/module/examples/DialogTrackingExample.js +172 -0
- package/lib/module/examples/DialogTrackingExample.js.map +1 -0
- package/lib/module/examples/HOCDialogExample.js +292 -0
- package/lib/module/examples/HOCDialogExample.js.map +1 -0
- package/lib/module/index.js +5 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/DialogDebugger.js +211 -0
- package/lib/module/utils/DialogDebugger.js.map +1 -0
- package/lib/module/utils/DialogListener.js +199 -0
- package/lib/module/utils/DialogListener.js.map +1 -0
- package/lib/module/utils/useDialogTracking.js +102 -0
- package/lib/module/utils/useDialogTracking.js.map +1 -0
- package/lib/module/utils/withAcousticAutoDialog.js +275 -0
- package/lib/module/utils/withAcousticAutoDialog.js.map +1 -0
- package/lib/typescript/src/TLTRN.d.ts +7 -0
- package/lib/typescript/src/TLTRN.d.ts.map +1 -1
- package/lib/typescript/src/components/Connect.d.ts +2 -2
- package/lib/typescript/src/components/Connect.d.ts.map +1 -1
- package/lib/typescript/src/examples/DialogTrackingExample.d.ts +17 -0
- package/lib/typescript/src/examples/DialogTrackingExample.d.ts.map +1 -0
- package/lib/typescript/src/examples/HOCDialogExample.d.ts +21 -0
- package/lib/typescript/src/examples/HOCDialogExample.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts +4 -0
- package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts.map +1 -1
- package/lib/typescript/src/utils/DialogDebugger.d.ts +58 -0
- package/lib/typescript/src/utils/DialogDebugger.d.ts.map +1 -0
- package/lib/typescript/src/utils/DialogListener.d.ts +85 -0
- package/lib/typescript/src/utils/DialogListener.d.ts.map +1 -0
- package/lib/typescript/src/utils/useDialogTracking.d.ts +25 -0
- package/lib/typescript/src/utils/useDialogTracking.d.ts.map +1 -0
- package/lib/typescript/src/utils/withAcousticAutoDialog.d.ts +37 -0
- package/lib/typescript/src/utils/withAcousticAutoDialog.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.hpp +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/acousticconnectrn/HybridAcousticConnectRNSpec.kt +16 -0
- package/nitrogen/generated/ios/c++/HybridAcousticConnectRNSpecSwift.hpp +32 -0
- package/nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec_cxx.swift +71 -0
- package/nitrogen/generated/shared/c++/HybridAcousticConnectRNSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridAcousticConnectRNSpec.hpp +4 -0
- package/package.json +1 -1
- package/scripts/ConnectConfig.json +1 -1
- package/src/TLTRN.ts +75 -0
- package/src/components/Connect.tsx +92 -101
- package/src/docs/DialogTracking.md +252 -0
- package/src/docs/NativeImplementation.md +176 -0
- package/src/examples/DialogTrackingExample.tsx +163 -0
- package/src/examples/HOCDialogExample.tsx +253 -0
- package/src/index.ts +5 -1
- package/src/specs/react-native-acoustic-connect.nitro.ts +5 -0
- package/src/utils/DialogDebugger.ts +224 -0
- package/src/utils/DialogListener.ts +238 -0
- package/src/utils/useDialogTracking.ts +102 -0
- package/src/utils/withAcousticAutoDialog.tsx +312 -0
|
@@ -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,163 @@
|
|
|
1
|
+
/********************************************************************************************
|
|
2
|
+
* Copyright (C) 2025 Acoustic, L.P. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* NOTICE: This file contains material that is confidential and proprietary to
|
|
5
|
+
* Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
|
|
6
|
+
* industrial property rights of Acoustic, L.P. except as may be provided in an agreement with
|
|
7
|
+
* Acoustic, L.P. Any unauthorized copying or distribution of content from this file is
|
|
8
|
+
* prohibited.
|
|
9
|
+
********************************************************************************************/
|
|
10
|
+
|
|
11
|
+
import React, { useState } from 'react';
|
|
12
|
+
import { View, Text, Button, Alert, StyleSheet } from 'react-native';
|
|
13
|
+
import { useDialogTracking } from '../utils/useDialogTracking';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Example component demonstrating dialog event tracking
|
|
17
|
+
* Shows how to use both automatic Alert.alert interception and manual custom dialog tracking
|
|
18
|
+
*/
|
|
19
|
+
const DialogTrackingExample: React.FC = () => {
|
|
20
|
+
const [customDialogVisible, setCustomDialogVisible] = useState(false);
|
|
21
|
+
const {
|
|
22
|
+
generateDialogId,
|
|
23
|
+
trackDialogShow,
|
|
24
|
+
trackDialogDismiss,
|
|
25
|
+
createTrackedButton
|
|
26
|
+
} = useDialogTracking();
|
|
27
|
+
|
|
28
|
+
// Example 1: Automatic Alert.alert tracking (no additional code needed)
|
|
29
|
+
const showAlertDialog = () => {
|
|
30
|
+
Alert.alert(
|
|
31
|
+
'Confirmation',
|
|
32
|
+
'Are you sure you want to proceed?',
|
|
33
|
+
[
|
|
34
|
+
{ text: 'Cancel', style: 'cancel' },
|
|
35
|
+
{ text: 'OK', onPress: () => console.log('OK pressed') }
|
|
36
|
+
]
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Example 2: Manual custom dialog tracking
|
|
41
|
+
const showCustomDialog = () => {
|
|
42
|
+
const dialogId = generateDialogId();
|
|
43
|
+
const title = 'Custom Dialog';
|
|
44
|
+
const buttons = [
|
|
45
|
+
{ text: 'Cancel', style: 'cancel' as const },
|
|
46
|
+
{ text: 'Confirm', onPress: () => console.log('Confirm pressed') }
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
// Track dialog show event
|
|
50
|
+
trackDialogShow(dialogId, title, buttons);
|
|
51
|
+
setCustomDialogVisible(true);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const hideCustomDialog = () => {
|
|
55
|
+
const dialogId = generateDialogId(); // In real app, you'd store this
|
|
56
|
+
trackDialogDismiss(dialogId, 'user_dismiss');
|
|
57
|
+
setCustomDialogVisible(false);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Example 3: Custom dialog with tracked buttons
|
|
61
|
+
const showTrackedCustomDialog = () => {
|
|
62
|
+
const dialogId = generateDialogId();
|
|
63
|
+
const title = 'Tracked Custom Dialog';
|
|
64
|
+
const originalButtons = [
|
|
65
|
+
{ text: 'No', style: 'cancel' as const },
|
|
66
|
+
{ text: 'Yes', onPress: () => console.log('Yes pressed') }
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
// Create tracked buttons
|
|
70
|
+
const trackedButtons = originalButtons.map((button, index) =>
|
|
71
|
+
createTrackedButton(dialogId, button, index)
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
trackDialogShow(dialogId, title, trackedButtons);
|
|
75
|
+
setCustomDialogVisible(true);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<View style={styles.container}>
|
|
80
|
+
<Text style={styles.title}>Dialog Tracking Examples</Text>
|
|
81
|
+
|
|
82
|
+
<View style={styles.buttonContainer}>
|
|
83
|
+
<Button
|
|
84
|
+
title="Show Alert Dialog (Auto-tracked)"
|
|
85
|
+
onPress={showAlertDialog}
|
|
86
|
+
/>
|
|
87
|
+
</View>
|
|
88
|
+
|
|
89
|
+
<View style={styles.buttonContainer}>
|
|
90
|
+
<Button
|
|
91
|
+
title="Show Custom Dialog (Manual tracking)"
|
|
92
|
+
onPress={showCustomDialog}
|
|
93
|
+
/>
|
|
94
|
+
</View>
|
|
95
|
+
|
|
96
|
+
<View style={styles.buttonContainer}>
|
|
97
|
+
<Button
|
|
98
|
+
title="Show Tracked Custom Dialog"
|
|
99
|
+
onPress={showTrackedCustomDialog}
|
|
100
|
+
/>
|
|
101
|
+
</View>
|
|
102
|
+
|
|
103
|
+
{customDialogVisible && (
|
|
104
|
+
<View style={styles.customDialog}>
|
|
105
|
+
<Text style={styles.dialogTitle}>Custom Dialog</Text>
|
|
106
|
+
<Text style={styles.dialogMessage}>
|
|
107
|
+
This is a custom dialog with manual tracking
|
|
108
|
+
</Text>
|
|
109
|
+
<View style={styles.dialogButtons}>
|
|
110
|
+
<Button title="Cancel" onPress={hideCustomDialog} />
|
|
111
|
+
<Button title="OK" onPress={hideCustomDialog} />
|
|
112
|
+
</View>
|
|
113
|
+
</View>
|
|
114
|
+
)}
|
|
115
|
+
</View>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const styles = StyleSheet.create({
|
|
120
|
+
container: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
padding: 20,
|
|
123
|
+
justifyContent: 'center',
|
|
124
|
+
},
|
|
125
|
+
title: {
|
|
126
|
+
fontSize: 24,
|
|
127
|
+
fontWeight: 'bold',
|
|
128
|
+
textAlign: 'center',
|
|
129
|
+
marginBottom: 30,
|
|
130
|
+
},
|
|
131
|
+
buttonContainer: {
|
|
132
|
+
marginVertical: 10,
|
|
133
|
+
},
|
|
134
|
+
customDialog: {
|
|
135
|
+
position: 'absolute',
|
|
136
|
+
top: '50%',
|
|
137
|
+
left: 20,
|
|
138
|
+
right: 20,
|
|
139
|
+
backgroundColor: 'white',
|
|
140
|
+
borderRadius: 10,
|
|
141
|
+
padding: 20,
|
|
142
|
+
elevation: 5,
|
|
143
|
+
shadowColor: '#000',
|
|
144
|
+
shadowOffset: { width: 0, height: 2 },
|
|
145
|
+
shadowOpacity: 0.25,
|
|
146
|
+
shadowRadius: 3.84,
|
|
147
|
+
},
|
|
148
|
+
dialogTitle: {
|
|
149
|
+
fontSize: 18,
|
|
150
|
+
fontWeight: 'bold',
|
|
151
|
+
marginBottom: 10,
|
|
152
|
+
},
|
|
153
|
+
dialogMessage: {
|
|
154
|
+
fontSize: 16,
|
|
155
|
+
marginBottom: 20,
|
|
156
|
+
},
|
|
157
|
+
dialogButtons: {
|
|
158
|
+
flexDirection: 'row',
|
|
159
|
+
justifyContent: 'space-around',
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export default DialogTrackingExample;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/********************************************************************************************
|
|
2
|
+
* Copyright (C) 2025 Acoustic, L.P. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* NOTICE: This file contains material that is confidential and proprietary to
|
|
5
|
+
* Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
|
|
6
|
+
* industrial property rights of Acoustic, L.P. except as may be provided in an agreement with
|
|
7
|
+
* Acoustic, L.P. Any unauthorized copying or distribution of content from this file is
|
|
8
|
+
* prohibited.
|
|
9
|
+
********************************************************************************************/
|
|
10
|
+
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { View, Text, TouchableOpacity, StyleSheet, Alert } from 'react-native';
|
|
13
|
+
import Connect from '../components/Connect';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Example demonstrating HOC-based Paper Dialog tracking
|
|
17
|
+
*
|
|
18
|
+
* This approach requires minimal code changes:
|
|
19
|
+
* 1. Create tracked versions of your dialog components
|
|
20
|
+
* 2. Use the tracked versions instead of the original ones
|
|
21
|
+
* 3. All dialog events are automatically tracked!
|
|
22
|
+
*/
|
|
23
|
+
const HOCDialogExample: React.FC = () => {
|
|
24
|
+
const [dialogVisible, setDialogVisible] = React.useState(false);
|
|
25
|
+
|
|
26
|
+
// Example 1: React Native Alert.alert (automatically tracked)
|
|
27
|
+
const showAlertDialog = () => {
|
|
28
|
+
Alert.alert(
|
|
29
|
+
'Confirmation Alert',
|
|
30
|
+
'This is a native alert dialog that is automatically tracked.',
|
|
31
|
+
[
|
|
32
|
+
{ text: 'Cancel', style: 'cancel' },
|
|
33
|
+
{ text: 'OK', onPress: () => console.log('Alert OK pressed') }
|
|
34
|
+
]
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Example 2: Paper Dialog with HOC tracking
|
|
39
|
+
const showPaperDialog = () => {
|
|
40
|
+
setDialogVisible(true);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const hidePaperDialog = () => {
|
|
44
|
+
setDialogVisible(false);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Connect captureDialogEvents={true} captureKeyboardEvents={false}>
|
|
49
|
+
<View style={styles.container}>
|
|
50
|
+
<Text style={styles.title}>HOC Dialog Tracking Example</Text>
|
|
51
|
+
<Text style={styles.subtitle}>
|
|
52
|
+
Minimal code changes required - just wrap your dialog components!
|
|
53
|
+
</Text>
|
|
54
|
+
|
|
55
|
+
<View style={styles.buttonContainer}>
|
|
56
|
+
<TouchableOpacity style={styles.button} onPress={showAlertDialog}>
|
|
57
|
+
<Text style={styles.buttonText}>Show Alert.alert</Text>
|
|
58
|
+
<Text style={styles.buttonSubtext}>Automatically tracked</Text>
|
|
59
|
+
</TouchableOpacity>
|
|
60
|
+
|
|
61
|
+
<TouchableOpacity style={styles.button} onPress={showPaperDialog}>
|
|
62
|
+
<Text style={styles.buttonText}>Show Paper Dialog (HOC)</Text>
|
|
63
|
+
<Text style={styles.buttonSubtext}>Minimal code changes</Text>
|
|
64
|
+
</TouchableOpacity>
|
|
65
|
+
</View>
|
|
66
|
+
|
|
67
|
+
<View style={styles.infoContainer}>
|
|
68
|
+
<Text style={styles.infoTitle}>How to use HOC approach:</Text>
|
|
69
|
+
<Text style={styles.infoText}>1. Create tracked dialog components</Text>
|
|
70
|
+
<Text style={styles.infoText}>2. Use tracked versions instead of originals</Text>
|
|
71
|
+
<Text style={styles.infoText}>3. All events automatically tracked!</Text>
|
|
72
|
+
<Text style={styles.infoText}>4. No manual tracking code needed</Text>
|
|
73
|
+
</View>
|
|
74
|
+
|
|
75
|
+
<View style={styles.codeContainer}>
|
|
76
|
+
<Text style={styles.codeTitle}>Example Setup Code:</Text>
|
|
77
|
+
<Text style={styles.codeText}>
|
|
78
|
+
{`// In your app setup
|
|
79
|
+
import { withAcousticAutoDialog } from 'react-native-acoustic-connect-beta';
|
|
80
|
+
import { Dialog, Portal } from 'react-native-paper';
|
|
81
|
+
|
|
82
|
+
// Create tracked versions
|
|
83
|
+
const TrackedDialog = withAcousticAutoDialog(Dialog);
|
|
84
|
+
const TrackedPortal = withAcousticAutoDialog(Portal);
|
|
85
|
+
|
|
86
|
+
// Use TrackedDialog instead of Dialog - that's it!`}
|
|
87
|
+
</Text>
|
|
88
|
+
</View>
|
|
89
|
+
|
|
90
|
+
{/* Example of how the tracked dialog would be used */}
|
|
91
|
+
{dialogVisible && (
|
|
92
|
+
<View style={styles.exampleDialog}>
|
|
93
|
+
<Text style={styles.dialogTitle}>Example Dialog</Text>
|
|
94
|
+
<Text style={styles.dialogContent}>
|
|
95
|
+
This shows how you would use the tracked dialog components.
|
|
96
|
+
In a real app, you would use TrackedDialog instead of Dialog.
|
|
97
|
+
</Text>
|
|
98
|
+
<View style={styles.dialogActions}>
|
|
99
|
+
<TouchableOpacity style={styles.dialogButton} onPress={hidePaperDialog}>
|
|
100
|
+
<Text style={styles.dialogButtonText}>Cancel</Text>
|
|
101
|
+
</TouchableOpacity>
|
|
102
|
+
<TouchableOpacity
|
|
103
|
+
style={[styles.dialogButton, styles.primaryButton]}
|
|
104
|
+
onPress={() => {
|
|
105
|
+
console.log('Dialog confirmed!');
|
|
106
|
+
hidePaperDialog();
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<Text style={styles.dialogButtonText}>Confirm</Text>
|
|
110
|
+
</TouchableOpacity>
|
|
111
|
+
</View>
|
|
112
|
+
</View>
|
|
113
|
+
)}
|
|
114
|
+
</View>
|
|
115
|
+
</Connect>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const styles = StyleSheet.create({
|
|
120
|
+
container: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
padding: 20,
|
|
123
|
+
backgroundColor: '#f5f5f5',
|
|
124
|
+
},
|
|
125
|
+
title: {
|
|
126
|
+
fontSize: 24,
|
|
127
|
+
fontWeight: 'bold',
|
|
128
|
+
textAlign: 'center',
|
|
129
|
+
marginBottom: 10,
|
|
130
|
+
color: '#333',
|
|
131
|
+
},
|
|
132
|
+
subtitle: {
|
|
133
|
+
fontSize: 16,
|
|
134
|
+
textAlign: 'center',
|
|
135
|
+
marginBottom: 30,
|
|
136
|
+
color: '#666',
|
|
137
|
+
fontStyle: 'italic',
|
|
138
|
+
},
|
|
139
|
+
buttonContainer: {
|
|
140
|
+
gap: 15,
|
|
141
|
+
},
|
|
142
|
+
button: {
|
|
143
|
+
backgroundColor: '#007AFF',
|
|
144
|
+
padding: 15,
|
|
145
|
+
borderRadius: 10,
|
|
146
|
+
shadowColor: '#000',
|
|
147
|
+
shadowOffset: { width: 0, height: 2 },
|
|
148
|
+
shadowOpacity: 0.1,
|
|
149
|
+
shadowRadius: 4,
|
|
150
|
+
elevation: 3,
|
|
151
|
+
},
|
|
152
|
+
buttonText: {
|
|
153
|
+
color: 'white',
|
|
154
|
+
fontSize: 16,
|
|
155
|
+
fontWeight: '600',
|
|
156
|
+
textAlign: 'center',
|
|
157
|
+
},
|
|
158
|
+
buttonSubtext: {
|
|
159
|
+
color: 'rgba(255, 255, 255, 0.8)',
|
|
160
|
+
fontSize: 12,
|
|
161
|
+
textAlign: 'center',
|
|
162
|
+
marginTop: 2,
|
|
163
|
+
},
|
|
164
|
+
infoContainer: {
|
|
165
|
+
backgroundColor: 'white',
|
|
166
|
+
padding: 20,
|
|
167
|
+
borderRadius: 10,
|
|
168
|
+
marginTop: 30,
|
|
169
|
+
shadowColor: '#000',
|
|
170
|
+
shadowOffset: { width: 0, height: 1 },
|
|
171
|
+
shadowOpacity: 0.1,
|
|
172
|
+
shadowRadius: 2,
|
|
173
|
+
elevation: 2,
|
|
174
|
+
},
|
|
175
|
+
infoTitle: {
|
|
176
|
+
fontSize: 18,
|
|
177
|
+
fontWeight: '600',
|
|
178
|
+
marginBottom: 10,
|
|
179
|
+
color: '#333',
|
|
180
|
+
},
|
|
181
|
+
infoText: {
|
|
182
|
+
fontSize: 14,
|
|
183
|
+
color: '#666',
|
|
184
|
+
marginBottom: 5,
|
|
185
|
+
},
|
|
186
|
+
codeContainer: {
|
|
187
|
+
backgroundColor: '#f8f9fa',
|
|
188
|
+
padding: 15,
|
|
189
|
+
borderRadius: 8,
|
|
190
|
+
marginTop: 20,
|
|
191
|
+
borderLeftWidth: 4,
|
|
192
|
+
borderLeftColor: '#007AFF',
|
|
193
|
+
},
|
|
194
|
+
codeTitle: {
|
|
195
|
+
fontSize: 16,
|
|
196
|
+
fontWeight: '600',
|
|
197
|
+
marginBottom: 10,
|
|
198
|
+
color: '#333',
|
|
199
|
+
},
|
|
200
|
+
codeText: {
|
|
201
|
+
fontSize: 12,
|
|
202
|
+
color: '#555',
|
|
203
|
+
fontFamily: 'monospace',
|
|
204
|
+
lineHeight: 18,
|
|
205
|
+
},
|
|
206
|
+
exampleDialog: {
|
|
207
|
+
position: 'absolute',
|
|
208
|
+
top: '50%',
|
|
209
|
+
left: 20,
|
|
210
|
+
right: 20,
|
|
211
|
+
backgroundColor: 'white',
|
|
212
|
+
borderRadius: 12,
|
|
213
|
+
padding: 20,
|
|
214
|
+
shadowColor: '#000',
|
|
215
|
+
shadowOffset: { width: 0, height: 4 },
|
|
216
|
+
shadowOpacity: 0.25,
|
|
217
|
+
shadowRadius: 8,
|
|
218
|
+
elevation: 8,
|
|
219
|
+
},
|
|
220
|
+
dialogTitle: {
|
|
221
|
+
fontSize: 20,
|
|
222
|
+
fontWeight: 'bold',
|
|
223
|
+
marginBottom: 15,
|
|
224
|
+
color: '#333',
|
|
225
|
+
},
|
|
226
|
+
dialogContent: {
|
|
227
|
+
fontSize: 16,
|
|
228
|
+
color: '#666',
|
|
229
|
+
marginBottom: 20,
|
|
230
|
+
lineHeight: 22,
|
|
231
|
+
},
|
|
232
|
+
dialogActions: {
|
|
233
|
+
flexDirection: 'row',
|
|
234
|
+
justifyContent: 'flex-end',
|
|
235
|
+
gap: 10,
|
|
236
|
+
},
|
|
237
|
+
dialogButton: {
|
|
238
|
+
paddingHorizontal: 20,
|
|
239
|
+
paddingVertical: 10,
|
|
240
|
+
borderRadius: 6,
|
|
241
|
+
backgroundColor: '#f0f0f0',
|
|
242
|
+
},
|
|
243
|
+
primaryButton: {
|
|
244
|
+
backgroundColor: '#007AFF',
|
|
245
|
+
},
|
|
246
|
+
dialogButtonText: {
|
|
247
|
+
fontSize: 16,
|
|
248
|
+
fontWeight: '600',
|
|
249
|
+
color: '#333',
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
export default HOCDialogExample;
|
package/src/index.ts
CHANGED
|
@@ -15,9 +15,13 @@ import { NitroModules } from 'react-native-nitro-modules'
|
|
|
15
15
|
import type { AcousticConnectRN as AcousticConnectRNSpec } from './specs/react-native-acoustic-connect.nitro'
|
|
16
16
|
import Connect from './components/Connect'
|
|
17
17
|
import KeyboardListener from './utils/KeyboardListener'
|
|
18
|
+
import DialogListener from './utils/DialogListener'
|
|
19
|
+
import useDialogTracking from './utils/useDialogTracking'
|
|
20
|
+
import { withAcousticAutoDialog } from './utils/withAcousticAutoDialog'
|
|
21
|
+
import DialogDebugger from './utils/DialogDebugger'
|
|
18
22
|
import TLTRN from './TLTRN'
|
|
19
23
|
|
|
20
24
|
const AcousticConnectRN = NitroModules.createHybridObject<AcousticConnectRNSpec>('AcousticConnectRN')
|
|
21
25
|
|
|
22
|
-
export { Connect, TLTRN, KeyboardListener}
|
|
26
|
+
export { Connect, TLTRN, KeyboardListener, DialogListener, useDialogTracking, DialogDebugger, withAcousticAutoDialog }
|
|
23
27
|
export default AcousticConnectRN
|
|
@@ -39,4 +39,9 @@ export interface AcousticConnectRN extends HybridObject<{ ios: 'swift', android:
|
|
|
39
39
|
logScreenViewContextLoad(logicalPageName: string | null | undefined, referrer:string | null | undefined): boolean
|
|
40
40
|
logScreenViewContextUnload(logicalPageName: string | null | undefined, referrer:string | null | undefined): boolean
|
|
41
41
|
logScreenLayout(name: string, delay: number): boolean
|
|
42
|
+
// New dialog event handling methods
|
|
43
|
+
logDialogShowEvent(dialogId: string, dialogTitle: string, dialogType: string): boolean
|
|
44
|
+
logDialogDismissEvent(dialogId: string, dismissReason: string): boolean
|
|
45
|
+
logDialogButtonClickEvent(dialogId: string, buttonText: string, buttonIndex: number): boolean
|
|
46
|
+
logDialogCustomEvent(dialogId: string, eventName: string, values: Record<string, string | number | boolean>): boolean
|
|
42
47
|
}
|