From ed1cdd49f7c0d1dfdd7df5ba1d4b3d9c1cf09d9c Mon Sep 17 00:00:00 2001 From: Ravi Kiran Papani Date: Wed, 14 Aug 2024 23:29:25 -0700 Subject: [PATCH 1/6] feat: experimentation opportunities audit --- package-lock.json | 89 ++----------------- package.json | 2 +- .../experimentationopportunities.js | 67 ++++++++++++++ 3 files changed, 73 insertions(+), 85 deletions(-) create mode 100644 src/experimentationopportunities/experimentationopportunities.js diff --git a/package-lock.json b/package-lock.json index 434db885..6461ea81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@adobe/spacecat-shared-ahrefs-client": "1.4.1", "@adobe/spacecat-shared-data-access": "1.41.2", "@adobe/spacecat-shared-http-utils": "1.6.1", - "@adobe/spacecat-shared-rum-api-client": "2.7.3", + "@adobe/spacecat-shared-rum-api-client": "https://gitpkg.now.sh/adobe/spacecat-shared/packages/spacecat-shared-rum-api-client?cede51c05756f680ea6a31189323038f7171da85", "@adobe/spacecat-shared-rum-api-client-v1": "npm:@adobe/spacecat-shared-rum-api-client@1.8.4", "@adobe/spacecat-shared-utils": "1.19.3", "@aws-sdk/client-lambda": "3.624.0", @@ -2086,7 +2086,6 @@ "version": "1.41.2", "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-data-access/-/spacecat-shared-data-access-1.41.2.tgz", "integrity": "sha512-jUEJzY6gUnFBDcG9sMsVCND2WQQsFHMRe/9HNN7zjlGkMVA3CaxsajKSydZOur7dq6NK9326k/86revrkonv1A==", - "license": "Apache-2.0", "dependencies": { "@adobe/spacecat-shared-dynamo": "1.2.5", "@adobe/spacecat-shared-utils": "1.2.0", @@ -2656,7 +2655,6 @@ "version": "1.6.1", "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-http-utils/-/spacecat-shared-http-utils-1.6.1.tgz", "integrity": "sha512-zm9QnAqBOWQMmpN+2WJHkVa9/nkfDagjhqcQ3eauU8+ZJscXBc4r7zQjaLeDv9zAn+Yn/nD2Og8pKmOAB273Qg==", - "license": "Apache-2.0", "dependencies": { "@adobe/fetch": "4.1.8", "@adobe/spacecat-shared-data-access": "1.39.0", @@ -3696,9 +3694,9 @@ } }, "node_modules/@adobe/spacecat-shared-rum-api-client": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-rum-api-client/-/spacecat-shared-rum-api-client-2.7.3.tgz", - "integrity": "sha512-BonnWQA2N1jBdjjtWxZ8vtcMX5+CgfcNOcHBnkm0HdmpfT+UEX5eTswrQvDyfUbH4nK9ArNIeGZLQtE0q64tBg==", + "version": "2.7.2", + "resolved": "https://gitpkg.now.sh/adobe/spacecat-shared/packages/spacecat-shared-rum-api-client?cede51c05756f680ea6a31189323038f7171da85", + "integrity": "sha512-Vp1NlR2vEq4roPjuwOSLqANSqWd7gTjHjQ1MfuvyoiQGPbv+74kixyt0AaNwvCf0mYGd6mfMFj1j1dIw5YS+cA==", "license": "Apache-2.0", "dependencies": { "@adobe/fetch": "4.1.8", @@ -3810,8 +3808,7 @@ "node_modules/@adobe/spacecat-shared-rum-api-client/node_modules/aws4": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.1.tgz", - "integrity": "sha512-u5w79Rd7SU4JaIlA/zFqG+gOiuq25q5VLyZ8E+ijJeILuTxVzZgp2CaGw/UTw6pXYN9XMO9yiqj/nEHmhTG5CA==", - "license": "MIT" + "integrity": "sha512-u5w79Rd7SU4JaIlA/zFqG+gOiuq25q5VLyZ8E+ijJeILuTxVzZgp2CaGw/UTw6pXYN9XMO9yiqj/nEHmhTG5CA==" }, "node_modules/@adobe/spacecat-shared-utils": { "version": "1.19.3", @@ -6040,7 +6037,6 @@ "version": "3.624.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb/-/client-dynamodb-3.624.0.tgz", "integrity": "sha512-/xssTNmwL+au3JIRQLHwz6O1kF8R9lfmL1PocQ+9sxcL4titU9TGslUotvZjdbklp3LzfusQh9Svx5g8EaONSw==", - "license": "Apache-2.0", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", @@ -6095,7 +6091,6 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-browser/-/sha256-browser-5.2.0.tgz", "integrity": "sha512-AXfN/lGotSQwu6HNcEsIASo7kWXZ5HYWvfOmSNKDsEqC4OashTp8alTmaz+F7TC2L083SFv5RdB+qU3Vs1kZqw==", - "license": "Apache-2.0", "dependencies": { "@aws-crypto/sha256-js": "^5.2.0", "@aws-crypto/supports-web-crypto": "^5.2.0", @@ -6110,7 +6105,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz", "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==", - "license": "Apache-2.0", "dependencies": { "@smithy/util-buffer-from": "^2.2.0", "tslib": "^2.6.2" @@ -6123,7 +6117,6 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz", "integrity": "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA==", - "license": "Apache-2.0", "dependencies": { "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", @@ -6137,7 +6130,6 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/@aws-crypto/supports-web-crypto/-/supports-web-crypto-5.2.0.tgz", "integrity": "sha512-iAvUotm021kM33eCdNfwIN//F77/IADDSs58i+MDaOqFrVjZo9bAal0NK7HurRuWLLpF1iLX7gbWrjHjeo+YFg==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" } @@ -6146,7 +6138,6 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-5.2.0.tgz", "integrity": "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==", - "license": "Apache-2.0", "dependencies": { "@aws-sdk/types": "^3.222.0", "@smithy/util-utf8": "^2.0.0", @@ -6157,7 +6148,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz", "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==", - "license": "Apache-2.0", "dependencies": { "@smithy/util-buffer-from": "^2.2.0", "tslib": "^2.6.2" @@ -6170,7 +6160,6 @@ "version": "3.624.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.624.0.tgz", "integrity": "sha512-Ki2uKYJKKtfHxxZsiMTOvJoVRP6b2pZ1u3rcUb2m/nVgBPUfLdl8ZkGpqE29I+t5/QaS/sEdbn6cgMUZwl+3Dg==", - "license": "Apache-2.0", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", @@ -6223,7 +6212,6 @@ "version": "3.624.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.624.0.tgz", "integrity": "sha512-k36fLZCb2nfoV/DKK3jbRgO/Yf7/R80pgYfMiotkGjnZwDmRvNN08z4l06L9C+CieazzkgRxNUzyppsYcYsQaw==", - "license": "Apache-2.0", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", @@ -6274,7 +6262,6 @@ "version": "3.624.0", "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.624.0.tgz", "integrity": "sha512-WyFmPbhRIvtWi7hBp8uSFy+iPpj8ccNV/eX86hwF4irMjfc/FtsGVIAeBXxXM/vGCjkdfEzOnl+tJ2XACD4OXg==", - "license": "Apache-2.0", "dependencies": { "@smithy/core": "^2.3.2", "@smithy/node-config-provider": "^3.1.4", @@ -6294,7 +6281,6 @@ "version": "3.609.0", "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.609.0.tgz", "integrity": "sha512-+Tqnh9w0h2LcrUsdXyT1F8mNhXz+tVYBtP19LpeEGntmvHwa2XzvLUCWpoIAIVsHp5+HdB2X9Sn0KAtmbFXc2Q==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6319,7 +6305,6 @@ "version": "3.0.5", "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-3.0.5.tgz", "integrity": "sha512-SkW5LxfkSI1bUC74OtfBbdz+grQXYiPYolyu8VfpLIjEoN/sHVBlLeGXMQ1vX4ejkgfv6sxVbQJ32yF2cl1veA==", - "license": "Apache-2.0", "dependencies": { "@smithy/node-config-provider": "^3.1.4", "@smithy/types": "^3.3.0", @@ -6335,7 +6320,6 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-3.2.0.tgz", "integrity": "sha512-0SCIzgd8LYZ9EJxUjLXBmEKSZR/P/w6l7Rz/pab9culE/RWuqelAKGJvn5qUOl8BgX8Yj5HWM50A5hiB/RzsgA==", - "license": "Apache-2.0", "dependencies": { "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", @@ -6351,7 +6335,6 @@ "version": "3.2.4", "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-3.2.4.tgz", "integrity": "sha512-kBprh5Gs5h7ug4nBWZi1FZthdqSM+T7zMmsZxx0IBvWUn7dK3diz2SHn7Bs4dQGFDk8plDv375gzenDoNwrXjg==", - "license": "Apache-2.0", "dependencies": { "@smithy/protocol-http": "^4.1.0", "@smithy/querystring-builder": "^3.0.3", @@ -6364,7 +6347,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-3.0.3.tgz", "integrity": "sha512-2ctBXpPMG+B3BtWSGNnKELJ7SH9e4TNefJS0cd2eSkOOROeBnnVBnAy9LtJ8tY4vUEoe55N4CNPxzbWvR39iBw==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "@smithy/util-buffer-from": "^3.0.0", @@ -6379,7 +6361,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-3.0.0.tgz", "integrity": "sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA==", - "license": "Apache-2.0", "dependencies": { "@smithy/is-array-buffer": "^3.0.0", "tslib": "^2.6.2" @@ -6392,7 +6373,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/invalid-dependency/-/invalid-dependency-3.0.3.tgz", "integrity": "sha512-ID1eL/zpDULmHJbflb864k72/SNOZCADRc9i7Exq3RUNJw6raWUSlFEQ+3PX3EYs++bTxZB2dE9mEHTQLv61tw==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6402,7 +6382,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-3.0.0.tgz", "integrity": "sha512-+Fsu6Q6C4RSJiy81Y8eApjEB5gVtM+oFKTffg+jSuwtvomJJrhUJBu2zS8wjXSgH/g1MKEWrzyChTBe6clb5FQ==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -6414,7 +6393,6 @@ "version": "3.0.5", "resolved": "https://registry.npmjs.org/@smithy/middleware-content-length/-/middleware-content-length-3.0.5.tgz", "integrity": "sha512-ILEzC2eyxx6ncej3zZSwMpB5RJ0zuqH7eMptxC4KN3f+v9bqT8ohssKbhNR78k/2tWW+KS5Spw+tbPF4Ejyqvw==", - "license": "Apache-2.0", "dependencies": { "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", @@ -6428,7 +6406,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-3.1.0.tgz", "integrity": "sha512-5y5aiKCEwg9TDPB4yFE7H6tYvGFf1OJHNczeY10/EFF8Ir8jZbNntQJxMWNfeQjC1mxPsaQ6mR9cvQbf+0YeMw==", - "license": "Apache-2.0", "dependencies": { "@smithy/middleware-serde": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", @@ -6446,7 +6423,6 @@ "version": "3.0.14", "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-3.0.14.tgz", "integrity": "sha512-7ZaWZJOjUxa5hgmuMspyt8v/zVsh0GXYuF7OvCmdcbVa/xbnKQoYC+uYKunAqRGTkxjOyuOCw9rmFUFOqqC0eQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/node-config-provider": "^3.1.4", "@smithy/protocol-http": "^4.1.0", @@ -6466,7 +6442,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-3.0.3.tgz", "integrity": "sha512-puUbyJQBcg9eSErFXjKNiGILJGtiqmuuNKEYNYfUD57fUl4i9+mfmThtQhvFXU0hCVG0iEJhvQUipUf+/SsFdA==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6479,7 +6454,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-3.0.3.tgz", "integrity": "sha512-r4klY9nFudB0r9UdSMaGSyjyQK5adUyPnQN/ZM6M75phTxOdnc/AhpvGD1fQUvgmqjQEBGCwpnPbDm8pH5PapA==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6492,7 +6466,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-3.1.4.tgz", "integrity": "sha512-YvnElQy8HR4vDcAjoy7Xkx9YT8xZP4cBXcbJSgm/kxmiQu08DwUwj8rkGnyoJTpfl/3xYHH+d8zE+eHqoDCSdQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/property-provider": "^3.1.3", "@smithy/shared-ini-file-loader": "^3.1.4", @@ -6507,7 +6480,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-3.1.4.tgz", "integrity": "sha512-+UmxgixgOr/yLsUxcEKGH0fMNVteJFGkmRltYFHnBMlogyFdpzn2CwqWmxOrfJELhV34v0WSlaqG1UtE1uXlJg==", - "license": "Apache-2.0", "dependencies": { "@smithy/abort-controller": "^3.1.1", "@smithy/protocol-http": "^4.1.0", @@ -6523,7 +6495,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-3.1.3.tgz", "integrity": "sha512-zahyOVR9Q4PEoguJ/NrFP4O7SMAfYO1HLhB18M+q+Z4KFd4V2obiMnlVoUFzFLSPeVt1POyNWneHHrZaTMoc/g==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6536,7 +6507,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-4.1.0.tgz", "integrity": "sha512-dPVoHYQ2wcHooGXg3LQisa1hH0e4y0pAddPMeeUPipI1tEOqL6A4N0/G7abeq+K8wrwSgjk4C0wnD1XZpJm5aA==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6549,7 +6519,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-3.0.3.tgz", "integrity": "sha512-vyWckeUeesFKzCDaRwWLUA1Xym9McaA6XpFfAK5qI9DKJ4M33ooQGqvM4J+LalH4u/Dq9nFiC8U6Qn1qi0+9zw==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "@smithy/util-uri-escape": "^3.0.0", @@ -6563,7 +6532,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-3.0.3.tgz", "integrity": "sha512-zahM1lQv2YjmznnfQsWbYojFe55l0SLG/988brlLv1i8z3dubloLF+75ATRsqPBboUXsW6I9CPGE5rQgLfY0vQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6576,7 +6544,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/service-error-classification/-/service-error-classification-3.0.3.tgz", "integrity": "sha512-Jn39sSl8cim/VlkLsUhRFq/dKDnRUFlfRkvhOJaUbLBXUsLRLNf9WaxDv/z9BjuQ3A6k/qE8af1lsqcwm7+DaQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0" }, @@ -6588,7 +6555,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-3.1.4.tgz", "integrity": "sha512-qMxS4hBGB8FY2GQqshcRUy1K6k8aBWP5vwm8qKkCT3A9K2dawUwOIJfqh9Yste/Bl0J2lzosVyrXDj68kLcHXQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6601,7 +6567,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-4.1.0.tgz", "integrity": "sha512-aRryp2XNZeRcOtuJoxjydO6QTaVhxx/vjaR+gx7ZjaFgrgPRyZ3HCTbfwqYj6ZWEBHkCSUfcaymKPURaByukag==", - "license": "Apache-2.0", "dependencies": { "@smithy/is-array-buffer": "^3.0.0", "@smithy/protocol-http": "^4.1.0", @@ -6620,7 +6585,6 @@ "version": "3.1.12", "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-3.1.12.tgz", "integrity": "sha512-wtm8JtsycthkHy1YA4zjIh2thJgIQ9vGkoR639DBx5lLlLNU0v4GARpQZkr2WjXue74nZ7MiTSWfVrLkyD8RkA==", - "license": "Apache-2.0", "dependencies": { "@smithy/middleware-endpoint": "^3.1.0", "@smithy/middleware-stack": "^3.0.3", @@ -6648,7 +6612,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-3.0.3.tgz", "integrity": "sha512-pw3VtZtX2rg+s6HMs6/+u9+hu6oY6U7IohGhVNnjbgKy86wcIsSZwgHrFR+t67Uyxvp4Xz3p3kGXXIpTNisq8A==", - "license": "Apache-2.0", "dependencies": { "@smithy/querystring-parser": "^3.0.3", "@smithy/types": "^3.3.0", @@ -6659,7 +6622,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-base64/-/util-base64-3.0.0.tgz", "integrity": "sha512-Kxvoh5Qtt0CDsfajiZOCpJxgtPHXOKwmM+Zy4waD43UoEMA+qPxxa98aE/7ZhdnBFZFXMOiBR5xbcaMhLtznQQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/util-buffer-from": "^3.0.0", "@smithy/util-utf8": "^3.0.0", @@ -6673,7 +6635,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-3.0.0.tgz", "integrity": "sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA==", - "license": "Apache-2.0", "dependencies": { "@smithy/is-array-buffer": "^3.0.0", "tslib": "^2.6.2" @@ -6686,7 +6647,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-body-length-browser/-/util-body-length-browser-3.0.0.tgz", "integrity": "sha512-cbjJs2A1mLYmqmyVl80uoLTJhAcfzMOyPgjwAYusWKMdLeNtzmMz9YxNl3/jRLoxSS3wkqkf0jwNdtXWtyEBaQ==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" } @@ -6695,7 +6655,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-body-length-node/-/util-body-length-node-3.0.0.tgz", "integrity": "sha512-Tj7pZ4bUloNUP6PzwhN7K386tmSmEET9QtQg0TgdNOnxhZvCssHji+oZTUIuzxECRfG8rdm2PMw2WCFs6eIYkA==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -6707,7 +6666,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-config-provider/-/util-config-provider-3.0.0.tgz", "integrity": "sha512-pbjk4s0fwq3Di/ANL+rCvJMKM5bzAQdE5S/6RL5NXgMExFAi6UgQMPOm5yPaIWPpr+EOXKXRonJ3FoxKf4mCJQ==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -6719,7 +6677,6 @@ "version": "3.0.14", "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-3.0.14.tgz", "integrity": "sha512-0iwTgKKmAIf+vFLV8fji21Jb2px11ktKVxbX6LIDPAUJyWQqGqBVfwba7xwa1f2FZUoolYQgLvxQEpJycXuQ5w==", - "license": "Apache-2.0", "dependencies": { "@smithy/property-provider": "^3.1.3", "@smithy/smithy-client": "^3.1.12", @@ -6735,7 +6692,6 @@ "version": "3.0.14", "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-3.0.14.tgz", "integrity": "sha512-e9uQarJKfXApkTMMruIdxHprhcXivH1flYCe8JRDTzkkLx8dA3V5J8GZlST9yfDiRWkJpZJlUXGN9Rc9Ade3OQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/config-resolver": "^3.0.5", "@smithy/credential-provider-imds": "^3.2.0", @@ -6753,7 +6709,6 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/@smithy/util-endpoints/-/util-endpoints-2.0.5.tgz", "integrity": "sha512-ReQP0BWihIE68OAblC/WQmDD40Gx+QY1Ez8mTdFMXpmjfxSyz2fVQu3A4zXRfQU9sZXtewk3GmhfOHswvX+eNg==", - "license": "Apache-2.0", "dependencies": { "@smithy/node-config-provider": "^3.1.4", "@smithy/types": "^3.3.0", @@ -6767,7 +6722,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-3.0.0.tgz", "integrity": "sha512-eFndh1WEK5YMUYvy3lPlVmYY/fZcQE1D8oSf41Id2vCeIkKJXPcYDCZD+4+xViI6b1XSd7tE+s5AmXzz5ilabQ==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -6779,7 +6733,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-3.0.3.tgz", "integrity": "sha512-l+StyYYK/eO3DlVPbU+4Bi06Jjal+PFLSMmlWM1BEwyLxZ3aKkf1ROnoIakfaA7mC6uw3ny7JBkau4Yc+5zfWw==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -6792,7 +6745,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/util-retry/-/util-retry-3.0.3.tgz", "integrity": "sha512-AFw+hjpbtVApzpNDhbjNG5NA3kyoMs7vx0gsgmlJF4s+yz1Zlepde7J58zpIRIsdjc+emhpAITxA88qLkPF26w==", - "license": "Apache-2.0", "dependencies": { "@smithy/service-error-classification": "^3.0.3", "@smithy/types": "^3.3.0", @@ -6806,7 +6758,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-3.1.3.tgz", "integrity": "sha512-FIv/bRhIlAxC0U7xM1BCnF2aDRPq0UaelqBHkM2lsCp26mcBbgI0tCVTv+jGdsQLUmAMybua/bjDsSu8RQHbmw==", - "license": "Apache-2.0", "dependencies": { "@smithy/fetch-http-handler": "^3.2.4", "@smithy/node-http-handler": "^3.1.4", @@ -6825,7 +6776,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-3.0.0.tgz", "integrity": "sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA==", - "license": "Apache-2.0", "dependencies": { "@smithy/is-array-buffer": "^3.0.0", "tslib": "^2.6.2" @@ -6838,7 +6788,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-uri-escape/-/util-uri-escape-3.0.0.tgz", "integrity": "sha512-LqR7qYLgZTD7nWLBecUi4aqolw8Mhza9ArpNEQ881MJJIU2sE5iHCK6TdyqqzcDLy0OPe10IY4T8ctVdtynubg==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -6850,7 +6799,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-3.0.0.tgz", "integrity": "sha512-rUeT12bxFnplYDe815GXbq/oixEGHfRFFtcTF3YdDi/JaENIM6aSYYLJydG83UNzLXeRI5K8abYd/8Sp/QM0kA==", - "license": "Apache-2.0", "dependencies": { "@smithy/util-buffer-from": "^3.0.0", "tslib": "^2.6.2" @@ -6863,7 +6811,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-3.0.0.tgz", "integrity": "sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA==", - "license": "Apache-2.0", "dependencies": { "@smithy/is-array-buffer": "^3.0.0", "tslib": "^2.6.2" @@ -6899,7 +6846,6 @@ "url": "https://paypal.me/naturalintelligence" } ], - "license": "MIT", "dependencies": { "strnum": "^1.0.5" }, @@ -15598,7 +15544,6 @@ "version": "3.624.0", "resolved": "https://registry.npmjs.org/@aws-sdk/lib-dynamodb/-/lib-dynamodb-3.624.0.tgz", "integrity": "sha512-PdItV9kqgeCH0OPslFZkRsxSKZ7P+DT0unXC5u/QIObzpoRXIWMM4GXCrrKb3lndh1L4jnqepyCTwWao9UX+ng==", - "license": "Apache-2.0", "dependencies": { "@aws-sdk/util-dynamodb": "3.624.0", "@smithy/smithy-client": "^3.1.12", @@ -15616,7 +15561,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-3.1.1.tgz", "integrity": "sha512-MBJBiidoe+0cTFhyxT8g+9g7CeVccLM0IOKKUMCNQ1CNMJ/eIfoo0RTfVrXOONEI1UCN1W+zkiHSbzUNE9dZtQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -15629,7 +15573,6 @@ "version": "3.2.4", "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-3.2.4.tgz", "integrity": "sha512-kBprh5Gs5h7ug4nBWZi1FZthdqSM+T7zMmsZxx0IBvWUn7dK3diz2SHn7Bs4dQGFDk8plDv375gzenDoNwrXjg==", - "license": "Apache-2.0", "dependencies": { "@smithy/protocol-http": "^4.1.0", "@smithy/querystring-builder": "^3.0.3", @@ -15642,7 +15585,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-3.0.0.tgz", "integrity": "sha512-+Fsu6Q6C4RSJiy81Y8eApjEB5gVtM+oFKTffg+jSuwtvomJJrhUJBu2zS8wjXSgH/g1MKEWrzyChTBe6clb5FQ==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -15654,7 +15596,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-3.1.0.tgz", "integrity": "sha512-5y5aiKCEwg9TDPB4yFE7H6tYvGFf1OJHNczeY10/EFF8Ir8jZbNntQJxMWNfeQjC1mxPsaQ6mR9cvQbf+0YeMw==", - "license": "Apache-2.0", "dependencies": { "@smithy/middleware-serde": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", @@ -15672,7 +15613,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-3.0.3.tgz", "integrity": "sha512-puUbyJQBcg9eSErFXjKNiGILJGtiqmuuNKEYNYfUD57fUl4i9+mfmThtQhvFXU0hCVG0iEJhvQUipUf+/SsFdA==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -15685,7 +15625,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-3.0.3.tgz", "integrity": "sha512-r4klY9nFudB0r9UdSMaGSyjyQK5adUyPnQN/ZM6M75phTxOdnc/AhpvGD1fQUvgmqjQEBGCwpnPbDm8pH5PapA==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -15698,7 +15637,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-3.1.4.tgz", "integrity": "sha512-YvnElQy8HR4vDcAjoy7Xkx9YT8xZP4cBXcbJSgm/kxmiQu08DwUwj8rkGnyoJTpfl/3xYHH+d8zE+eHqoDCSdQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/property-provider": "^3.1.3", "@smithy/shared-ini-file-loader": "^3.1.4", @@ -15713,7 +15651,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-3.1.4.tgz", "integrity": "sha512-+UmxgixgOr/yLsUxcEKGH0fMNVteJFGkmRltYFHnBMlogyFdpzn2CwqWmxOrfJELhV34v0WSlaqG1UtE1uXlJg==", - "license": "Apache-2.0", "dependencies": { "@smithy/abort-controller": "^3.1.1", "@smithy/protocol-http": "^4.1.0", @@ -15729,7 +15666,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-3.1.3.tgz", "integrity": "sha512-zahyOVR9Q4PEoguJ/NrFP4O7SMAfYO1HLhB18M+q+Z4KFd4V2obiMnlVoUFzFLSPeVt1POyNWneHHrZaTMoc/g==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -15742,7 +15678,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-4.1.0.tgz", "integrity": "sha512-dPVoHYQ2wcHooGXg3LQisa1hH0e4y0pAddPMeeUPipI1tEOqL6A4N0/G7abeq+K8wrwSgjk4C0wnD1XZpJm5aA==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -15755,7 +15690,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-3.0.3.tgz", "integrity": "sha512-vyWckeUeesFKzCDaRwWLUA1Xym9McaA6XpFfAK5qI9DKJ4M33ooQGqvM4J+LalH4u/Dq9nFiC8U6Qn1qi0+9zw==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "@smithy/util-uri-escape": "^3.0.0", @@ -15769,7 +15703,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-3.0.3.tgz", "integrity": "sha512-zahM1lQv2YjmznnfQsWbYojFe55l0SLG/988brlLv1i8z3dubloLF+75ATRsqPBboUXsW6I9CPGE5rQgLfY0vQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -15782,7 +15715,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-3.1.4.tgz", "integrity": "sha512-qMxS4hBGB8FY2GQqshcRUy1K6k8aBWP5vwm8qKkCT3A9K2dawUwOIJfqh9Yste/Bl0J2lzosVyrXDj68kLcHXQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -15795,7 +15727,6 @@ "version": "3.1.12", "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-3.1.12.tgz", "integrity": "sha512-wtm8JtsycthkHy1YA4zjIh2thJgIQ9vGkoR639DBx5lLlLNU0v4GARpQZkr2WjXue74nZ7MiTSWfVrLkyD8RkA==", - "license": "Apache-2.0", "dependencies": { "@smithy/middleware-endpoint": "^3.1.0", "@smithy/middleware-stack": "^3.0.3", @@ -15812,7 +15743,6 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/@smithy/types/-/types-3.3.0.tgz", "integrity": "sha512-IxvBBCTFDHbVoK7zIxqA1ZOdc4QfM5HM7rGleCuHi7L1wnKv5Pn69xXJQ9hgxH60ZVygH9/JG0jRgtUncE3QUA==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -15824,7 +15754,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-3.0.3.tgz", "integrity": "sha512-pw3VtZtX2rg+s6HMs6/+u9+hu6oY6U7IohGhVNnjbgKy86wcIsSZwgHrFR+t67Uyxvp4Xz3p3kGXXIpTNisq8A==", - "license": "Apache-2.0", "dependencies": { "@smithy/querystring-parser": "^3.0.3", "@smithy/types": "^3.3.0", @@ -15835,7 +15764,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-base64/-/util-base64-3.0.0.tgz", "integrity": "sha512-Kxvoh5Qtt0CDsfajiZOCpJxgtPHXOKwmM+Zy4waD43UoEMA+qPxxa98aE/7ZhdnBFZFXMOiBR5xbcaMhLtznQQ==", - "license": "Apache-2.0", "dependencies": { "@smithy/util-buffer-from": "^3.0.0", "@smithy/util-utf8": "^3.0.0", @@ -15849,7 +15777,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-3.0.0.tgz", "integrity": "sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA==", - "license": "Apache-2.0", "dependencies": { "@smithy/is-array-buffer": "^3.0.0", "tslib": "^2.6.2" @@ -15862,7 +15789,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-3.0.0.tgz", "integrity": "sha512-eFndh1WEK5YMUYvy3lPlVmYY/fZcQE1D8oSf41Id2vCeIkKJXPcYDCZD+4+xViI6b1XSd7tE+s5AmXzz5ilabQ==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -15874,7 +15800,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-3.0.3.tgz", "integrity": "sha512-l+StyYYK/eO3DlVPbU+4Bi06Jjal+PFLSMmlWM1BEwyLxZ3aKkf1ROnoIakfaA7mC6uw3ny7JBkau4Yc+5zfWw==", - "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -15887,7 +15812,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-3.1.3.tgz", "integrity": "sha512-FIv/bRhIlAxC0U7xM1BCnF2aDRPq0UaelqBHkM2lsCp26mcBbgI0tCVTv+jGdsQLUmAMybua/bjDsSu8RQHbmw==", - "license": "Apache-2.0", "dependencies": { "@smithy/fetch-http-handler": "^3.2.4", "@smithy/node-http-handler": "^3.1.4", @@ -15906,7 +15830,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-uri-escape/-/util-uri-escape-3.0.0.tgz", "integrity": "sha512-LqR7qYLgZTD7nWLBecUi4aqolw8Mhza9ArpNEQ881MJJIU2sE5iHCK6TdyqqzcDLy0OPe10IY4T8ctVdtynubg==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, @@ -15918,7 +15841,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-3.0.0.tgz", "integrity": "sha512-rUeT12bxFnplYDe815GXbq/oixEGHfRFFtcTF3YdDi/JaENIM6aSYYLJydG83UNzLXeRI5K8abYd/8Sp/QM0kA==", - "license": "Apache-2.0", "dependencies": { "@smithy/util-buffer-from": "^3.0.0", "tslib": "^2.6.2" @@ -17501,7 +17423,6 @@ "version": "3.624.0", "resolved": "https://registry.npmjs.org/@aws-sdk/util-dynamodb/-/util-dynamodb-3.624.0.tgz", "integrity": "sha512-u34TL7+fHnJHZi83nMkapjAtN9SLnRgXrwuRJ6cLIdvucHGGFtSxh6Nhp2GsrXGbO5hhoqXUDg3uCG7T3tJ7ow==", - "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" }, diff --git a/package.json b/package.json index 4d77d504..9a3ba94b 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@adobe/spacecat-shared-ahrefs-client": "1.4.1", "@adobe/spacecat-shared-data-access": "1.41.2", "@adobe/spacecat-shared-http-utils": "1.6.1", - "@adobe/spacecat-shared-rum-api-client": "2.7.3", + "@adobe/spacecat-shared-rum-api-client": "https://gitpkg.now.sh/adobe/spacecat-shared/packages/spacecat-shared-rum-api-client?cede51c05756f680ea6a31189323038f7171da85", "@adobe/spacecat-shared-rum-api-client-v1": "npm:@adobe/spacecat-shared-rum-api-client@1.8.4", "@aws-sdk/client-lambda": "3.624.0", "@aws-sdk/credential-provider-node": "3.624.0", diff --git a/src/experimentationopportunities/experimentationopportunities.js b/src/experimentationopportunities/experimentationopportunities.js new file mode 100644 index 00000000..6457cb26 --- /dev/null +++ b/src/experimentationopportunities/experimentationopportunities.js @@ -0,0 +1,67 @@ +/* + * Copyright 2024 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +/* c8 ignore start */ +import RUMAPIClient from '@adobe/spacecat-shared-rum-api-client'; +import { AuditBuilder } from '../common/audit-builder.js'; +import { getRUMDomainkey } from '../support/utils.js'; + +const DAYS = 30; + +let log = console; + +/** + * Audit handler container for all the experimentation opportunities + * @param {*} auditUrl + * @param {*} context + * @param {*} site + * @returns + */ + +export async function experimentationOpportunitiesHandler(auditUrl, context, site) { + log = context.log; + log.info(`Received Experimentation Opportunities audit request for ${auditUrl}`); + const startTime = process.hrtime(); + + const rumAPIClient = RUMAPIClient.createFrom(context); + const domainkey = await getRUMDomainkey(site.getBaseURL(), context); + const options = { + domain: auditUrl, + domainkey, + interval: DAYS, + granularity: 'hourly', + }; + const queryHandlers = ['rageclick']; + const queryResults = await rumAPIClient.queryMulti(queryHandlers, options); + const auditData = { + experimentationOpportunities: [], + }; + for (const queryResult of Object.keys(queryResults)) { + auditData.experimentationOpportunities.push(queryResults[queryResult]); + } + + const endTime = process.hrtime(startTime); + const elapsedSeconds = endTime[0] + endTime[1] / 1e9; + const formattedElapsed = elapsedSeconds.toFixed(2); + + log.info(`Experimentation opportunities Audit is completed in ${formattedElapsed} seconds for ${auditUrl}`); + + return { + auditResult: auditData, + fullAuditRef: auditUrl, + }; +} + +export default new AuditBuilder() + .withRunner(experimentationOpportunitiesHandler) + .build(); +/* c8 ignore stop */ From 6ad22be6fad8aa6fdfdb80e413f508eed64d767a Mon Sep 17 00:00:00 2001 From: Ravi Kiran Papani Date: Thu, 15 Aug 2024 16:07:43 -0700 Subject: [PATCH 2/6] fix: review feedback --- src/index.js | 2 ++ .../opportunities.js} | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) rename src/{experimentationopportunities/experimentationopportunities.js => opportunities/opportunities.js} (88%) diff --git a/src/index.js b/src/index.js index a51ef9b0..5dd6bc6a 100644 --- a/src/index.js +++ b/src/index.js @@ -29,6 +29,7 @@ import experimentation from './experimentation/handler.js'; import conversion from './conversion/handler.js'; import essExperimentationDaily from './experimentation-ess/daily.js'; import essExperimentationAll from './experimentation-ess/all.js'; +import opportunities from './opportunities/opportunities.js'; const HANDLERS = { apex, @@ -43,6 +44,7 @@ const HANDLERS = { conversion, 'experimentation-ess-daily': essExperimentationDaily, 'experimentation-ess-all': essExperimentationAll, + opportunities, }; function getElapsedSeconds(startTime) { diff --git a/src/experimentationopportunities/experimentationopportunities.js b/src/opportunities/opportunities.js similarity index 88% rename from src/experimentationopportunities/experimentationopportunities.js rename to src/opportunities/opportunities.js index 6457cb26..8179915b 100644 --- a/src/experimentationopportunities/experimentationopportunities.js +++ b/src/opportunities/opportunities.js @@ -40,13 +40,15 @@ export async function experimentationOpportunitiesHandler(auditUrl, context, sit interval: DAYS, granularity: 'hourly', }; - const queryHandlers = ['rageclick']; - const queryResults = await rumAPIClient.queryMulti(queryHandlers, options); + const experimentationHandlers = ['rageclick']; + const queryResults = await rumAPIClient.queryMulti(experimentationHandlers, options); const auditData = { experimentationOpportunities: [], }; for (const queryResult of Object.keys(queryResults)) { - auditData.experimentationOpportunities.push(queryResults[queryResult]); + if (experimentationHandlers.includes(queryResult)) { + auditData.experimentationOpportunities.push(...queryResults[queryResult]); + } } const endTime = process.hrtime(startTime); From d35a2073a0b582380912318d85941a22eac9cde4 Mon Sep 17 00:00:00 2001 From: Ravi Kiran Papani Date: Thu, 15 Aug 2024 17:26:24 -0700 Subject: [PATCH 3/6] chore: adding unit tests --- src/opportunities/opportunities.js | 6 +- test/audits/opportunities.test.js | 110 +++++++++++++++++++++++++++ test/fixtures/opportunitiesdata.json | 47 ++++++++++++ 3 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 test/audits/opportunities.test.js create mode 100644 test/fixtures/opportunitiesdata.json diff --git a/src/opportunities/opportunities.js b/src/opportunities/opportunities.js index 8179915b..c38e9c97 100644 --- a/src/opportunities/opportunities.js +++ b/src/opportunities/opportunities.js @@ -20,14 +20,14 @@ const DAYS = 30; let log = console; /** - * Audit handler container for all the experimentation opportunities + * Audit handler container for all the opportunities * @param {*} auditUrl * @param {*} context * @param {*} site * @returns */ -export async function experimentationOpportunitiesHandler(auditUrl, context, site) { +export async function opportunitiesHandler(auditUrl, context, site) { log = context.log; log.info(`Received Experimentation Opportunities audit request for ${auditUrl}`); const startTime = process.hrtime(); @@ -64,6 +64,6 @@ export async function experimentationOpportunitiesHandler(auditUrl, context, sit } export default new AuditBuilder() - .withRunner(experimentationOpportunitiesHandler) + .withRunner(opportunitiesHandler) .build(); /* c8 ignore stop */ diff --git a/test/audits/opportunities.test.js b/test/audits/opportunities.test.js new file mode 100644 index 00000000..571e5a19 --- /dev/null +++ b/test/audits/opportunities.test.js @@ -0,0 +1,110 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +/* eslint-env mocha */ + +import chai from 'chai'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; +import nock from 'nock'; +import { opportunitiesHandler } from '../../src/opportunities/opportunities.js'; +import { MockContextBuilder } from '../shared.js'; +import opportunitiesData from '../fixtures/opportunitiesdata.json' assert { type: 'json' }; + +chai.use(sinonChai); +const { expect } = chai; + +describe('Opportunities Tests', () => { + const url = 'https://abc.com'; + let context; + let processEnvCopy; + let messageBodyJson; + let sandbox; + before('setup', function () { + sandbox = sinon.createSandbox(); + const mockDate = '2023-11-27T12:30:01.124Z'; + this.clock = sandbox.useFakeTimers({ + now: new Date(mockDate).getTime(), + }); + }); + + beforeEach('setup', () => { + messageBodyJson = { + type: '404', + url: 'https://abc.com', + auditContext: { + finalUrl: 'abc.com', + }, + }; + context = new MockContextBuilder() + .withSandbox(sandbox) + .withOverrides({ + env: { + AUDIT_RESULTS_QUEUE_URL: 'queueUrl', + AWS_REGION: 'us-east-1', + AWS_ACCESS_KEY_ID: 'some-key-id', + AWS_SECRET_ACCESS_KEY: 'some-secret-key', + AWS_SESSION_TOKEN: 'some-secret-token', + }, + runtime: { name: 'aws-lambda', region: 'us-east-1' }, + func: { package: 'spacecat-services', version: 'ci', name: 'test' }, + }) + .build(messageBodyJson); + processEnvCopy = { ...process.env }; + process.env = { + ...process.env, + ...context.env, + }; + }); + after('clean', function () { + this.clock.uninstall(); + }); + + afterEach(() => { + process.env = processEnvCopy; + nock.cleanAll(); + sinon.restore(); + }); + + it('fetch bundles for base url > process > send opportunities', async () => { + nock('https://secretsmanager.us-east-1.amazonaws.com/') + .post('/', (body) => body.SecretId === '/helix-deploy/spacecat-services/customer-secrets/abc_com/ci') + .reply(200, { + SecretString: JSON.stringify({ + RUM_DOMAIN_KEY: 'abc_dummy_key', + }), + }); + nock('https://abc.com') + .get('/') + .reply(200); + context.rumApiClient = { + queryMulti: sinon.stub().resolves(opportunitiesData), + }; + const site = { + getBaseURL: () => 'https://abc.com', + }; + const auditData = await opportunitiesHandler(url, context, site); + + expect(context.rumApiClient.queryMulti).calledWith( + ['rageclick'], + { + domain: 'https://abc.com', + domainkey: 'abc_dummy_key', + interval: 30, + granularity: 'hourly', + }, + ); + expect( + auditData.auditResult.experimentationOpportunities, + ).to.deep.equal(opportunitiesData.rageclick); + }); +}); diff --git a/test/fixtures/opportunitiesdata.json b/test/fixtures/opportunitiesdata.json new file mode 100644 index 00000000..92f6f8ee --- /dev/null +++ b/test/fixtures/opportunitiesdata.json @@ -0,0 +1,47 @@ +{ + "rageclick": [ + { + "type": "rageclick", + "page": "https://abc.com/abc-adoption/survey", + "screenshot": "", + "trackedPageKPIName": "The percentage of users who click on the same element lot of times in a short period of time.", + "trackedPageKPIValue": 43.25513196480938, + "pageViews": 34100, + "samples": 341, + "metrics": [ + { + "type": "click", + "selector": ".abc-survey", + "value": 2111, + "samples": 138, + "percentage": 40.469208211143695 + }, + { + "type": "click", + "selector": ".abc-survey #abc-survey-next", + "value": 2160, + "samples": 157, + "percentage": 46.04105571847507 + } + ] + }, + { + "type": "rageclick", + "page": "https://abc.com/abc-adoption/account", + "screenshot": "", + "trackedPageKPIName": "The percentage of users who click on the same element lot of times in a short period of time.", + "trackedPageKPIValue": 8.771929824561402, + "pageViews": 11400, + "samples": 114, + "metrics": [ + { + "type": "click", + "selector": ".account #favorites", + "value": 138, + "samples": 10, + "percentage": 8.771929824561402 + } + ] + } + ] +} \ No newline at end of file From 449cac876386e562fadcedf7e3937a2d4d2477e1 Mon Sep 17 00:00:00 2001 From: Ravi Kiran Papani Date: Mon, 26 Aug 2024 15:28:00 -0700 Subject: [PATCH 4/6] chore: updating dependencies --- package-lock.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index fe7d7b86..f450532a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@adobe/spacecat-shared-ahrefs-client": "1.5.1", "@adobe/spacecat-shared-data-access": "1.43.3", "@adobe/spacecat-shared-http-utils": "1.6.8", - "@adobe/spacecat-shared-rum-api-client": "2.7.4", + "@adobe/spacecat-shared-rum-api-client": "2.8.0", "@adobe/spacecat-shared-rum-api-client-v1": "npm:@adobe/spacecat-shared-rum-api-client@1.8.4", "@adobe/spacecat-shared-utils": "1.19.6", "@aws-sdk/client-lambda": "3.637.0", @@ -4383,10 +4383,9 @@ } }, "node_modules/@adobe/spacecat-shared-rum-api-client": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-rum-api-client/-/spacecat-shared-rum-api-client-2.7.4.tgz", - "integrity": "sha512-0N3LClkMR7jKJGaqngL+e39XXYxO39lyjSKqYlzECDZGbbskNxs21zTzxpuOBFmpEBOow4xz23pcCVAPkhoKIA==", - "license": "Apache-2.0", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-rum-api-client/-/spacecat-shared-rum-api-client-2.8.0.tgz", + "integrity": "sha512-CNtQy6nYWErCJgG2YyFxej8hVBnoS8PItPNLvHRjEYXFpU9QhuoS+bSxcmDRbwRxMbHpAgK3XclddP6DFrKjDQ==", "dependencies": { "@adobe/fetch": "4.1.8", "@adobe/helix-shared-wrap": "2.0.2", From dfd110009b60a388fceba84989880ab85850273b Mon Sep 17 00:00:00 2001 From: Ravi Kiran Papani Date: Mon, 26 Aug 2024 16:20:35 -0700 Subject: [PATCH 5/6] fix: tests --- test/audits/opportunities.test.js | 5 ++--- test/fixtures/opportunitiesdata.json | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/test/audits/opportunities.test.js b/test/audits/opportunities.test.js index 571e5a19..22905dfb 100644 --- a/test/audits/opportunities.test.js +++ b/test/audits/opportunities.test.js @@ -12,7 +12,7 @@ /* eslint-env mocha */ -import chai from 'chai'; +import { expect, use } from 'chai'; import sinon from 'sinon'; import sinonChai from 'sinon-chai'; import nock from 'nock'; @@ -20,8 +20,7 @@ import { opportunitiesHandler } from '../../src/opportunities/opportunities.js'; import { MockContextBuilder } from '../shared.js'; import opportunitiesData from '../fixtures/opportunitiesdata.json' assert { type: 'json' }; -chai.use(sinonChai); -const { expect } = chai; +use(sinonChai); describe('Opportunities Tests', () => { const url = 'https://abc.com'; diff --git a/test/fixtures/opportunitiesdata.json b/test/fixtures/opportunitiesdata.json index 92f6f8ee..fde23dbf 100644 --- a/test/fixtures/opportunitiesdata.json +++ b/test/fixtures/opportunitiesdata.json @@ -13,14 +13,27 @@ "type": "click", "selector": ".abc-survey", "value": 2111, + "targets": { + "https://abc.com/in/products/media_1c2c9e62626b7b4df13882c013438725ae05464d6.jpeg": 577, + "undefined": 1534 + }, "samples": 138, + "mobileSamples": 106, + "desktopSamples": 32, "percentage": 40.469208211143695 }, { "type": "click", "selector": ".abc-survey #abc-survey-next", "value": 2160, + "targets": { + "https://abc.com/in/images/media_1c2c9e62626b7b4df13882c0134982380923890.jpeg": 141, + "https://abc.com/in/images/media_1c2c9e62626b7b4df13882c013498223987923afe.jpeg": 401, + "undefined": 1618 + }, "samples": 157, + "mobileSamples": 96, + "desktopSamples": 61, "percentage": 46.04105571847507 } ] @@ -38,10 +51,15 @@ "type": "click", "selector": ".account #favorites", "value": 138, + "targets": { + "undefined": 138 + }, "samples": 10, + "mobileSamples": 9, + "desktopSamples": 1, "percentage": 8.771929824561402 } ] } ] -} \ No newline at end of file +} From 2c646615dd8dc97ef727f2bfc022b8768a17c6e5 Mon Sep 17 00:00:00 2001 From: Ravi Kiran Papani Date: Mon, 26 Aug 2024 16:23:14 -0700 Subject: [PATCH 6/6] fix: log message --- src/opportunities/opportunities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opportunities/opportunities.js b/src/opportunities/opportunities.js index c38e9c97..4eff2b43 100644 --- a/src/opportunities/opportunities.js +++ b/src/opportunities/opportunities.js @@ -29,7 +29,7 @@ let log = console; export async function opportunitiesHandler(auditUrl, context, site) { log = context.log; - log.info(`Received Experimentation Opportunities audit request for ${auditUrl}`); + log.info(`Received Opportunities audit request for ${auditUrl}`); const startTime = process.hrtime(); const rumAPIClient = RUMAPIClient.createFrom(context); @@ -55,7 +55,7 @@ export async function opportunitiesHandler(auditUrl, context, site) { const elapsedSeconds = endTime[0] + endTime[1] / 1e9; const formattedElapsed = elapsedSeconds.toFixed(2); - log.info(`Experimentation opportunities Audit is completed in ${formattedElapsed} seconds for ${auditUrl}`); + log.info(`Opportunities Audit is completed in ${formattedElapsed} seconds for ${auditUrl}`); return { auditResult: auditData,