Skip to content

Commit

Permalink
Merge pull request #130 from adrienne-deriv/setup-hydra-autgh
Browse files Browse the repository at this point in the history
Integrate auth-client for Hydra logout functionality
  • Loading branch information
sandeep-deriv authored Oct 7, 2024
2 parents e84abbe + 96bbc45 commit 65085fa
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 18 deletions.
4 changes: 0 additions & 4 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ inputs:
GROWTHBOOK_CLIENT_KEY:
description: Growthbook client key for analytics
required: false
GROWTHBOOK_DECRYPTION_KEY:
description: Growthbook decryption key for analytics
required: false
runs:
using: composite
steps:
Expand All @@ -26,6 +23,5 @@ runs:
TRACKJS_TOKEN: ${{ inputs.TRACKJS_TOKEN }}
RUDDERSTACK_KEY: ${{ inputs.RUDDERSTACK_KEY }}
GROWTHBOOK_CLIENT_KEY: ${{ inputs.GROWTHBOOK_CLIENT_KEY }}
GROWTHBOOK_DECRYPTION_KEY: ${{ inputs.GROWTHBOOK_DECRYPTION_KEY }}
run: npm run build
shell: bash
1 change: 0 additions & 1 deletion .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
NODE_ENV: production
TRACKJS_TOKEN: ${{ secrets.TRACKJS_TOKEN }}
RUDDERSTACK_KEY: ${{ vars.RUDDERSTACK_KEY }}
GROWTHBOOK_DECRYPTION_KEY: ${{ secrets.GROWTHBOOK_DECRYPTION_KEY }}
GROWTHBOOK_CLIENT_KEY: ${{ vars.GROWTHBOOK_CLIENT_KEY }}
- name: Versioning
uses: ./.github/actions/versioning
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
with:
NODE_ENV: staging
RUDDERSTACK_KEY: ${{ vars.RUDDERSTACK_KEY }}
GROWTHBOOK_DECRYPTION_KEY: ${{ secrets.GROWTHBOOK_DECRYPTION_KEY }}
GROWTHBOOK_CLIENT_KEY: ${{ vars.GROWTHBOOK_CLIENT_KEY }}
- name: Versioning
uses: ./.github/actions/versioning
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
NODE_ENV: staging
TRACKJS_TOKEN: ${{ secrets.TRACKJS_TOKEN }}
RUDDERSTACK_KEY: ${{ vars.RUDDERSTACK_KEY }}
GROWTHBOOK_DECRYPTION_KEY: ${{ secrets.GROWTHBOOK_DECRYPTION_KEY }}
GROWTHBOOK_CLIENT_KEY: ${{ vars.GROWTHBOOK_CLIENT_KEY }}
- name: Versioning
uses: ./.github/actions/versioning
Expand Down
1 change: 0 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const config = {
customFields: {
trackJsToken: process.env.TRACKJS_TOKEN,
rudderstackKey: process.env.RUDDERSTACK_KEY,
growthbookDecryptionKey: process.env.GROWTHBOOK_DECRYPTION_KEY,
growthbookClientKey: process.env.GROWTHBOOK_CLIENT_KEY,
},

Expand Down
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ module.exports = {
],
'^.+\\.mjs$': 'babel-jest',
},
transformIgnorePatterns: ['node_modules/(?!(@docusaurus|swiper|ssr-window|dom7)|@theme)'],
transformIgnorePatterns: [
'node_modules/(?!(@docusaurus|swiper|ssr-window|dom7)|@theme|@deriv-com/auth-client)',
],
moduleNameMapper: {
'@theme/(.*)': '@docusaurus/theme-classic/src/theme/$1',

Expand Down
23 changes: 19 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,md,json}' --config ./.prettierrc"
},
"dependencies": {
"@deriv-com/analytics": "^1.18.0",
"@deriv-com/analytics": "^1.22.1",
"@deriv-com/auth-client": "^1.0.27",
"@deriv/deriv-api": "^1.0.11",
"@deriv/quill-icons": "^1.22.10",
"@deriv/ui": "^0.8.0",
Expand Down
10 changes: 9 additions & 1 deletion src/components/AccountSwitcher/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useState, useRef } from 'react';
import { useOAuth2, TOAuth2EnabledAppList } from '@deriv-com/auth-client';
import { isNotDemoCurrency } from '@site/src/utils';
import useLogout from '@site/src/hooks/useLogout';
import useGrowthbookGetFeatureValue from '@site/src/hooks/useGrowthbookGetFeatureValue';
import useAuthContext from '@site/src/hooks/useAuthContext';
import useOnClickOutside from '@site/src/hooks/useOnClickOutside';
import CurrencyIcon from '../CurrencyIcon';
Expand All @@ -11,7 +13,13 @@ import SearchButton from '../SearchButton';
import Translate from '@docusaurus/Translate';

const AccountSwitcher = () => {
const [OAuth2EnabledApps, OAuth2EnabledAppsInitialised] =
useGrowthbookGetFeatureValue<TOAuth2EnabledAppList>({
featureFlag: 'hydra_be',
});

const { logout } = useLogout();
const { OAuth2Logout } = useOAuth2({ OAuth2EnabledApps, OAuth2EnabledAppsInitialised }, logout);

const { currentLoginAccount } = useAuthContext();
const [is_toggle_dropdown, setToggleDropdown] = useState(false);
Expand Down Expand Up @@ -57,7 +65,7 @@ const AccountSwitcher = () => {
</div>
<div className={styles.logoutButtonContainer}>
<button
onClick={logout}
onClick={OAuth2Logout}
type='button'
color={'tertiary'}
className={styles.logoutButton}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useGrowthbookGetFeatureValue/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { Analytics } from '@deriv-com/analytics';
import useIsGrowthbookIsLoaded from './useIsGrowthbookLoaded';
import useIsGrowthbookIsLoaded from '../useIsGrowthbookLoaded';

type featureValueTypes = Record<string, boolean> | boolean | string | [];

Expand Down
3 changes: 1 addition & 2 deletions src/theme/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ if (trackJsToken) {
console.warn('trackjs is not installed due to a missing token');
}

if (rudderstackKey && growthbookClientKey && growthbookDecryptionKey) {
if (rudderstackKey && growthbookClientKey) {
Analytics?.initialise({
growthbookKey: siteConfig.customFields.growthbookClientKey.toString(),
growthbookDecryptionKey: siteConfig.customFields.growthbookDecryptionKey.toString(),
rudderstackKey: siteConfig.customFields.rudderstackKey.toString(),
});
} else {
Expand Down

0 comments on commit 65085fa

Please sign in to comment.