@tonconnect/sdk 3.0.2-beta.0 → 3.0.3-beta.0
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 +48 -0
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +358 -13
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +341 -15
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +355 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -357,6 +357,54 @@ myTelegramBot.userIsOnline(user => {
|
|
|
357
357
|
})
|
|
358
358
|
```
|
|
359
359
|
|
|
360
|
+
# Tracking
|
|
361
|
+
|
|
362
|
+
## Track events
|
|
363
|
+
|
|
364
|
+
Tracker for TonConnect user actions, such as transaction signing, connection, etc.
|
|
365
|
+
|
|
366
|
+
List of events:
|
|
367
|
+
* `connection-started`: when a user starts connecting a wallet.
|
|
368
|
+
* `connection-completed`: when a user successfully connected a wallet.
|
|
369
|
+
* `connection-error`: when a user cancels a connection or there is an error during the connection process.
|
|
370
|
+
* `connection-restoring-started`: when the dApp starts restoring a connection.
|
|
371
|
+
* `connection-restoring-completed`: when the dApp successfully restores a connection.
|
|
372
|
+
* `connection-restoring-error`: when the dApp fails to restore a connection.
|
|
373
|
+
* `disconnection`: when a user starts disconnecting a wallet.
|
|
374
|
+
* `transaction-sent-for-signature`: when a user sends a transaction for signature.
|
|
375
|
+
* `transaction-signed`: when a user successfully signs a transaction.
|
|
376
|
+
* `transaction-signing-failed`: when a user cancels transaction signing or there is an error during the signing process.
|
|
377
|
+
|
|
378
|
+
If you want to track user actions, you can subscribe to the window events with prefix `ton-connect-`:
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
window.addEventListener('ton-connect-transaction-sent-for-signature', (event) => {
|
|
382
|
+
console.log('Transaction init', event.detail);
|
|
383
|
+
});
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Use custom event dispatcher
|
|
387
|
+
|
|
388
|
+
You can use your custom event dispatcher to track user actions. To do this, you need to pass the `eventDispatcher` to the TonConnect constructor:
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
import {TonConnect, EventDispatcher, SdkActionEvent} from '@tonconnect/sdk';
|
|
392
|
+
|
|
393
|
+
class CustomEventDispatcher implements EventDispatcher<SdkActionEvent> {
|
|
394
|
+
public async dispatchEvent(
|
|
395
|
+
eventName: string,
|
|
396
|
+
eventDetails: SdkActionEvent
|
|
397
|
+
): Promise<void> {
|
|
398
|
+
console.log(`Event: ${eventName}, details:`, eventDetails);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const eventDispatcher = new CustomEventDispatcher();
|
|
403
|
+
|
|
404
|
+
const connector = new TonConnect({ eventDispatcher });
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
|
|
360
408
|
# Troubleshooting
|
|
361
409
|
|
|
362
410
|
## Warning about 'encoding' module in Next.js
|