From cf8d900b77d78b14ca2f8419ed0a123bcc1c16fd Mon Sep 17 00:00:00 2001 From: DmitriVanGuard Date: Tue, 17 Jan 2023 12:12:33 +0300 Subject: [PATCH 1/2] Supporting oauth redirects. Handling successfull auth analytics --- config-overrides.js | 9 ++++++--- src/firstLogin.js | 17 +++++++++++++++++ src/pages/Login/LoginGoogleBtn.js | 7 ++----- src/pages/Login/LoginTwitterBtn.js | 7 ++----- src/withTracker.js | 5 +++++ 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/config-overrides.js b/config-overrides.js index a873337289..52e9df1676 100644 --- a/config-overrides.js +++ b/config-overrides.js @@ -72,12 +72,15 @@ module.exports = function override(config, env) { const dev = process.env.NODE_ENV === 'development' + const BACKEND_URL = dev + ? JSON.stringify(process.env.REACT_APP_BACKEND_URL) + : '`https://api${window.location.hostname.includes("stage") ? "-stage" : ""}.santiment.net`' + config.plugins.push( new webpack.DefinePlugin({ 'process.browser': true, - 'process.env.GQL_SERVER_URL': dev - ? JSON.stringify(process.env.REACT_APP_BACKEND_URL + '/graphql') - : '`https://api${window.location.hostname.includes("stage") ? "-stage" : ""}.santiment.net/graphql`', + 'process.env.BACKEND_URL': BACKEND_URL, + 'process.env.GQL_SERVER_URL': BACKEND_URL + '+ "/graphql"', 'process.env.IS_DEV_MODE': dev, 'process.env.MEDIA_PATH': JSON.stringify('/static'), 'process.env.ICONS_PATH': JSON.stringify('/static/icons'), diff --git a/src/firstLogin.js b/src/firstLogin.js index 17bcab9760..2e83792172 100644 --- a/src/firstLogin.js +++ b/src/firstLogin.js @@ -1,4 +1,7 @@ import { query } from 'webkit/api' +import { parseAuthSearchParams } from 'webkit/utils/auth' +import { trackLoginFinish } from 'webkit/analytics/events/general' +import { trackSignupFinish } from 'webkit/analytics/events/onboarding' query(`{ currentUser { @@ -6,4 +9,18 @@ query(`{ } }`).then(({ currentUser }) => { window.isFirstLogin = Boolean(currentUser && currentUser.firstLogin) + + const { auth } = parseAuthSearchParams() + + if (auth) { + if (window.isFirstLogin) { + window.onGdprAccept = () => { + trackSignupFinish(auth) + } + } else { + trackLoginFinish(auth) + } + + window.history.replaceState(window.history.state, null, window.location.pathname) + } }) diff --git a/src/pages/Login/LoginGoogleBtn.js b/src/pages/Login/LoginGoogleBtn.js index 593f92152f..240367e92d 100644 --- a/src/pages/Login/LoginGoogleBtn.js +++ b/src/pages/Login/LoginGoogleBtn.js @@ -1,13 +1,10 @@ import React from 'react' import cx from 'classnames' +import { getOAuthLink } from 'webkit/utils/auth' import { trackLoginStart, LoginType } from 'webkit/analytics/events/general' import { trackSignupStart } from 'webkit/analytics/events/onboarding' import styles from './index.module.scss' -const AUTH_LINK = (process.env.REACT_APP_BACKEND_URL || window.location.hostname).includes('stage') - ? 'https://api-stage.santiment.net/auth/google' - : 'https://api.santiment.net/auth/google' - const GOOGLE_ICON = ( { return ( diff --git a/src/pages/Login/LoginTwitterBtn.js b/src/pages/Login/LoginTwitterBtn.js index afa5137bfc..2e482476d3 100644 --- a/src/pages/Login/LoginTwitterBtn.js +++ b/src/pages/Login/LoginTwitterBtn.js @@ -1,14 +1,11 @@ import React from 'react' import cx from 'classnames' import Icon from '@santiment-network/ui/Icon' +import { getOAuthLink } from 'webkit/utils/auth' import { trackLoginStart, LoginType } from 'webkit/analytics/events/general' import { trackSignupStart } from 'webkit/analytics/events/onboarding' import styles from './index.module.scss' -const AUTH_LINK = (process.env.REACT_APP_BACKEND_URL || window.location.hostname).includes('stage') - ? 'https://api-stage.santiment.net/auth/twitter' - : 'https://api.santiment.net/auth/twitter' - const LogitTwitterBtn = ({ signUp, className }) => { function onClick() { if (signUp) { @@ -20,7 +17,7 @@ const LogitTwitterBtn = ({ signUp, className }) => { return ( diff --git a/src/withTracker.js b/src/withTracker.js index c3fd78a1f5..7188054ade 100644 --- a/src/withTracker.js +++ b/src/withTracker.js @@ -23,6 +23,11 @@ const withTracker = (WrappedComponent) => { componentDidMount() { const page = this.props.location.pathname trackPage(page) + + trackPageView({ + url: page, + type: getPageType(page), + }) } componentWillReceiveProps(nextProps) { From 31d8d47dd4b6c6c0dd51292cfd65fc85b02f6e40 Mon Sep 17 00:00:00 2001 From: DmitriVanGuard Date: Tue, 17 Jan 2023 12:18:24 +0300 Subject: [PATCH 2/2] webkit updated --- package-lock.json | 50 +++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 +- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c003eb33ac..16e6005614 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28704,6 +28704,11 @@ "turndown": "^7.1.1" }, "dependencies": { + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==" + }, "dom-serializer": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", @@ -28762,6 +28767,26 @@ "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" }, + "fast-glob": { + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, "htmlparser2": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", @@ -28775,6 +28800,19 @@ "readable-stream": "^3.1.1" } }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, "medium-draft": { "version": "0.5.17", "resolved": "https://registry.npmjs.org/medium-draft/-/medium-draft-0.5.17.tgz", @@ -28817,6 +28855,14 @@ "util-deprecate": "^1.0.1" } }, + "san-webkit": { + "version": "git+https://github.com/santiment/san-webkit.git#917dee46d3c31346c85e6d9540f76d530bbdc69f", + "from": "git+https://github.com/santiment/san-webkit.git#917dee4", + "requires": { + "fast-glob": "^3.2.5", + "patch-package": "^6.4.7" + } + }, "sanitize-html": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-1.20.1.tgz", @@ -29057,8 +29103,8 @@ "from": "git+https://github.com/santiment/san-studio.git#d1c72d9" }, "san-webkit": { - "version": "git+https://github.com/santiment/san-webkit.git#917dee46d3c31346c85e6d9540f76d530bbdc69f", - "from": "git+https://github.com/santiment/san-webkit.git#917dee4", + "version": "git+https://github.com/santiment/san-webkit.git#eb47bbeb253cc47ce7ccf98a333e88509a33d435", + "from": "git+https://github.com/santiment/san-webkit.git#eb47bbe", "requires": { "fast-glob": "^3.2.5", "patch-package": "^6.4.7" diff --git a/package.json b/package.json index e6aff540ed..1e1e2fe55d 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "rxjs": "5.x.x", "san-insights": "https://github.com/santiment/insights-app#0aebf0e", "san-studio": "https://github.com/santiment/san-studio#d1c72d9", - "san-webkit": "https://github.com/santiment/san-webkit#917dee4", + "san-webkit": "https://github.com/santiment/san-webkit#eb47bbe", "san-queries": "https://github.com/santiment/san-queries#4235111", "sanitize-html": "^1.18.2", "svg-sprite": "1.5.0",