diff --git a/src/client/index.ts b/src/client/index.ts index 7afb56e3..052cfadc 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -769,7 +769,7 @@ export class Client { private async loadRemoteOutletTokens(issuer: OffChainTokenConfig): Promise { const redirectRequired = shouldUseRedirectMode(this.config.offChainRedirectMode) if (redirectRequired) this.tokenStore.setTokens(issuer.collectionID, []) - if (this.ui) { + if (this.ui && !issuer.onChain) { await waitForElementToExist('.load-container-tn') this.ui.showLoader( `

${this.config.uiOptions?.reDirectIssuerEventHeading ?? 'Connecting to Issuers...'}

`, @@ -778,13 +778,12 @@ export class Client { this.config.uiOptions?.cancelAction ?? 'Cancel' }`, ) - if (!issuer.onChain) { - this.enableTokenAutoLoadCancel() - await sleep(this.config.uiOptions.userCancelIssuerAutoRedirectTimer ?? 2500) - if (this.userCancelTokenAutoload) { - this.userCancelTokenAutoload = false - return {} - } + this.enableTokenAutoLoadCancel() + this.eventSender('page-redirecting', { collectionId: issuer.collectionID, tokenOrigin: issuer.tokenOrigin }) + await sleep(this.config.uiOptions.userCancelIssuerAutoRedirectTimer ?? 2500) + if (this.userCancelTokenAutoload) { + this.userCancelTokenAutoload = false + return {} } } const res = await this.messaging.sendMessage( @@ -1009,6 +1008,7 @@ export class Client { cancelAuthButton.onclick = () => { const err = 'User cancelled authentication' this.ui.showError(err) + this.eventSender('user-cancel', { eventType: 'Authentication' }) this.eventSender('token-proof', { issuer, error: err, data: null }) } }) @@ -1029,6 +1029,7 @@ export class Client { document.querySelectorAll('.connect-btn-tn .lds-ellipsis').forEach((el) => { el.parentElement.innerHTML = this.config.uiOptions?.loadAction ?? 'Load Collection' }) + this.eventSender('user-cancel', { eventType: 'page-redirect' }) } }) .catch((err) => { diff --git a/src/client/interface.ts b/src/client/interface.ts index 3abf8f70..db6dd224 100644 --- a/src/client/interface.ts +++ b/src/client/interface.ts @@ -156,15 +156,21 @@ export interface TokenNegotiatorEventsArgs { 'opened-overlay': EventSenderOpenedOverlay 'closed-overlay': EventSenderClosedOverlay loaded: EventSenderViewLoaded - 'token-proof': any // EventSenderTokenProof // TODO: Update this + 'token-proof': any 'connected-wallet': EventSenderConnectedWallet 'disconnected-wallet': EventSenderDisconnectedWallet 'tokens-selected': EventSenderTokensSelected 'tokens-loaded': EventSenderTokensLoaded 'network-change': string + 'page-redirecting': PageRedirecting + 'user-cancel': { eventType: string } error: EventSenderError } +export interface PageRedirecting { + collectionId: string + tokenOrigin: string +} export interface EventSenderViewLoaded { data: any }