diff --git a/analytics/spec/events/_index.yaml b/analytics/spec/events/_index.yaml index 3ad2bc08c1..587c12c676 100644 --- a/analytics/spec/events/_index.yaml +++ b/analytics/spec/events/_index.yaml @@ -8,5 +8,3 @@ - $ref: ./video_played.yaml - $ref: ./product_downloaded.yaml - $ref: ./error_page_loaded.yaml -- $ref: ./ab_test_result.yaml -- $ref: ./ab_test_served.yaml diff --git a/analytics/spec/events/ab_test_result.yaml b/analytics/spec/events/ab_test_result.yaml deleted file mode 100644 index e2a866e0ce..0000000000 --- a/analytics/spec/events/ab_test_result.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -name: AB Test Result -description: The user has completed the successful event of an A/B test. -rules: - '$schema': http://json-schema.org/draft-04/schema# - type: object - properties: - context: - $ref: ../meta/context.yaml - properties: - type: object - properties: - test_name: - description: The name of the A/B test that we are running - type: string - variant: - description: A uniquely identifying name for the variant - type: string - required: - - test_name - - variant diff --git a/analytics/spec/events/ab_test_served.yaml b/analytics/spec/events/ab_test_served.yaml deleted file mode 100644 index 1db11e5586..0000000000 --- a/analytics/spec/events/ab_test_served.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -name: AB Test Served -description: The user has been served a variant of an A/B test. -rules: - '$schema': http://json-schema.org/draft-04/schema# - type: object - properties: - context: - $ref: ../meta/context.yaml - properties: - type: object - properties: - test_name: - description: The name of the A/B test that we are running - type: string - variant: - description: A uniquely identifying name for the variant - type: string - required: - - test_name - - variant diff --git a/next.config.js b/next.config.js index 454d559e65..a6a38d9079 100644 --- a/next.config.js +++ b/next.config.js @@ -9,11 +9,6 @@ const withHashicorp = require('@hashicorp/platform-nextjs-plugin') const { redirectsConfig } = require('./build-libs/redirects') const HashiConfigPlugin = require('./config/plugin') -// Set api key for Happy Kit feature flags -const happyKitKey = process.env.NEXT_PUBLIC_FLAGS_ENV_KEY - ? process.env.NEXT_PUBLIC_FLAGS_ENV_KEY - : 'flags_pub_development_343442393171755603' - /** * @type {import('next/dist/lib/load-custom-routes').Header} * @@ -88,7 +83,6 @@ module.exports = withHashicorp({ MKTG_CONTENT_API: process.env.MKTG_CONTENT_API, // TODO: determine if DevDot needs this or not SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY, - HAPPY_KIT_KEY: happyKitKey, }, svgo: { plugins: [ diff --git a/package-lock.json b/package-lock.json index 2bf95a0b9c..7acebe568e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "dependencies": { "@actions/core": "^1.9.1", "@apidevtools/json-schema-ref-parser": "^9.0.9", - "@happykit/flags": "^3.1.1", "@hashicorp/design-system-tokens": "^2.1.0", "@hashicorp/flight-icons": "^3.5.0", "@hashicorp/localstorage-polyfill": "^1.0.14", @@ -1902,29 +1901,6 @@ "@hapi/hoek": "^9.0.0" } }, - "node_modules/@happykit/flags": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@happykit/flags/-/flags-3.1.1.tgz", - "integrity": "sha512-xYK28EaZNt1waKgErRQqQVgdzY6MYwmvhd70KlLtjYwgTni5lEV0wLOHVdfHKZhcNEZM0oL7QtMo10/40apWvQ==", - "dependencies": { - "nanoid": "3.2.0" - }, - "peerDependencies": { - "next": ">=12.0.2", - "react": ">=16.13.1" - } - }, - "node_modules/@happykit/flags/node_modules/nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, "node_modules/@hashicorp/design-system-tokens": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@hashicorp/design-system-tokens/-/design-system-tokens-2.1.0.tgz", diff --git a/package.json b/package.json index e96dee0356..b2831507ba 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,6 @@ "dependencies": { "@actions/core": "^1.9.1", "@apidevtools/json-schema-ref-parser": "^9.0.9", - "@happykit/flags": "^3.1.1", "@hashicorp/design-system-tokens": "^2.1.0", "@hashicorp/flight-icons": "^3.5.0", "@hashicorp/localstorage-polyfill": "^1.0.14", diff --git a/src/flags/client.ts b/src/flags/client.ts deleted file mode 100644 index e3a1b8c090..0000000000 --- a/src/flags/client.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { - createUseFlags, - type InitialFlagState as GenericInitialFlagState, -} from '@happykit/flags/client' -import { createUseFlagBag, FlagBagProvider } from '@happykit/flags/context' -import { type AppFlags, config } from './config' - -export type InitialFlagState = GenericInitialFlagState -export const useFlags = createUseFlags(config) -export const useFlagBag = createUseFlagBag() -export { FlagBagProvider } diff --git a/src/flags/config.ts b/src/flags/config.ts deleted file mode 100644 index a4b3e294c1..0000000000 --- a/src/flags/config.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import type { Configuration } from '@happykit/flags/config' - -// You can replace this with your exact flag types -export type AppFlags = { - [key: string]: boolean | number | string | null -} - -export const config: Configuration = { - envKey: process.env.HAPPY_KIT_KEY!, - - // You can provide defaults flag values here - defaultFlags: { - testFlag: false, - }, -} diff --git a/src/flags/edge.ts b/src/flags/edge.ts deleted file mode 100644 index 4f23d319cc..0000000000 --- a/src/flags/edge.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { createGetEdgeFlags } from '@happykit/flags/edge' -import { type AppFlags, config } from './config' - -export const getEdgeFlags = createGetEdgeFlags(config) diff --git a/src/flags/server.ts b/src/flags/server.ts deleted file mode 100644 index 7f6bc1aa83..0000000000 --- a/src/flags/server.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { - createGetFlags, - type GenericEvaluationResponseBody, -} from '@happykit/flags/server' -import { type AppFlags, config } from './config' - -export type EvaluationResponseBody = GenericEvaluationResponseBody -export const getFlags = createGetFlags(config) diff --git a/src/lib/ab-test-track.ts b/src/lib/ab-test-track.ts deleted file mode 100644 index 70f650610e..0000000000 --- a/src/lib/ab-test-track.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { isInUS } from '@hashicorp/platform-util/geo' - -import { canTrackAnalytics } from 'lib/analytics' - -export const abTestTrack = ({ - type, - test_name, - variant, -}: { - type: 'Served' | 'Result' - test_name: string - variant: string -}) => { - if (canTrackAnalytics() && isInUS()) { - window.analytics.track(`AB Test ${type}`, { - test_name, - variant, - }) - } -} diff --git a/src/middleware.ts b/src/middleware.ts index ddd99becb4..11b5d06133 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -9,7 +9,6 @@ import redirects from 'data/_redirects.generated.json' import variantRewrites from '.generated/tutorial-variant-map.json' import setGeoCookie from '@hashicorp/platform-edge-utils/lib/set-geo-cookie' import { HOSTNAME_MAP } from 'constants/hostname-map' -import { getEdgeFlags } from 'flags/edge' import { getVariantParam } from 'views/tutorial-view/utils/variants' function determineProductSlug(req: NextRequest): string { @@ -22,24 +21,12 @@ function determineProductSlug(req: NextRequest): string { return '*' } -function setHappyKitCookie( - cookie: { args: Parameters }, - response: NextResponse -): NextResponse { - if (cookie) { - response.cookies.set(...cookie.args) - } - return response -} - /** * Root-level middleware that will process all middleware-capable requests. * Currently used to support: * - Handling simple one-to-one redirects for .io routes */ export async function middleware(req: NextRequest, ev: NextFetchEvent) { - const { geo } = req - // UA checks to prevent misuse const { ua } = userAgent(req) if (/(bytespider|bytedance)/i.test(ua)) { @@ -90,22 +77,6 @@ export async function middleware(req: NextRequest, ev: NextFetchEvent) { return NextResponse.redirect(url, permanent ? 308 : 307) } - /** - * We are running A/B tests on a subset of routes, so we are limiting the call to resolve flags from HappyKit to only those routes. This limits the impact of any additional latency to the routes which need the data. - */ - // if ( - // geo?.country === 'US' && - // ['vault', 'consul'].includes(product) && - // ['/'].includes(req.nextUrl.pathname) - // ) { - // try { - // const edgeFlags = await getEdgeFlags({ request: req }) - // const { flags, cookie } = edgeFlags - // } catch { - // // Fallback to default URLs - // } - // } - // Check if this path is associated with a tutorial variant if (variantRewrites[req.nextUrl.pathname]) { // check for query param first diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 16773cae47..6c5c041e79 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -15,8 +15,6 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools' import { NextAdapter } from 'next-query-params' import { QueryParamProvider } from 'use-query-params' import type { AppProps } from 'next/app' -import { useFlags } from 'flags/client' -import { FlagBagProvider } from 'flags/client' import { SpeedInsights } from '@vercel/speed-insights/next' // HashiCorp imports @@ -59,7 +57,6 @@ export default function App({ Component, pageProps: { session, ...pageProps }, }: AppProps<{ session?: Session } & Record>) { - const flagBag = useFlags() useAnchorLinkAnalytics() useEffect(() => makeDevAnalyticsLogger(), []) @@ -87,30 +84,28 @@ export default function App({ - - - - - - - - import('lib/framer-motion-features').then( - (mod) => mod.default - ) - } - strict={process.env.NODE_ENV === 'development'} - > - - - - - - - - - - + + + + + + + import('lib/framer-motion-features').then( + (mod) => mod.default + ) + } + strict={process.env.NODE_ENV === 'development'} + > + + + + + + + + +