diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index e0accc553..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,40 +0,0 @@ -version: 2.1 -workflows: - commit: - jobs: - - build -orbs: - browser-tools: circleci/browser-tools@1.4.8 - -jobs: - build: - resource_class: large - docker: - - image: "cimg/node:18.20.3-browsers" - steps: - - checkout - - browser-tools/install-chrome - - restore_cache: - keys: - - npm-cache-{{ checksum "package-lock.json" }} - # fallback to a previous cache if package-lock.json hasn't changed - - npm-cache- - - run: - name: install - command: npm ci - - save_cache: - paths: - - ~/.npm - key: npm-cache-{{ checksum "package-lock.json" }} - - run: - name: lint - command: npm run lint - - run: - name: test - command: npm run test - - run: - name: type check - command: npm run type-check - - run: - name: build and run integration - command: ./scripts/integration-headless.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..fe0bcc36e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI - Lint and Test + +on: + push: + branches: [develop, master] + pull_request: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +env: + NODE_VERSION: "18" + +jobs: + lint-and-test: + name: Lint & Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "npm" + + - name: Install dependencies + run: npm ci + + - name: Type check + run: npm run type-check --if-present + + - name: Lint + run: npm run lint + + - name: Unit tests + run: npm test -- --ci diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml new file mode 100644 index 000000000..1e80ccd23 --- /dev/null +++ b/.github/workflows/deploy-dev.yml @@ -0,0 +1,111 @@ +name: Deploy to Dev Environment + +on: + push: + branches: [develop] + +concurrency: + group: deploy-dev-${{ github.ref }} + cancel-in-progress: true + +env: + NODE_VERSION: "18" + BUILD_DIR: "out" + +jobs: + wait-for-ci: + name: Wait for CI + runs-on: ubuntu-latest + steps: + - name: Wait for CI workflow + uses: lewagon/wait-on-check-action@v1.3.4 + with: + ref: ${{ github.ref }} + check-name: 'Lint & Test' + repo-token: ${{ secrets.GITHUB_TOKEN }} + + build-dev: + name: Build (Dev) + runs-on: ubuntu-latest + needs: wait-for-ci + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "npm" + + - name: Install dependencies + run: npm ci + + - name: Build static site + run: | + npm run build + npm run postexport + env: + # Build-time envs used in next.config.js + NET: 'sepolia' + INFURA_API_KEY: ${{ secrets.DEV_INFURA_API_KEY }} + ALCHEMY_API_KEY: ${{ secrets.DEV_ALCHEMY_API_KEY }} + GA4_TAG_ID: ${{ secrets.GA4_TAG_ID }} + TRUSTED_TLDS: ${{ secrets.TRUSTED_TLDS }} + + - name: Upload build artifact (Dev) + uses: actions/upload-artifact@v4 + with: + name: static-site-dev + path: ${{ env.BUILD_DIR }} + + deploy-dev: + name: Deploy to S3 (Dev) + needs: build-dev + runs-on: ubuntu-latest + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: static-site-dev + path: ${{ env.BUILD_DIR }} + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Select target bucket + id: bucket + run: | + echo "bucket=${S3_BUCKET_DEV}" >> $GITHUB_OUTPUT + env: + S3_BUCKET_DEV: ${{ secrets.S3_BUCKET_DEV }} + + - name: Sync static assets with long cache + run: | + aws s3 sync $BUILD_DIR s3://${{ steps.bucket.outputs.bucket }} \ + --delete \ + --exclude "*" \ + --include "_next/*" \ + --include "static/*" \ + --cache-control "public, max-age=31536000, immutable" + + - name: Sync HTML and other assets with no-cache + run: | + aws s3 sync $BUILD_DIR s3://${{ steps.bucket.outputs.bucket }} \ + --delete \ + --exclude "_next/*" \ + --exclude "static/*" \ + --cache-control "no-cache, no-store, must-revalidate" + + - name: Invalidate CloudFront + env: + CLOUDFRONT_DISTRIBUTION_ID_DEV: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_DEV }} + if: ${{ env.CLOUDFRONT_DISTRIBUTION_ID_DEV != '' }} + run: | + aws cloudfront create-invalidation \ + --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_DEV }} \ + --paths "/*" diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml new file mode 100644 index 000000000..e22c114aa --- /dev/null +++ b/.github/workflows/deploy-prod.yml @@ -0,0 +1,110 @@ +name: Deploy to Production Environment + +on: + workflow_dispatch: + +concurrency: + group: deploy-prod-${{ github.ref }} + cancel-in-progress: true + +env: + NODE_VERSION: "18" + BUILD_DIR: "out" + +jobs: + wait-for-ci: + name: Wait for CI + runs-on: ubuntu-latest + steps: + - name: Wait for CI workflow + uses: lewagon/wait-on-check-action@v1.3.4 + with: + ref: ${{ github.ref }} + check-name: 'Lint & Test' + repo-token: ${{ secrets.GITHUB_TOKEN }} + + build-prod: + name: Build (Prod) + runs-on: ubuntu-latest + needs: wait-for-ci + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "npm" + + - name: Install dependencies + run: npm ci + + - name: Build static site + run: | + npm run build + npm run postexport + env: + # Build-time envs used in next.config.js + NET: 'mainnet' + INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} + GA4_TAG_ID: ${{ secrets.GA4_TAG_ID }} + TRUSTED_TLDS: ${{ secrets.TRUSTED_TLDS }} + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: static-site-prod + path: ${{ env.BUILD_DIR }} + + deploy-prod: + name: Deploy to S3 (Prod) + needs: build-prod + runs-on: ubuntu-latest + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: static-site-prod + path: ${{ env.BUILD_DIR }} + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Select target bucket + id: bucket + run: | + echo "bucket=${S3_BUCKET_PROD}" >> $GITHUB_OUTPUT + env: + S3_BUCKET_PROD: ${{ secrets.S3_BUCKET_PROD }} + + - name: Sync static assets with long cache + run: | + aws s3 sync $BUILD_DIR s3://${{ steps.bucket.outputs.bucket }} \ + --delete \ + --exclude "*" \ + --include "_next/*" \ + --include "static/*" \ + --cache-control "public, max-age=31536000, immutable" + + - name: Sync HTML and other assets with no-cache + run: | + aws s3 sync $BUILD_DIR s3://${{ steps.bucket.outputs.bucket }} \ + --delete \ + --exclude "_next/*" \ + --exclude "static/*" \ + --cache-control "no-cache, no-store, must-revalidate" + + - name: Invalidate CloudFront + env: + CLOUDFRONT_DISTRIBUTION_ID_PROD: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_PROD }} + if: ${{ env.CLOUDFRONT_DISTRIBUTION_ID_PROD != '' }} + run: | + aws cloudfront create-invalidation \ + --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_PROD }} \ + --paths "/*" diff --git a/.nvmrc b/.nvmrc index 5f09eed8d..3f430af82 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v18.20.3 +v18 diff --git a/README.md b/README.md index a9928a566..8f45c2587 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ # Certificate Web UI -[![CircleCI](https://circleci.com/gh/OpenCerts/opencerts-website.svg?style=svg)](https://circleci.com/gh/OpenCerts/opencerts-website) +[![CI](https://github.com/OpenCerts/opencerts-website/actions/workflows/ci.yml/badge.svg)](https://github.com/OpenCerts/opencerts-website/actions/workflows/ci.yml) +[![Deploy Dev](https://github.com/OpenCerts/opencerts-website/actions/workflows/deploy-dev.yml/badge.svg)](https://github.com/OpenCerts/opencerts-website/actions/workflows/deploy-dev.yml) +[![Deploy Prod](https://github.com/OpenCerts/opencerts-website/actions/workflows/deploy-prod.yml/badge.svg)](https://github.com/OpenCerts/opencerts-website/actions/workflows/deploy-prod.yml) ## Notice +From 1 Oct 2025, the Infocomm Media Development Authority (IMDA) will take over the maintenance of OpenCerts. For enquiries, reach out to https://trustvc.io + +--- + As of 31 December 2019, we have migrated from OpenCerts `v1` to `v2`. As part of the migration, do note that `certificateStore` has been renamed to `documentStore`, please refer to the [`public/static/demo/sepolia.opencert`](https://github.com/OpenCerts/opencerts-website/blob/master/public/static/demo/sepolia.opencert) for the latest implementation or refer to the snippet below for more information about the "issuers" section of the document. @@ -95,3 +101,9 @@ Try running `npm rebuild` ### Integration tests To run integration tests locally, make sure you run `npm run build` once to build the static site first. The e2e tests will then spin up a server based on the `out` folder in project root. + +### Deployment + +develop branch is deployed to https://dev.opencerts.io -> for development and testing purposes only. + +master branch is deployed to https://opencerts.io -> for production use. diff --git a/next-env.d.ts b/next-env.d.ts index 4f11a03dc..a4a7b3f5c 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information. diff --git a/next.config.js b/next.config.js index 6373afbfe..f1e47ec7f 100644 --- a/next.config.js +++ b/next.config.js @@ -22,7 +22,6 @@ const nextConfig = { ALCHEMY_API_KEY: process.env.ALCHEMY_API_KEY, // The default/free key should not be used in production as they are rate-limited by the service provider TRUSTED_TLDS: process.env.TRUSTED_TLDS || "gov.sg,edu.sg", GA4_TAG_ID: process.env.GA4_TAG_ID || "G-JP12T2F01V", - WOGAA_ENV: process.env.WOGAA_ENV || "production", }, // Variables passed to both server and client publicRuntimeConfig: { diff --git a/package-lock.json b/package-lock.json index 064188d40..93ce24ff8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,9 +13,9 @@ "@govtechsg/oa-encryption": "^1.3.5", "@govtechsg/oa-verify": "^9.3.0-beta.4", "@govtechsg/open-attestation": "^6.10.0-beta.6", - "@govtechsg/opencerts-verify": "^3.1.3", "@next/bundle-analyzer": "^14.2.5", "@reduxjs/toolkit": "^2.2.7", + "@trustvc/opencerts-verify": "^3.1.4", "@types/google.analytics": "0.0.41", "@types/react-google-recaptcha": "^2.1.0", "clipboard-copy": "^4.0.1", @@ -3434,83 +3434,6 @@ "zod": "^3.22.4" } }, - "node_modules/@govtechsg/opencerts-verify": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/@govtechsg/opencerts-verify/-/opencerts-verify-3.1.3.tgz", - "integrity": "sha512-4vhhxGI2QOgfEAcTtKpL/zxsbqFyDe+B288hv/iV6U6Kve0uem39tfiMcHM0+b5AwvVZVHbb2FnyhmHA1kL33A==", - "dependencies": { - "@govtechsg/oa-verify": "^8.1.0", - "@govtechsg/open-attestation": "^6.5.1", - "debug": "^4.3.1", - "node-fetch": "^2.6.1", - "runtypes": "^6.3.0" - } - }, - "node_modules/@govtechsg/opencerts-verify/node_modules/@govtechsg/oa-verify": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/@govtechsg/oa-verify/-/oa-verify-8.2.3.tgz", - "integrity": "sha512-rrGqoF0xWoXapmTyrrSpneZgWwLCohG0JMovWpkyPmHQO0AfCqHDMVqsGSi6PywxqIZfDdPSMG43qYe1WWaVPg==", - "dependencies": { - "@govtechsg/dnsprove": "^2.6.2", - "@govtechsg/document-store": "^2.2.3", - "@govtechsg/open-attestation": "^6.2.0", - "@govtechsg/token-registry": "^4.1.7", - "axios": "^1.6.0", - "debug": "^4.3.1", - "did-resolver": "^3.1.0", - "ethers": "^5.1.4", - "ethr-did-resolver": "^4.3.3", - "node-cache": "^5.1.2", - "runtypes": "^6.3.0", - "web-did-resolver": "^2.0.4" - } - }, - "node_modules/@govtechsg/opencerts-verify/node_modules/@govtechsg/open-attestation": { - "version": "6.9.5", - "resolved": "https://registry.npmjs.org/@govtechsg/open-attestation/-/open-attestation-6.9.5.tgz", - "integrity": "sha512-idORp5t8RcV/Fz3BCl67zAX7DcuJWlwn7Wt4NsIIWWdD1K8qSsUmeLfqfTcGHqbplwQPZ2eUFIqX9mTAd9m3NA==", - "hasInstallScript": true, - "dependencies": { - "@ethersproject/abstract-signer": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "@ethersproject/wallet": "^5.7.0", - "@govtechsg/jsonld": "^0.1.0", - "ajv-formats": "^2.1.1", - "cross-fetch": "^3.1.5", - "debug": "^4.3.2", - "flatley": "^5.2.0", - "js-base64": "^3.6.1", - "js-sha3": "^0.8.0", - "lodash": "^4.17.21", - "runtypes": "^6.3.2", - "uuid": "^8.3.2", - "validator": "^13.7.0" - } - }, - "node_modules/@govtechsg/opencerts-verify/node_modules/did-resolver": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-3.2.2.tgz", - "integrity": "sha512-Eeo2F524VM5N3W4GwglZrnul2y6TLTwMQP3In62JdG34NZoqihYyOZLk+5wUW8sSgvIYIcJM8Dlt3xsdKZZ3tg==" - }, - "node_modules/@govtechsg/opencerts-verify/node_modules/ethr-did-resolver": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/ethr-did-resolver/-/ethr-did-resolver-4.3.5.tgz", - "integrity": "sha512-BQO7PQwuqqczK+4AWQhys/sgegDVIFr6+lSoSYXlIbG0oRH0l7PkSuf7VEFKclEJ3JlJ1t9kjDIdj7Ba7euTJg==", - "dependencies": { - "@ethersproject/abi": "^5.1.0", - "@ethersproject/abstract-signer": "^5.1.0", - "@ethersproject/address": "^5.1.0", - "@ethersproject/basex": "^5.1.0", - "@ethersproject/bignumber": "^5.1.0", - "@ethersproject/contracts": "^5.1.0", - "@ethersproject/providers": "^5.1.0", - "@ethersproject/transactions": "^5.1.0", - "did-resolver": "^3.1.0", - "ethr-did-registry": "^0.0.3", - "querystring": "^0.2.1" - } - }, "node_modules/@govtechsg/token-registry": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@govtechsg/token-registry/-/token-registry-4.4.0.tgz", @@ -5186,6 +5109,82 @@ "node": ">= 6" } }, + "node_modules/@trustvc/opencerts-verify": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@trustvc/opencerts-verify/-/opencerts-verify-3.1.4.tgz", + "integrity": "sha512-wJdgRC04AzK8vJcLYYjlnYwnr/X/Xgk8iVNcxNfMT0DWxtZSxgbnYhi665YwsZuXqYejIMU0d75pOWOmixDEgg==", + "dependencies": { + "@govtechsg/oa-verify": "^8.1.0", + "@govtechsg/open-attestation": "^6.5.1", + "debug": "^4.3.1", + "node-fetch": "^2.6.1", + "runtypes": "^6.3.0" + } + }, + "node_modules/@trustvc/opencerts-verify/node_modules/@govtechsg/oa-verify": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/@govtechsg/oa-verify/-/oa-verify-8.2.3.tgz", + "integrity": "sha512-rrGqoF0xWoXapmTyrrSpneZgWwLCohG0JMovWpkyPmHQO0AfCqHDMVqsGSi6PywxqIZfDdPSMG43qYe1WWaVPg==", + "dependencies": { + "@govtechsg/dnsprove": "^2.6.2", + "@govtechsg/document-store": "^2.2.3", + "@govtechsg/open-attestation": "^6.2.0", + "@govtechsg/token-registry": "^4.1.7", + "axios": "^1.6.0", + "debug": "^4.3.1", + "did-resolver": "^3.1.0", + "ethers": "^5.1.4", + "ethr-did-resolver": "^4.3.3", + "node-cache": "^5.1.2", + "runtypes": "^6.3.0", + "web-did-resolver": "^2.0.4" + } + }, + "node_modules/@trustvc/opencerts-verify/node_modules/@govtechsg/open-attestation": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@govtechsg/open-attestation/-/open-attestation-6.9.7.tgz", + "integrity": "sha512-2j1fPQK+udqLRaX9lFFPK7QeNxEKFcMwHUdnuiuMAJwKzHH3u9KkSNfbRl8J5mKHU+vHujNnUDBcuEyNXcg4hg==", + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/wallet": "^5.7.0", + "@govtechsg/jsonld": "^0.1.0", + "ajv-formats": "^2.1.1", + "cross-fetch": "^3.1.5", + "debug": "^4.3.2", + "flatley": "^5.2.0", + "js-base64": "^3.6.1", + "js-sha3": "^0.8.0", + "lodash": "^4.17.21", + "runtypes": "^6.3.2", + "uuid": "^8.3.2", + "validator": "^13.7.0" + } + }, + "node_modules/@trustvc/opencerts-verify/node_modules/did-resolver": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-3.2.2.tgz", + "integrity": "sha512-Eeo2F524VM5N3W4GwglZrnul2y6TLTwMQP3In62JdG34NZoqihYyOZLk+5wUW8sSgvIYIcJM8Dlt3xsdKZZ3tg==" + }, + "node_modules/@trustvc/opencerts-verify/node_modules/ethr-did-resolver": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/ethr-did-resolver/-/ethr-did-resolver-4.3.5.tgz", + "integrity": "sha512-BQO7PQwuqqczK+4AWQhys/sgegDVIFr6+lSoSYXlIbG0oRH0l7PkSuf7VEFKclEJ3JlJ1t9kjDIdj7Ba7euTJg==", + "dependencies": { + "@ethersproject/abi": "^5.1.0", + "@ethersproject/abstract-signer": "^5.1.0", + "@ethersproject/address": "^5.1.0", + "@ethersproject/basex": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/contracts": "^5.1.0", + "@ethersproject/providers": "^5.1.0", + "@ethersproject/transactions": "^5.1.0", + "did-resolver": "^3.1.0", + "ethr-did-registry": "^0.0.3", + "querystring": "^0.2.1" + } + }, "node_modules/@typechain/ethers-v5": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/@typechain/ethers-v5/-/ethers-v5-10.0.0.tgz", diff --git a/package.json b/package.json index d40afd305..a9d3cdc3e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@govtechsg/oa-encryption": "^1.3.5", "@govtechsg/oa-verify": "^9.3.0-beta.4", "@govtechsg/open-attestation": "^6.10.0-beta.6", - "@govtechsg/opencerts-verify": "^3.1.3", + "@trustvc/opencerts-verify": "^3.1.4", "@next/bundle-analyzer": "^14.2.5", "@reduxjs/toolkit": "^2.2.7", "@types/google.analytics": "0.0.41", diff --git a/pages/index.tsx b/pages/index.tsx index f5d68ca94..c308c0840 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -2,7 +2,6 @@ import { ParsedUrlQuery } from "querystring"; import { useRouter } from "next/router"; import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; -import { Wogaa } from "../src/components/Analytics/wogaa"; import { Wrapper, Main } from "../src/components/Layout/Body"; import { FooterBar } from "../src/components/Layout/FooterBar"; import { NavigationBar } from "../src/components/Layout/NavigationBar"; @@ -38,8 +37,7 @@ const HomePage: React.FunctionComponent = (props) => { }, [props, urlParams]); return ( - - {urlParams ? : null} +
diff --git a/public/static/images/common/PBGT-logo.png b/public/static/images/common/PBGT-logo.png deleted file mode 100644 index 73d767fe3..000000000 Binary files a/public/static/images/common/PBGT-logo.png and /dev/null differ diff --git a/public/static/images/common/gds-logo.svg b/public/static/images/common/gds-logo.svg deleted file mode 100644 index ccc5ea274..000000000 --- a/public/static/images/common/gds-logo.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/Analytics/index.ts b/src/components/Analytics/index.ts index 94cc09a6d..2b88f77d0 100644 --- a/src/components/Analytics/index.ts +++ b/src/components/Analytics/index.ts @@ -1,5 +1,5 @@ import { v2, WrappedDocument, getData, v3, utils, v4 } from "@govtechsg/open-attestation"; -import { RegistryEntry } from "@govtechsg/opencerts-verify"; +import { RegistryEntry } from "@trustvc/opencerts-verify"; import { isEmpty, omitBy } from "lodash"; import ReactGA from "react-ga4"; import registry from "../../../public/static/registry.json"; diff --git a/src/components/Analytics/wogaa.tsx b/src/components/Analytics/wogaa.tsx deleted file mode 100644 index 02cb09856..000000000 --- a/src/components/Analytics/wogaa.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import Script from "next/script"; -import React from "react"; -import { WOGAA_TRANSACTIONAL_SERVICE } from "../../config"; - -declare global { - interface Window { - wogaaCustom: { - startTransactionalService: ( - trackingId: (typeof WOGAA_TRANSACTIONAL_SERVICE)[keyof typeof WOGAA_TRANSACTIONAL_SERVICE], - uniqueTransactionId?: string - ) => void; - completeTransactionalService: ( - trackingId: (typeof WOGAA_TRANSACTIONAL_SERVICE)[keyof typeof WOGAA_TRANSACTIONAL_SERVICE], - uniqueTransactionId?: string - ) => void; - }; - } -} - -const MAX_CALL_QUEUE_LENGTH = 20; -// calls to Wogaa can happen before the Wogaa script is loaded -// this queue will hold the calls until the Wogaa script is loaded -const wogaaCallQueue: ( - | { - name: "startTransactionalService"; - args: Parameters; - } - | { - name: "completeTransactionalService"; - args: Parameters; - } -)[] = []; -export const startTransactionalService: typeof window.wogaaCustom.startTransactionalService = (...args) => { - if (typeof window !== undefined && window.wogaaCustom) { - window.wogaaCustom.startTransactionalService(...args); - } else { - console.warn( - "window.wogaaCustom is not defined", - "Ensure Wogaa script is properly installed/imported", - "Pushed call to queue" - ); - // just in case wogaa script is never loaded, we dont want to keep storing calls indefinitely - if (wogaaCallQueue.length <= MAX_CALL_QUEUE_LENGTH) { - wogaaCallQueue.push({ name: "startTransactionalService", args }); - } - } -}; - -export const completeTransactionalService: typeof window.wogaaCustom.completeTransactionalService = (...args) => { - if (typeof window !== undefined && window.wogaaCustom) { - window.wogaaCustom.completeTransactionalService(...args); - } else { - console.warn( - "window.wogaaCustom is not defined", - "Ensure Wogaa script is properly installed/imported", - "Pushed call to queue" - ); - // just in case wogaa script is never loaded, we dont want to keep storing calls indefinitely - if (wogaaCallQueue.length <= MAX_CALL_QUEUE_LENGTH) { - wogaaCallQueue.push({ name: "completeTransactionalService", args }); - } - } -}; - -export const Wogaa = () => ( -