diff --git a/.buildkite/Dockerfile.agent b/.buildkite/Dockerfile.agent index 8b5a6b52e..7ef44e24b 100644 --- a/.buildkite/Dockerfile.agent +++ b/.buildkite/Dockerfile.agent @@ -1,55 +1,5 @@ -FROM 528451384384.dkr.ecr.us-west-2.amazonaws.com/buildkite-agent-node16:node-16.16 +FROM 528451384384.dkr.ecr.us-west-2.amazonaws.com/buildkite-agent-node20 -# 2. Install WebKit dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - libwoff1 \ - libopus0 \ - libwebp6 \ - libwebpdemux2 \ - libenchant1c2a \ - libgudev-1.0-0 \ - libsecret-1-0 \ - libhyphen0 \ - libgdk-pixbuf2.0-0 \ - libegl1 \ - libnotify4 \ - libxslt1.1 \ - libevent-2.1-6 \ - libgles2 \ - libvpx5 \ - libxcomposite1 \ - libatk1.0-0 \ - libatk-bridge2.0-0 \ - libepoxy0 \ - libgtk-3-0 \ - libharfbuzz-icu0 - -# 3. Install gstreamer and plugins to support video playback in WebKit. -RUN apt-get update && apt-get install -y --no-install-recommends \ - libgstreamer-gl1.0-0 \ - libgstreamer-plugins-bad1.0-0 \ - gstreamer1.0-plugins-good \ - gstreamer1.0-libav - -# 4. Install Chromium dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - libnss3 \ - libxss1 \ - libasound2 \ - fonts-noto-color-emoji \ - libxtst6 - -# 5. Install Firefox dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - libdbus-glib-1-2 \ - libxt6 - -# 6. Install ffmpeg to bring in audio and video codecs necessary for playing videos in Firefox. -RUN apt-get update && apt-get install -y --no-install-recommends \ - ffmpeg - -# 7. (Optional) Install XVFB if there's a need to run browsers in headful mode -RUN apt-get update && apt-get install -y --no-install-recommends \ - xvfb +RUN npx playwright install-deps ENTRYPOINT [] diff --git a/.buildkite/Readme.md b/.buildkite/Readme.md index c38a7468c..da5d625b6 100644 --- a/.buildkite/Readme.md +++ b/.buildkite/Readme.md @@ -1,14 +1,11 @@ -# Buildkite setup - -## Dockerfile.agent - -Builds the base image that is used by analytics-next in CI. +# Buildkite +## How to update the buildkite docker agent +1. Make your changes to `Dockerfile.agent`. +2. Push the changes to ecr +(will need `Ops Write` permission). ```bash -$ robo docker.login-privileged +$ cd .buildkite +$ robo-tooling.docker.login-privileged $ make agent ``` - -## .pipeline - -Full buildkite configuration. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e27e2ab49..a7db4a5a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: - uses: browser-actions/setup-chrome@v1 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 16 # UPDATE TO NODE 20!!! cache: 'yarn' - run: yarn install --immutable - name: Turbo cache diff --git a/.github/workflows/create-github-release.yml b/.github/workflows/create-github-release.yml index 5a6957951..185d40363 100644 --- a/.github/workflows/create-github-release.yml +++ b/.github/workflows/create-github-release.yml @@ -11,10 +11,10 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v3 - - name: Setup Node.js 16.x + - name: Setup Node.js 20.x uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 20.x cache: "yarn" - name: Install Dependencies run: HUSKY=0 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn install --immutable diff --git a/.github/workflows/release-creator.yml b/.github/workflows/release-creator.yml index c2e43a733..69d10066a 100644 --- a/.github/workflows/release-creator.yml +++ b/.github/workflows/release-creator.yml @@ -21,10 +21,10 @@ jobs: # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits fetch-depth: 0 - - name: Setup Node.js 16.x + - name: Setup Node.js 20.x uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 20.x cache: "yarn" - name: Install Dependencies diff --git a/.nvmrc b/.nvmrc index d4b25d088..f3f52b42d 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16.16 +20.9.0 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..f5be7fd90 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,7 @@ +coverage: + status: + project: + default: + target: auto + threshold: 0% + base: auto diff --git a/package.json b/package.json index 43c93ae6d..246980765 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "scripts" ], "engines": { - "node": "^16.16.0" + "node": "^20" }, "scripts": { "test": "jest", diff --git a/packages/browser/jest.config.js b/packages/browser/jest.config.js index b3f10efe1..2e212a7fb 100644 --- a/packages/browser/jest.config.js +++ b/packages/browser/jest.config.js @@ -6,10 +6,10 @@ module.exports = createJestTSConfig(__dirname, { testEnvironment: 'jsdom', coverageThreshold: { global: { - branches: 80.91, - functions: 87.25, - lines: 91.03, - statements: 87.25, + branches: 74, + functions: 80, + lines: 87, + statements: 82, }, }, }) diff --git a/packages/browser/package.json b/packages/browser/package.json index 330c3391e..89244a7a4 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -74,7 +74,7 @@ "@types/js-cookie": "3.0.1", "@types/jsdom": "^16.2.14", "@types/mime": "^2.0.3", - "@types/node": "^16", + "@types/node": "^20", "@types/serve-handler": "^6.1.0", "aws-sdk": "^2.814.0", "circular-dependency-plugin": "^5.2.2", diff --git a/packages/config/src/jest/config.js b/packages/config/src/jest/config.js index f40d0fb65..00c53331c 100644 --- a/packages/config/src/jest/config.js +++ b/packages/config/src/jest/config.js @@ -22,6 +22,19 @@ const createJestTSConfig = ( * No need to manually run yarn build all the time. * This resolve packages for ts-jest so typescript compilation happens in-memory. */ + ...(process.env.COVERAGE === 'true' + ? { + collectCoverage: true, + coverageReporters: ['json'], + collectCoverageFrom: [ + 'src/**/*.{js,jsx,ts,tsx}', + '!src/**/*.test.{js,jsx,ts,tsx}', + // Exclude test files "!src/**/index.{js,ts}", + // Exclude index files + ], + coverageDirectory: '/coverage', + } + : {}), moduleNameMapper: moduleMap, preset: 'ts-jest', modulePathIgnorePatterns: [ diff --git a/packages/node/package.json b/packages/node/package.json index 7124262e9..67f15ca16 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -45,7 +45,7 @@ }, "devDependencies": { "@internal/config": "0.0.0", - "@types/node": "^16", + "@types/node": "^18", "axios": "^1.6.2" }, "packageManager": "yarn@3.4.1" diff --git a/packages/signals/signals/src/core/client/redact.ts b/packages/signals/signals/src/core/client/redact.ts index 3c28c2ada..6f7a7eb61 100644 --- a/packages/signals/signals/src/core/client/redact.ts +++ b/packages/signals/signals/src/core/client/redact.ts @@ -3,7 +3,11 @@ import { Signal } from '@segment/analytics-signals-runtime' export const redactSignalData = (signalArg: Signal): Signal => { const signal = structuredClone(signalArg) if (signal.type === 'interaction') { - if ('target' in signal.data) { + if ( + 'target' in signal.data && + signal.data.target && + typeof signal.data.target === 'object' + ) { if ('value' in signal.data.target) { signal.data.target.value = redactJsonValues(signal.data.target.value) } diff --git a/scripts/clean.sh b/scripts/clean.sh index b1c8477a8..c6c312ad7 100644 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -1,7 +1,7 @@ #!/bin/sh # Clear build artifacts and build cache -find . \( -name ".turbo" -o -name "dist" -o -name ".next" -o -name "tsconfig.tsbuildinfo" \) ! -path "*/node_modules/*" -print0 | xargs -0 rm -rf +find . \( -name ".turbo" -o -name "dist" -o -name ".next" -o -name "tsconfig.tsbuildinfo" -o -name "coverage" \) ! -path "*/node_modules/*" -print0 | xargs -0 rm -rf rm -rf node_modules/.cache echo "Build files and cache deleted." diff --git a/scripts/package.json b/scripts/package.json index 9cf25a45d..c68ec6d17 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -15,7 +15,7 @@ "packageManager": "yarn@3.4.1", "devDependencies": { "@node-kit/yarn-workspace-root": "^3.2.0", - "@types/node": "^16", + "@types/node": "^20", "ts-node": "^10.8.0" } } diff --git a/yarn.lock b/yarn.lock index e4d322be6..ade0dc543 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2984,7 +2984,7 @@ __metadata: resolution: "@internal/scripts@workspace:scripts" dependencies: "@node-kit/yarn-workspace-root": ^3.2.0 - "@types/node": ^16 + "@types/node": ^20 ts-node: ^10.8.0 languageName: unknown linkType: soft @@ -4273,7 +4273,7 @@ __metadata: "@types/js-cookie": 3.0.1 "@types/jsdom": ^16.2.14 "@types/mime": ^2.0.3 - "@types/node": ^16 + "@types/node": ^20 "@types/serve-handler": ^6.1.0 aws-sdk: ^2.814.0 circular-dependency-plugin: ^5.2.2 @@ -4315,7 +4315,7 @@ __metadata: "@lukeed/uuid": ^2.0.0 "@segment/analytics-core": 1.8.0 "@segment/analytics-generic-utils": 1.2.0 - "@types/node": ^16 + "@types/node": ^18 axios: ^1.6.2 buffer: ^6.0.3 jose: ^5.1.0 @@ -6463,6 +6463,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^18": + version: 18.19.64 + resolution: "@types/node@npm:18.19.64" + dependencies: + undici-types: ~5.26.4 + checksum: e7680215b03c9bee8a33947f03d06048e8e460f23b1b7b29c45350cf437faa5f8fcb7d8c3eb8dfec8427923e7a184df42bc710c1b6252b4852e3ed7064c6228f + languageName: node + linkType: hard + "@types/node@npm:^18.11.15": version: 18.17.5 resolution: "@types/node@npm:18.17.5" @@ -6470,6 +6479,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20": + version: 20.17.6 + resolution: "@types/node@npm:20.17.6" + dependencies: + undici-types: ~6.19.2 + checksum: d51dbb9881c94d0310b32b5fd8013e3261595c61bc888fa27258469c93c3dc0b3c4d20a9f28f3f5f79562f6737e28e7f3dd04940dc8b4d966d34aaf318f7f69b + languageName: node + linkType: hard + "@types/node@npm:^20.1.0, @types/node@npm:^20.1.1": version: 20.3.1 resolution: "@types/node@npm:20.3.1" @@ -22393,6 +22411,20 @@ __metadata: languageName: node linkType: hard +"undici-types@npm:~5.26.4": + version: 5.26.5 + resolution: "undici-types@npm:5.26.5" + checksum: 3192ef6f3fd5df652f2dc1cd782b49d6ff14dc98e5dced492aa8a8c65425227da5da6aafe22523c67f035a272c599bb89cfe803c1db6311e44bed3042fc25487 + languageName: node + linkType: hard + +"undici-types@npm:~6.19.2": + version: 6.19.8 + resolution: "undici-types@npm:6.19.8" + checksum: de51f1b447d22571cf155dfe14ff6d12c5bdaec237c765085b439c38ca8518fc360e88c70f99469162bf2e14188a7b0bcb06e1ed2dc031042b984b0bb9544017 + languageName: node + linkType: hard + "undici@npm:^5.22.1": version: 5.28.4 resolution: "undici@npm:5.28.4"