@arcblock/ux 3.1.30 → 3.1.32

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.
@@ -0,0 +1,14 @@
1
+ export interface PayEvent {
2
+ action: 'paySuccess' | 'payFailed';
3
+ checkoutSessionMode: string;
4
+ success: boolean;
5
+ }
6
+
7
+ export interface PaySuccessEvent extends PayEvent {
8
+ success: true;
9
+ }
10
+
11
+ export interface PayFailedEvent extends PayEvent {
12
+ success: false;
13
+ errorMessage: string;
14
+ }
@@ -0,0 +1,20 @@
1
+ export interface SwitchPassportEvent {
2
+ action: 'switchPassportSuccess' | 'switchPassportFailed';
3
+ success: boolean;
4
+ }
5
+
6
+ export interface SwitchPassportSuccessEvent extends SwitchPassportEvent {
7
+ success: true;
8
+ /**
9
+ *
10
+ * @example guest -> admin
11
+ * @type {string}
12
+ * @memberof SwitchPassportEvent
13
+ */
14
+ change: string;
15
+ }
16
+
17
+ export interface SwitchPassportFailedEvent extends SwitchPassportEvent {
18
+ success: false;
19
+ errorMessage: string;
20
+ }
@@ -0,0 +1,3 @@
1
+ export const GA_LAST_LOGIN_METHOD = 'ga-last-login-method';
2
+ export const GA_LAST_ROLE = 'ga-last-role';
3
+ export const GA_LAST_SOURCE_PROVIDER = 'ga-last-source-provider';
@@ -0,0 +1 @@
1
+ export const googleAnalyticsMeasurementId: string = window.blocklet?.GA_MEASUREMENT_ID || '';
@@ -1,29 +1,26 @@
1
1
  import { useLocation } from 'react-router-dom';
2
2
  import { useMount, useDeepCompareEffect } from 'ahooks';
3
3
  import ReactGA from 'react-ga4';
4
+ import { googleAnalyticsMeasurementId } from './env';
4
5
 
6
+ if (googleAnalyticsMeasurementId) {
7
+ ReactGA.initialize(googleAnalyticsMeasurementId);
8
+ }
9
+
10
+ export { ReactGA };
5
11
  export default <P extends object>(WrappedComponent: React.ComponentType<P>) => {
6
- const trackingId = window.blocklet?.GA_MEASUREMENT_ID || '';
7
12
  const trackPage = (page: string, title = document.title) => {
8
- if (!process.env.NODE_ENV || process.env.NODE_ENV === 'development') {
9
- return;
10
- }
11
-
12
- if (trackingId) {
13
+ if (googleAnalyticsMeasurementId) {
13
14
  ReactGA.send({ hitType: 'pageview', page, title });
14
15
  }
15
16
  };
16
17
 
17
18
  const trackEvent = (category: string, action: string, label: string, value: number) => {
18
- if (trackingId) {
19
+ if (googleAnalyticsMeasurementId) {
19
20
  ReactGA.event({ category, action, label, value, transport: 'beacon' });
20
21
  }
21
22
  };
22
23
 
23
- if (trackingId) {
24
- ReactGA.initialize(trackingId);
25
- }
26
-
27
24
  // @ts-ignore
28
25
  window.trackPage = trackPage;
29
26
  // @ts-ignore