From b8bff3e72848e2ff7013d6abb7233239b6033d87 Mon Sep 17 00:00:00 2001 From: Yashasvi Bajpai <33063622+yashasvibajpai@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:10:33 +0530 Subject: [PATCH 1/2] chore: remove redundant https (#162) * chore: remove redundant https * chore: update formatting for dataplane url * chore: update commitlint configs * chore: update commitlint version to latest * chore: move commitlint back to 17.6.3 --- commitlnt.config.js | 6 -- package-lock.json | 177 +++++++----------------------------------- package.json | 4 +- src/deviceModeInit.js | 2 +- src/loadingCode.js | 2 +- src/router.js | 15 ++-- 6 files changed, 40 insertions(+), 166 deletions(-) delete mode 100644 commitlnt.config.js diff --git a/commitlnt.config.js b/commitlnt.config.js deleted file mode 100644 index 8ade7fe..0000000 --- a/commitlnt.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - extends: ['@commitlint/config-conventional'], - rules: { - 'type-enum': () => [2, 'always', ['fix', 'feat', 'chore', 'refactor', 'docs', 'test']], - }, -}; diff --git a/package-lock.json b/package-lock.json index c905958..60d7ef2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "axios": "^1.6.4", - "commitlint": "^17.7.1", + "commitlint": "^17.6.3", "conventional-github-releaser": "^3.1.5", "dotenv": "^15.0.0", "husky": "^8.0.3", @@ -20,7 +20,7 @@ "standard-version": "^9.5.0" }, "devDependencies": { - "@commitlint/config-conventional": "^18.5.0", + "@commitlint/config-conventional": "^17.6.3", "eslint": "^8.49.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-json": "^3.1.0", @@ -685,28 +685,16 @@ "node": ">=v14" } }, - "node_modules/@commitlint/cli/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/config-conventional": { - "version": "18.6.3", - "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-18.6.3.tgz", - "integrity": "sha512-8ZrRHqF6je+TRaFoJVwszwnOXb/VeYrPmTwPhf0WxpzpGTcYy1p0SPyZ2eRn/sRi/obnWAcobtDAq6+gJQQNhQ==", + "version": "17.8.1", + "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.8.1.tgz", + "integrity": "sha512-NxCOHx1kgneig3VLauWJcDWS40DVjg7nKOpBEEK9E5fjJpQqLCilcnKkIIjdBH98kEO1q3NpE5NSrZ2kl/QGJg==", "dev": true, "dependencies": { - "@commitlint/types": "^18.6.1", - "conventional-changelog-conventionalcommits": "^7.0.2" + "conventional-changelog-conventionalcommits": "^6.1.0" }, "engines": { - "node": ">=v18" + "node": ">=v14" } }, "node_modules/@commitlint/config-validator": { @@ -721,17 +709,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/config-validator/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/ensure": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-17.8.1.tgz", @@ -748,17 +725,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/ensure/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/execute-rule": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-17.8.1.tgz", @@ -779,17 +745,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/format/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/is-ignored": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.8.1.tgz", @@ -802,15 +757,18 @@ "node": ">=v14" } }, - "node_modules/@commitlint/is-ignored/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", + "node_modules/@commitlint/is-ignored/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dependencies": { - "chalk": "^4.1.0" + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" }, "engines": { - "node": ">=v14" + "node": ">=10" } }, "node_modules/@commitlint/lint": { @@ -827,17 +785,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/lint/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/load": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-17.8.1.tgz", @@ -862,17 +809,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/load/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/message": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-17.8.1.tgz", @@ -894,17 +830,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/parse/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/read": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-17.8.1.tgz", @@ -920,17 +845,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/read/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/resolve-extends": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-17.8.1.tgz", @@ -947,17 +861,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/resolve-extends/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/rules": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.8.1.tgz", @@ -973,17 +876,6 @@ "node": ">=v14" } }, - "node_modules/@commitlint/rules/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/@commitlint/to-lines": { "version": "17.8.1", "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-17.8.1.tgz", @@ -1004,15 +896,14 @@ } }, "node_modules/@commitlint/types": { - "version": "18.6.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-18.6.1.tgz", - "integrity": "sha512-gwRLBLra/Dozj2OywopeuHj2ac26gjGkz2cZ+86cTJOdtWfiRRr4+e77ZDAGc6MDWxaWheI+mAV5TLWWRwqrFg==", - "dev": true, + "version": "17.8.1", + "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", + "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", "dependencies": { "chalk": "^4.1.0" }, "engines": { - "node": ">=v18" + "node": ">=v14" } }, "node_modules/@cspotcode/source-map-support": { @@ -2676,17 +2567,6 @@ "node": ">=v14" } }, - "node_modules/commitlint/node_modules/@commitlint/types": { - "version": "17.8.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz", - "integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==", - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">=v14" - } - }, "node_modules/compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -2794,15 +2674,15 @@ "integrity": "sha512-IpVePh16EbbB02V+UA+HQnnPIohgXvJRxHcS5+Uwk4AT5LjzCZJm5sp/yqs5C6KZJ1jMsV4paEV13BN1pvDuxQ==" }, "node_modules/conventional-changelog-conventionalcommits": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-7.0.2.tgz", - "integrity": "sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-6.1.0.tgz", + "integrity": "sha512-3cS3GEtR78zTfMzk0AizXKKIdN4OvSh7ibNz6/DPbhWWQu7LqE/8+/GqSodV+sywUR2gpJAdP/1JFf4XtN7Zpw==", "dev": true, "dependencies": { "compare-func": "^2.0.0" }, "engines": { - "node": ">=16" + "node": ">=14" } }, "node_modules/conventional-changelog-core": { @@ -8085,12 +7965,9 @@ } }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "bin": { "semver": "bin/semver.js" }, diff --git a/package.json b/package.json index d63997a..be3c362 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "license": "ISC", "dependencies": { "axios": "^1.6.4", - "commitlint": "^17.7.1", + "commitlint": "^17.6.3", "conventional-github-releaser": "^3.1.5", "dotenv": "^15.0.0", "husky": "^8.0.3", @@ -32,7 +32,7 @@ "standard-version": "^9.5.0" }, "devDependencies": { - "@commitlint/config-conventional": "^18.5.0", + "@commitlint/config-conventional": "^17.6.3", "eslint": "^8.49.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-json": "^3.1.0", diff --git a/src/deviceModeInit.js b/src/deviceModeInit.js index d0dd6c5..c64b075 100644 --- a/src/deviceModeInit.js +++ b/src/deviceModeInit.js @@ -340,7 +340,7 @@ let _rudderTracking = (function () { // common function for sending anonymousId and sessionId Identifier function sendToRudderWebhook(data, type, updateTypeCookieFunction, retryAttempt = 0) { - const webhookUrl = 'https://dataplaneUrl_placeHolder/v1/webhook?writeKey=writeKey_placeHolder'; + const webhookUrl = 'dataplaneUrl_placeHolder/v1/webhook?writeKey=writeKey_placeHolder'; const timeToRetry = 1000; // 1 second const maxRetries = 3; if (maxRetries > retryAttempt) { diff --git a/src/loadingCode.js b/src/loadingCode.js index a2f6ac1..6dbedd1 100644 --- a/src/loadingCode.js +++ b/src/loadingCode.js @@ -23,7 +23,7 @@ }; })(method); } - rudderanalytics.load('writeKey', 'https://dataPlaneUrl', { + rudderanalytics.load('writeKey', 'dataPlaneUrl', { configUrl: 'configBackendUrl', logLevel: 'DEBUG', }); diff --git a/src/router.js b/src/router.js index da1f041..8a89da7 100644 --- a/src/router.js +++ b/src/router.js @@ -18,13 +18,14 @@ const ensureHttpsPrefix = (url) => { return url; }; -const isValidDataPlaneURL = (dataPlaneUrl) => { +const formatDataPlaneURL = (dataPlaneUrl) => { + // TODO :: Sanitize dataplane url with basic checks before prefixing with https const newDataPlaneUrl = ensureHttpsPrefix(dataPlaneUrl); try { new URL(newDataPlaneUrl); // This will throw if the URL is invalid - return true; + return newDataPlaneUrl; } catch { - return false; + return undefined; } }; const isValidWriteKey = (writeKey) => /^[A-Za-z0-9_]{5,}$/.test(writeKey); @@ -52,16 +53,18 @@ router.get('/load', async (ctx) => { const { writeKey, dataPlaneUrl } = ctx.request.query; console.log('writeKey', writeKey); console.log('dataplaneUrl', dataPlaneUrl); - if (!isValidDataPlaneURL(dataPlaneUrl) || !isValidWriteKey(writeKey)) { + if (formatDataPlaneURL(dataPlaneUrl) === undefined || !isValidWriteKey(writeKey)) { ctx.response.body = { error: 'writeKey or dataPlaneUrl is invalid or missing', }; ctx.status = 400; return ctx; } + const formattedDataPlaneUrl = formatDataPlaneURL(dataPlaneUrl); + console.log('formattedDataPlaneUrl', formattedDataPlaneUrl); d = d.replace('writeKey', writeKey); - d = d.replace('dataPlaneUrl', dataPlaneUrl); + d = d.replace('dataPlaneUrl', formattedDataPlaneUrl); d = d.replace('configBackendUrl', configUrl); const pollTimeForSessionIdentifierCheck = @@ -70,7 +73,7 @@ router.get('/load', async (ctx) => { /sessionIdentifierPollTime_placeHolder/g, pollTimeForSessionIdentifierCheck, ); - deviceModeInit = deviceModeInit.replace(/dataplaneUrl_placeHolder/g, dataPlaneUrl); + deviceModeInit = deviceModeInit.replace(/dataplaneUrl_placeHolder/g, formattedDataPlaneUrl); deviceModeInit = deviceModeInit.replace(/writeKey_placeHolder/g, writeKey); deviceModeInit = deviceModeInit.replace(/configUrl_placeholder/g, configUrl); From 0f64c57e069a86a28d5fd6b8b6d919af3d0059d2 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 20 Sep 2024 13:41:20 +0000 Subject: [PATCH 2/2] chore(release): 1.5.1 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b13832d..7ca1020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.5.1](https://github.com/rudderlabs/rudder-shopify-tracker/compare/v1.5.0...v1.5.1) (2024-09-20) + ## [1.5.0](https://github.com/rudderlabs/rudder-shopify-tracker/compare/v1.4.10...v1.5.0) (2024-09-20) diff --git a/package-lock.json b/package-lock.json index 60d7ef2..8b6a40d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudderstack-shopify-tracker", - "version": "1.5.0", + "version": "1.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudderstack-shopify-tracker", - "version": "1.5.0", + "version": "1.5.1", "license": "ISC", "dependencies": { "axios": "^1.6.4", diff --git a/package.json b/package.json index be3c362..df72144 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudderstack-shopify-tracker", - "version": "1.5.0", + "version": "1.5.1", "description": "Tracks client-side events on Shopify stores", "main": "src/main.js", "scripts": {