react-native-acoustic-connect-beta
Version:
BETA: React native plugin for Acoustic Connect
175 lines (168 loc) • 6.32 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _useDialogTracking = require("../utils/useDialogTracking");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/********************************************************************************************
* Copyright (C) 2025 Acoustic, L.P. All rights reserved.
*
* NOTICE: This file contains material that is confidential and proprietary to
* Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
* industrial property rights of Acoustic, L.P. except as may be provided in an agreement with
* Acoustic, L.P. Any unauthorized copying or distribution of content from this file is
* prohibited.
********************************************************************************************/
/**
* Example component demonstrating dialog event tracking
* Shows how to use both automatic Alert.alert interception and manual custom dialog tracking
*/const DialogTrackingExample = () => {
const [customDialogVisible, setCustomDialogVisible] = (0, _react.useState)(false);
const {
generateDialogId,
trackDialogShow,
trackDialogDismiss,
createTrackedButton
} = (0, _useDialogTracking.useDialogTracking)();
// Example 1: Automatic Alert.alert tracking (no additional code needed)
const showAlertDialog = () => {
_reactNative.Alert.alert('Confirmation', 'Are you sure you want to proceed?', [{
text: 'Cancel',
style: 'cancel'
}, {
text: 'OK',
onPress: () => console.log('OK pressed')
}]);
};
// Example 2: Manual custom dialog tracking
const showCustomDialog = () => {
const dialogId = generateDialogId();
const title = 'Custom Dialog';
const buttons = [{
text: 'Cancel',
style: 'cancel'
}, {
text: 'Confirm',
onPress: () => console.log('Confirm pressed')
}];
// Track dialog show event
trackDialogShow(dialogId, title, buttons);
setCustomDialogVisible(true);
};
const hideCustomDialog = () => {
const dialogId = generateDialogId(); // In real app, you'd store this
trackDialogDismiss(dialogId, 'user_dismiss');
setCustomDialogVisible(false);
};
// Example 3: Custom dialog with tracked buttons
const showTrackedCustomDialog = () => {
const dialogId = generateDialogId();
const title = 'Tracked Custom Dialog';
const originalButtons = [{
text: 'No',
style: 'cancel'
}, {
text: 'Yes',
onPress: () => console.log('Yes pressed')
}];
// Create tracked buttons
const trackedButtons = originalButtons.map((button, index) => createTrackedButton(dialogId, button, index));
trackDialogShow(dialogId, title, trackedButtons);
setCustomDialogVisible(true);
};
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: styles.container,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: styles.title,
children: "Dialog Tracking Examples"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.buttonContainer,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Button, {
title: "Show Alert Dialog (Auto-tracked)",
onPress: showAlertDialog
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.buttonContainer,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Button, {
title: "Show Custom Dialog (Manual tracking)",
onPress: showCustomDialog
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.buttonContainer,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Button, {
title: "Show Tracked Custom Dialog",
onPress: showTrackedCustomDialog
})
}), customDialogVisible && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: styles.customDialog,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: styles.dialogTitle,
children: "Custom Dialog"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: styles.dialogMessage,
children: "This is a custom dialog with manual tracking"
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: styles.dialogButtons,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Button, {
title: "Cancel",
onPress: hideCustomDialog
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Button, {
title: "OK",
onPress: hideCustomDialog
})]
})]
})]
});
};
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1,
padding: 20,
justifyContent: 'center'
},
title: {
fontSize: 24,
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 30
},
buttonContainer: {
marginVertical: 10
},
customDialog: {
position: 'absolute',
top: '50%',
left: 20,
right: 20,
backgroundColor: 'white',
borderRadius: 10,
padding: 20,
elevation: 5,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 3.84
},
dialogTitle: {
fontSize: 18,
fontWeight: 'bold',
marginBottom: 10
},
dialogMessage: {
fontSize: 16,
marginBottom: 20
},
dialogButtons: {
flexDirection: 'row',
justifyContent: 'space-around'
}
});
var _default = exports.default = DialogTrackingExample;
//# sourceMappingURL=DialogTrackingExample.js.map