@tonconnect/ui 2.0.3-beta.0 → 2.0.3-beta.2

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/README.md CHANGED
@@ -751,6 +751,54 @@ tonConnectUI.onStatusChange(wallet => {
751
751
  });
752
752
  ```
753
753
 
754
+
755
+ # Tracking
756
+
757
+ ## Track events
758
+
759
+ Tracker for TonConnect user actions, such as transaction signing, connection, etc.
760
+
761
+ List of events:
762
+ * `connection-started`: when a user starts connecting a wallet.
763
+ * `connection-completed`: when a user successfully connected a wallet.
764
+ * `connection-error`: when a user cancels a connection or there is an error during the connection process.
765
+ * `connection-restoring-started`: when the dApp starts restoring a connection.
766
+ * `connection-restoring-completed`: when the dApp successfully restores a connection.
767
+ * `connection-restoring-error`: when the dApp fails to restore a connection.
768
+ * `disconnection`: when a user starts disconnecting a wallet.
769
+ * `transaction-sent-for-signature`: when a user sends a transaction for signature.
770
+ * `transaction-signed`: when a user successfully signs a transaction.
771
+ * `transaction-signing-failed`: when a user cancels transaction signing or there is an error during the signing process.
772
+
773
+ If you want to track user actions, you can subscribe to the window events with prefix `ton-connect-ui-`:
774
+
775
+ ```typescript
776
+ window.addEventListener('ton-connect-ui-transaction-sent-for-signature', (event) => {
777
+ console.log('Transaction init', event.detail);
778
+ });
779
+ ```
780
+
781
+ ## Use custom event dispatcher
782
+
783
+ You can use your custom event dispatcher to track user actions. To do this, you need to pass the `eventDispatcher` to the TonConnect constructor:
784
+
785
+ ```typescript
786
+ import { TonConnectUI, EventDispatcher, SdkActionEvent, UserActionEvent } from '@tonconnect/ui';
787
+
788
+ class CustomEventDispatcher implements EventDispatcher<UserActionEvent | SdkActionEvent> {
789
+ public async dispatchEvent(
790
+ eventName: string,
791
+ eventDetails: UserActionEvent | SdkActionEvent
792
+ ): Promise<void> {
793
+ console.log(`Event: ${eventName}, details:`, eventDetails);
794
+ }
795
+ }
796
+
797
+ const eventDispatcher = new CustomEventDispatcher();
798
+
799
+ const connector = new TonConnectUI({ eventDispatcher });
800
+ ```
801
+
754
802
  # Troubleshooting
755
803
 
756
804
  ## Android Back Handler