Skip to content

Commit

Permalink
fix(txn): txnHash in submitTxn (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalMir135 authored May 10, 2023
1 parent 9f28bee commit 592d28f
Showing 4 changed files with 17 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -135,3 +135,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Events flow in session.
- Geolocation tracking on intial events.

## [1.0.0-beta.4] - 2023-05-10

### Fixed

- Add txn hash on txn-submit tracking.
- Expire session on wallet or chain change.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "analytics-web3",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "Spock analytics SDK analytics-web3 is a js module to collect and log all the data and events of DApp for analytics.",
"main": "dist/analytics-web3.min.js",
"license": "UNLICENSED",
13 changes: 7 additions & 6 deletions src/Session/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LOG, TRACKING_EVENTS, STORAGE } from '../constants';
import { LOG, TRACKING_EVENTS, STORAGE, EVENTS } from '../constants';
import BaseAnalytics from '../BaseAnalytics';
import { limitedTimeout, sessionUUID } from './utils';
import { getCookie } from '../utils/cookies';
import { deleteCookie, getCookie } from '../utils/cookies';
import { JSON_Formatter } from '../utils/formatting';
import { addEvent, currentTimestamp } from '../utils/helpers';
import { notUndefined } from '../utils/validators';
@@ -28,10 +28,10 @@ class Session extends BaseAnalytics {
addEvent(window, 'beforeunload', this.pauseSession.bind(this));

//TODO should we expire on new wallet connect
// addEvent(window, EVENTS.WALLET_CONNECTION, () => {
// this.endSession();
// this.beginSession();
// });
addEvent(window, EVENTS.WALLET_CONNECTION, () => {
this.endSession();
this.beginSession();
});

this.visibilityEvents();

@@ -79,6 +79,7 @@ class Session extends BaseAnalytics {
this.dispatch({ sessionId, txnReject, txnSubmit, flow: [...flow, ...this.store.flow] });
this.storedDuration = duration;
this.request.post(`track/${TRACKING_EVENTS.REWIND_SESSION}`, { data: { sessionId } });
deleteCookie(STORAGE.COOKIES.SESSION);
}

pauseSession() {
4 changes: 2 additions & 2 deletions src/WalletConnection/index.js
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ class WalletConnection extends BaseAnalytics {
this.trackEvent({ event: TRACKING_EVENTS.TRANSACTION, properties, logMessage: 'Transaction rejected' });
this.dispatch({ txnReject: this.store.txnReject + 1 });
} else if (status === 'submitted' && this.cacheTxnHash !== txnHash) {
const properties = { ...txnObj, status: 1 };
const properties = { ...txnObj, hash: txnHash, status: 1 };
this.trackEvent({ event: TRACKING_EVENTS.TRANSACTION, properties, logMessage: 'Transaction submitted' });
this.cacheTxnHash = txnHash;
this.dispatch({ txnSubmit: this.store.txnSubmit + 1 });
@@ -181,7 +181,7 @@ class WalletConnection extends BaseAnalytics {
}
}

if (provider.isMetaMask) return WALLET_TYPE.METAMASK;
if (provider.isMetaMask || provider.connection?.url === 'metamask') return WALLET_TYPE.METAMASK;
else if (provider.isWalletConnect) return WALLET_TYPE.WALLETCONNECT;
else if (provider.isCoinbaseWallet) return WALLET_TYPE.COINBASE;
else if (provider.isFortmatic) return WALLET_TYPE.FORTMATIC;

0 comments on commit 592d28f

Please sign in to comment.