diff --git a/lib/schema-event.js b/lib/schema-event.js index 913cf1d9a3..e832eecc97 100644 --- a/lib/schema-event.js +++ b/lib/schema-event.js @@ -114,6 +114,7 @@ const context = { } const pageSchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -129,6 +130,7 @@ const pageSchema = { } const exitSchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -175,6 +177,7 @@ const exitSchema = { } const linkSchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -196,6 +199,7 @@ const linkSchema = { } const searchSchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -220,6 +224,7 @@ const searchSchema = { } const navigateSchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -239,6 +244,7 @@ const navigateSchema = { } const surveySchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -273,6 +279,7 @@ const surveySchema = { } const experimentSchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -304,6 +311,7 @@ const experimentSchema = { } const redirectSchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -331,6 +339,7 @@ const redirectSchema = { } const clipboardSchema = { + type: 'object', additionalProperties: false, required: [ 'type', @@ -352,6 +361,7 @@ const clipboardSchema = { } const printSchema = { + type: 'object', additionalProperties: false, required: [ 'type', diff --git a/middleware/events.js b/middleware/events.js index bb69adcc93..04301d9d00 100644 --- a/middleware/events.js +++ b/middleware/events.js @@ -1,11 +1,13 @@ const express = require('express') const { omit } = require('lodash') const Ajv = require('ajv') +const addFormats = require('ajv-formats') const schema = require('../lib/schema-event') const OMIT_FIELDS = ['type', 'token'] const ajv = new Ajv() +addFormats(ajv) const router = express.Router() diff --git a/package-lock.json b/package-lock.json index a86b8b462e..75469e0c01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5678,14 +5678,29 @@ } }, "ajv": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz", - "integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.4.0.tgz", + "integrity": "sha512-7QD2l6+KBSLwf+7MuYocbWvRPdOu63/trReTLu2KFwkgctnub1auoF+Y1WYcm09CTM7quuscrzqmASaLHC/K4Q==", "requires": { "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", "uri-js": "^4.2.2" + }, + "dependencies": { + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + } + } + }, + "ajv-formats": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz", + "integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==", + "requires": { + "ajv": "^8.0.0" } }, "ajv-keywords": { @@ -9494,6 +9509,18 @@ } } }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, "ansi-regex": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", @@ -19247,8 +19274,7 @@ "require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" }, "require-main-filename": { "version": "2.0.0", diff --git a/package.json b/package.json index 07bc4aaef2..9801ebc433 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "@primer/css": "^16.2.0", "@primer/octicons": "^14.1.0", "@primer/octicons-react": "^14.1.0", - "ajv": "^6.11.0", + "ajv": "^8.4.0", + "ajv-formats": "^2.1.0", "algoliasearch": "^4.9.1", "assert": "^2.0.0", "babel-loader": "^8.2.2", diff --git a/pages/[versionId]/[productId]/index.tsx b/pages/[versionId]/[productId]/index.tsx index 21a7562ac7..906bff47fc 100644 --- a/pages/[versionId]/[productId]/index.tsx +++ b/pages/[versionId]/[productId]/index.tsx @@ -41,13 +41,8 @@ const ProductPage = ({ mainContext, productLandingContext }: Props) => { } const ProductPageInner = () => { - const { - title, - guideCards, - productUserExamples, - productCommunityExamples, - productCodeExamples, - } = useProductLandingContext() + const { title, guideCards, productUserExamples, productCommunityExamples, productCodeExamples } = + useProductLandingContext() const { t } = useTranslation('product_landing') const { FEATURE_NEW_SITETREE } = useFeatureFlags()