From 4af13d85df8ef996f7027d01b9dd6e5c99a6a8b4 Mon Sep 17 00:00:00 2001 From: Mark Wylde Date: Wed, 13 Mar 2024 07:51:42 +0000 Subject: [PATCH 1/2] chore: add trackjs --- docusaurus.config.js | 4 ++++ package-lock.json | 6 ++++++ package.json | 1 + src/theme/Root.tsx | 8 ++++++++ 4 files changed, 19 insertions(+) diff --git a/docusaurus.config.js b/docusaurus.config.js index d196c3424..763a13a78 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -18,6 +18,10 @@ const config = { projectName: 'deriv-api-docs', // Usually your repo name. trailingSlash: false, + customFields: { + trackJsToken: process.env.TRACKJS_TOKEN, + }, + // Even if you don't use internalization, you can use this field to set useful // metadata like html lang. For example, if your site is Chinese, you may want // to replace "en" with "zh-Hans". diff --git a/package-lock.json b/package-lock.json index 432a7b907..862e2498d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,6 +36,7 @@ "sass": "^1.57.1", "sass-loader": "^13.2.0", "swiper": "^8.3.2", + "trackjs": "^3.10.4", "ts-jest": "^29.0.3", "usehooks-ts": "^2.9.1", "yup": "^0.32.11" @@ -23323,6 +23324,11 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/trackjs": { + "version": "3.10.4", + "resolved": "https://registry.npmjs.org/trackjs/-/trackjs-3.10.4.tgz", + "integrity": "sha512-coQkj9d7OjPmrLKj4MeLvf1U5vPD9QfXMpqVghhKnF++BlFOkA9t64ry0Usqt+8dk1tunZ9DQ5IVKLYi+3H8+w==" + }, "node_modules/trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", diff --git a/package.json b/package.json index 41a507949..df1c3d8f6 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "sass": "^1.57.1", "sass-loader": "^13.2.0", "swiper": "^8.3.2", + "trackjs": "^3.10.4", "ts-jest": "^29.0.3", "usehooks-ts": "^2.9.1", "yup": "^0.32.11" diff --git a/src/theme/Root.tsx b/src/theme/Root.tsx index 181bc367c..2022cd3d2 100644 --- a/src/theme/Root.tsx +++ b/src/theme/Root.tsx @@ -1,6 +1,8 @@ import React from 'react'; import { ThemeProvider } from '@deriv/ui'; import type { ReactNode } from 'react'; +import { TrackJS } from 'trackjs'; +import siteConfig from '@generated/docusaurus.config'; import AuthProvider from '../contexts/auth/auth.provider'; import ApiTokenProvider from '../contexts/api-token/api-token.provider'; import AppManagerContextProvider from '../contexts/app-manager/app-manager.provider'; @@ -11,6 +13,12 @@ type TRootProps = { children: ReactNode; }; +if (siteConfig.customFields.trackJsToken) { + TrackJS.install({ token: siteConfig.customFields.trackJsToken }); +} else { + console.warn('trackjs is not installed due to a missing token'); +} + export default function Root({ children }: TRootProps) { return ( <> From a54fab940725653c60bdc48d2f1f9d635183d999 Mon Sep 17 00:00:00 2001 From: Mark Wylde <129744061+markwylde-deriv@users.noreply.github.com> Date: Fri, 15 Mar 2024 08:24:40 +0000 Subject: [PATCH 2/2] fix: convert to string Co-authored-by: Jim Daniels Wasswa <104334373+jim-deriv@users.noreply.github.com> --- src/theme/Root.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/theme/Root.tsx b/src/theme/Root.tsx index 2022cd3d2..b848eed08 100644 --- a/src/theme/Root.tsx +++ b/src/theme/Root.tsx @@ -14,7 +14,7 @@ type TRootProps = { }; if (siteConfig.customFields.trackJsToken) { - TrackJS.install({ token: siteConfig.customFields.trackJsToken }); + TrackJS.install({ token: siteConfig.customFields.trackJsToken.toString() }); } else { console.warn('trackjs is not installed due to a missing token'); }