UNPKG

react-native-acoustic-connect-beta

Version:

BETA: React native plugin for Acoustic Connect

216 lines (192 loc) 7.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.DialogDebugger = void 0; var _reactNative = require("react-native"); var _DialogListener = _interopRequireDefault(require("./DialogListener")); var _TLTRN = _interopRequireDefault(require("../TLTRN")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /******************************************************************************************** * 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. ********************************************************************************************/ /** * Debug utility for dialog event tracking * Helps identify issues with dialog event interception and logging */ class DialogDebugger { isEnabled = false; constructor() { this.originalAlert = _reactNative.Alert.alert; } static getInstance() { if (!DialogDebugger.instance) { DialogDebugger.instance = new DialogDebugger(); } return DialogDebugger.instance; } /** * Enable debug mode */ enable() { this.isEnabled = true; console.log('🔍 DialogDebugger: Debug mode enabled'); } /** * Disable debug mode */ disable() { this.isEnabled = false; console.log('🔍 DialogDebugger: Debug mode disabled'); } /** * Test the complete dialog event flow */ testDialogEventFlow() { console.log('🔍 DialogDebugger: Testing dialog event flow...'); // Test 1: Check if DialogListener is working this.testDialogListener(); // Test 2: Check if TLTRN methods are accessible this.testTLTRNMethods(); // Test 3: Check if Alert.alert override is working this.testAlertOverride(); // Test 4: Test native method calls this.testNativeMethods(); } /** * Test DialogListener functionality */ testDialogListener() { console.log('🔍 DialogDebugger: Testing DialogListener...'); try { const dialogListener = _DialogListener.default.getInstance(); console.log('✅ DialogListener.getInstance() - SUCCESS'); // Test event listener const unsubscribe = dialogListener.addEventListener(event => { console.log('🔍 DialogDebugger: DialogListener event received:', event); }); console.log('✅ DialogListener.addEventListener() - SUCCESS'); // Test manual tracking dialogListener.trackCustomDialogShow('test-dialog-id', 'Test Dialog', []); console.log('✅ DialogListener.trackCustomDialogShow() - SUCCESS'); unsubscribe(); } catch (error) { console.error('❌ DialogDebugger: DialogListener test failed:', error); } } /** * Test TLTRN methods */ testTLTRNMethods() { console.log('🔍 DialogDebugger: Testing TLTRN methods...'); try { // Test if TLTRN methods exist if (typeof _TLTRN.default.logDialogShowEvent === 'function') { console.log('✅ TLTRN.logDialogShowEvent - EXISTS'); } else { console.error('❌ TLTRN.logDialogShowEvent - NOT FOUND'); } if (typeof _TLTRN.default.interceptDialogEvents === 'function') { console.log('✅ TLTRN.interceptDialogEvents - EXISTS'); } else { console.error('❌ TLTRN.interceptDialogEvents - NOT FOUND'); } // Test method call _TLTRN.default.logDialogShowEvent('test-dialog-id', 'Test Dialog', 'test'); console.log('✅ TLTRN.logDialogShowEvent() - CALLED'); } catch (error) { console.error('❌ DialogDebugger: TLTRN test failed:', error); } } /** * Test Alert.alert override */ testAlertOverride() { console.log('🔍 DialogDebugger: Testing Alert.alert override...'); try { // Check if Alert.alert is overridden if (_reactNative.Alert.alert !== this.originalAlert) { console.log('✅ Alert.alert is overridden'); } else { console.error('❌ Alert.alert is NOT overridden'); } // Test Alert.alert call _reactNative.Alert.alert('Debug Test', 'This is a test alert', [{ text: 'OK', onPress: () => console.log('🔍 DialogDebugger: Alert OK pressed') }]); console.log('✅ Alert.alert() - CALLED'); } catch (error) { console.error('❌ DialogDebugger: Alert.alert test failed:', error); } } /** * Test native method calls */ testNativeMethods() { console.log('🔍 DialogDebugger: Testing native method calls...'); try { // Import AcousticConnectRN to test native calls const AcousticConnectRN = require('../index').default; if (AcousticConnectRN && typeof AcousticConnectRN.logDialogShowEvent === 'function') { console.log('✅ AcousticConnectRN.logDialogShowEvent - EXISTS'); // Test native call const result = AcousticConnectRN.logDialogShowEvent('test-dialog-id', 'Test Dialog', 'test'); console.log('✅ AcousticConnectRN.logDialogShowEvent() - CALLED, result:', result); } else { console.error('❌ AcousticConnectRN.logDialogShowEvent - NOT FOUND'); } } catch (error) { console.error('❌ DialogDebugger: Native method test failed:', error); } } /** * Check if dialog tracking is properly enabled */ checkDialogTrackingStatus() { console.log('🔍 DialogDebugger: Checking dialog tracking status...'); // Check DialogListener status const dialogListener = _DialogListener.default.getInstance(); console.log('DialogListener status:', { isIntercepting: dialogListener.isIntercepting, eventCallbacksCount: dialogListener.eventCallbacks?.length || 0 }); // Check if Alert.alert is overridden console.log('Alert.alert override status:', { isOverridden: _reactNative.Alert.alert !== this.originalAlert, originalAlert: this.originalAlert, currentAlert: _reactNative.Alert.alert }); // Check TLTRN methods console.log('TLTRN methods status:', { logDialogShowEvent: typeof _TLTRN.default.logDialogShowEvent, interceptDialogEvents: typeof _TLTRN.default.interceptDialogEvents }); } /** * Force enable dialog tracking for testing */ forceEnableDialogTracking() { console.log('🔍 DialogDebugger: Force enabling dialog tracking...'); try { // Force enable DialogListener const dialogListener = _DialogListener.default.getInstance(); dialogListener.isIntercepting = true; console.log('✅ DialogListener interception forced enabled'); // Force enable TLTRN dialog events _TLTRN.default.interceptDialogEvents(true); console.log('✅ TLTRN dialog events forced enabled'); } catch (error) { console.error('❌ DialogDebugger: Force enable failed:', error); } } } exports.DialogDebugger = DialogDebugger; var _default = exports.default = DialogDebugger; //# sourceMappingURL=DialogDebugger.js.map