@formo/analytics 1.13.3-alpha.3 → 1.13.3-alpha.4
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/dist/cjs/src/FormoAnalytics.d.ts +2 -2
- package/dist/cjs/src/FormoAnalytics.d.ts.map +1 -1
- package/dist/cjs/src/FormoAnalytics.js +4 -8
- package/dist/cjs/src/FormoAnalytics.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/src/FormoAnalytics.d.ts +2 -2
- package/dist/esm/src/FormoAnalytics.d.ts.map +1 -1
- package/dist/esm/src/FormoAnalytics.js +4 -8
- package/dist/esm/src/FormoAnalytics.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/FormoAnalytics.ts +5 -11
package/package.json
CHANGED
package/src/FormoAnalytics.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
-
import { createStore, EIP6963ProviderDetail
|
|
2
|
+
import { createStore, EIP6963ProviderDetail } from "mipd";
|
|
3
3
|
import {
|
|
4
4
|
COUNTRY_LIST,
|
|
5
5
|
CURRENT_URL_KEY,
|
|
@@ -22,7 +22,6 @@ import { toSnakeCase } from "./lib/utils";
|
|
|
22
22
|
|
|
23
23
|
interface IFormoAnalytics {
|
|
24
24
|
page(): void;
|
|
25
|
-
// trackPagesChange(): void;
|
|
26
25
|
connect(params: { chainId: ChainID; address: Address }): Promise<void>;
|
|
27
26
|
disconnect(params?: { chainId?: ChainID; address?: Address }): Promise<void>;
|
|
28
27
|
chain(params: { chainId: ChainID; address?: Address }): Promise<void>;
|
|
@@ -82,8 +81,8 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
82
81
|
this.trackProvider(provider);
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
84
|
+
this.trackFirstPageHit();
|
|
85
|
+
this.trackPageHits();
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
static async init(
|
|
@@ -535,7 +534,7 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
535
534
|
}
|
|
536
535
|
}
|
|
537
536
|
|
|
538
|
-
private async
|
|
537
|
+
private async trackFirstPageHit(): Promise<void> {
|
|
539
538
|
if (sessionStorage.getItem(CURRENT_URL_KEY) === null) {
|
|
540
539
|
sessionStorage.setItem(CURRENT_URL_KEY, window.location.href);
|
|
541
540
|
}
|
|
@@ -543,7 +542,7 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
543
542
|
return this.trackPageHit();
|
|
544
543
|
}
|
|
545
544
|
|
|
546
|
-
private async
|
|
545
|
+
private async trackPageHits(): Promise<void> {
|
|
547
546
|
const oldPushState = history.pushState;
|
|
548
547
|
history.pushState = function pushState(...args) {
|
|
549
548
|
const ret = oldPushState.apply(this, args);
|
|
@@ -559,7 +558,6 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
559
558
|
};
|
|
560
559
|
|
|
561
560
|
window.addEventListener("popstate", () => this.onLocationChange());
|
|
562
|
-
|
|
563
561
|
window.addEventListener("locationchange", () => this.onLocationChange());
|
|
564
562
|
}
|
|
565
563
|
|
|
@@ -572,8 +570,6 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
572
570
|
}
|
|
573
571
|
}
|
|
574
572
|
|
|
575
|
-
// TODO: Add event listener and support for SPA and hash-based navigation
|
|
576
|
-
// https://linear.app/getformo/issue/P-800/sdk-support-spa-and-hash-based-routing
|
|
577
573
|
private trackPageHit(): void {
|
|
578
574
|
const pathname = window.location.pathname;
|
|
579
575
|
const href = window.location.href;
|
|
@@ -681,8 +677,6 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
681
677
|
const accounts = await this.getAccounts();
|
|
682
678
|
if (accounts && accounts.length > 0) {
|
|
683
679
|
return accounts[0];
|
|
684
|
-
// TODO: how to handle multiple addresses? Should we emit a connect event here? Since the user has not manually connected
|
|
685
|
-
// https://linear.app/getformo/issue/P-691/sdk-detect-multiple-wallets-using-eip6963
|
|
686
680
|
}
|
|
687
681
|
} catch (err) {
|
|
688
682
|
console.log("Failed to fetch accounts from provider:", err);
|