diff --git a/package.json b/package.json index e9caa353..8ae87ad0 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "prettier": "^3.3.3", "start-server-and-test": "^2.0.8", "ts-node": "^10.9.2", - "typescript": "^5.6.3" + "typescript": "^5.9.3" }, "browserslist": [ "since 2017-06" diff --git a/src/adapters/ecommerce.ts b/src/adapters/ecommerce.ts index c9583997..42bae5af 100644 --- a/src/adapters/ecommerce.ts +++ b/src/adapters/ecommerce.ts @@ -20,7 +20,10 @@ export default async (tracker: SnowplowTracker): Promise => { return; } - const environments = context.environment.split(',').map(env => env.trim()).filter(env => env.length > 0); + const environments = context.environment + .split(",") + .map((env) => env.trim()) + .filter((env) => env.length > 0); for (const env of environments) { switch (env) { @@ -169,55 +172,56 @@ export default async (tracker: SnowplowTracker): Promise => { // description: "tnew is a just a test description" // events-tracked: [{ "value": "transaction", "label": "Transaction" }] break; - case "weave": - import("../shared/environment-data-sources/weave").then(({ default: load }): void => load()); - // description: "weave is a just a test descriptions" - // events-tracked: [{ "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] - break; - case "webjoint": - import("../shared/environment-data-sources/webjoint").then(({ default: load }): void => load()); - // description: "webjoint is a just a test description" - // events-tracked: [{ "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] - break; - case "wefunder": - import("../shared/environment-data-sources/wefunder").then(({ default: load }): void => load()); - // description: "wefunder is a just a test description" - // events-tracked: [{ "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] - break; - case "wix": - import("../shared/environment-data-sources/wix").then(({ default: load }): void => load()); - // description: "wix is a just a test description" - // events-tracked: [{ value: "add_to_cart", label: "Add to Cart" }, { value: "remove_from_cart", label: "Remove from Cart" }, { "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] - break; - case "woocommerce": - import("../shared/environment-data-sources/woocommerce").then(({ default: load }): void => load()); - // description: "woocommerce is a just a test description" - // events-tracked: [{ "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] - break; - case "yotpo": - import("../shared/environment-data-sources/yotpo").then(({ default: load }): void => load()); - // description: "yotpo is a just a test description" - // events-tracked: [{ value: "add_to_cart", label: "Add to Cart" }, { value: "remove_from_cart", label: "Remove from Cart" }, { "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] - break; - case "flowhub": - import("../shared/environment-data-sources/flowhub").then(({ default: load }): void => load(tracker)); - // description: "flowhub is a just a test descriptions" - // events-tracked: [{ "value": "transaction", "label": "Transaction" }] - break; - case "thirdparty": - import("../shared/environment-data-sources/thirdparty").then(({ default: load }): void => load()); - // description: "thirdparty is a just a test descriptions" - // events-tracked: [{ "value": "transaction", "label": "Transaction" }] - break; - case "carrot": - import("../shared/environment-data-sources/carrot").then(({ default: load }): void => load(tracker)); - // description: "carrot is a just a test descriptions" - // events-tracked: [{ "value": "transaction", "label": "Transaction" }] - break; + case "weave": + import("../shared/environment-data-sources/weave").then(({ default: load }): void => load()); + // description: "weave is a just a test descriptions" + // events-tracked: [{ "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] + break; + case "webjoint": + import("../shared/environment-data-sources/webjoint").then(({ default: load }): void => load()); + // description: "webjoint is a just a test description" + // events-tracked: [{ "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] + break; + case "wefunder": + import("../shared/environment-data-sources/wefunder").then(({ default: load }): void => load()); + // description: "wefunder is a just a test description" + // events-tracked: [{ "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] + break; + case "wix": + import("../shared/environment-data-sources/wix").then(({ default: load }): void => load()); + // description: "wix is a just a test description" + // events-tracked: [{ value: "add_to_cart", label: "Add to Cart" }, { value: "remove_from_cart", label: "Remove from Cart" }, { "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] + break; + case "woocommerce": + import("../shared/environment-data-sources/woocommerce").then(({ default: load }): void => load()); + // description: "woocommerce is a just a test description" + // events-tracked: [{ "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] + break; + case "yotpo": + import("../shared/environment-data-sources/yotpo").then(({ default: load }): void => load()); + // description: "yotpo is a just a test description" + // events-tracked: [{ value: "add_to_cart", label: "Add to Cart" }, { value: "remove_from_cart", label: "Remove from Cart" }, { "value": "transaction", "label": "Transaction" }, { "value": "basket_items", "label": "Basket Items" }] + break; + case "flowhub": + import("../shared/environment-data-sources/flowhub").then(({ default: load }): void => load(tracker)); + // description: "flowhub is a just a test descriptions" + // events-tracked: [{ "value": "transaction", "label": "Transaction" }] + break; + case "thirdparty": + import("../shared/environment-data-sources/thirdparty").then(({ default: load }): void => load()); + // description: "thirdparty is a just a test descriptions" + // events-tracked: [{ "value": "transaction", "label": "Transaction" }] + break; + case "carrot": + import("../shared/environment-data-sources/carrot").then(({ default: load }): void => load(tracker)); + // description: "carrot is a just a test descriptions" + // events-tracked: [{ "value": "transaction", "label": "Transaction" }] + break; - default: - logger.warn("No event/environment specified, Only pageview is active"); - break; + default: + logger.warn("No event/environment specified, Only pageview is active"); + break; + } } }; } \ No newline at end of file diff --git a/src/shared/environment-data-sources/foxy.ts b/src/shared/environment-data-sources/foxy.ts index 3f2f74ef..78155000 100644 --- a/src/shared/environment-data-sources/foxy.ts +++ b/src/shared/environment-data-sources/foxy.ts @@ -27,7 +27,7 @@ const foxyDataSource = () => { city: "N/A", state: "N/A", country: "N/A", - couponCode: transaction.coupon || "N/A", + couponCode: transaction?.coupon || "N/A", discount: 0, currency: "USD", items: products.map((product) => { diff --git a/src/shared/environment-data-sources/tymber.ts b/src/shared/environment-data-sources/tymber.ts index e32cb14a..d77d619d 100644 --- a/src/shared/environment-data-sources/tymber.ts +++ b/src/shared/environment-data-sources/tymber.ts @@ -46,7 +46,7 @@ const tymberDataSource = () => { try { const transaction = data.ecommerce.actionField; const products = data.ecommerce.products; - const { id, revenue, tax } = transaction; + const { id, revenue, tax, coupon } = transaction; observable.notify({ transactionEvent: { @@ -55,6 +55,8 @@ const tymberDataSource = () => { tax: parseFloat(tax), shipping: 0, city: "N/A", + couponCode: coupon || "N/A", + discount: 0, state: "N/A", country: "N/A", currency: "USD", diff --git a/src/shared/utils/get-context.ts b/src/shared/utils/get-context.ts index 61dbb0da..1932f1ba 100644 --- a/src/shared/utils/get-context.ts +++ b/src/shared/utils/get-context.ts @@ -17,7 +17,7 @@ const getContext = (): QueryStringContext => { return { appId: appId || mediajelAppId, // Legacy support for old universal tag version: version || "1", // tracker version - environment: params.environment || "production", + environment: params.environment || "thirdparty", collector: params.test ? process.env.MJ_STAGING_COLLECTOR_URL : process.env.MJ_PRODUCTION_COLLECTOR_URL, // Regex mainly used to remove the "&" and the '\\"' from the outerHTML tag: target.outerHTML.replace(/&/g, "&").replace(/\\"/g, '"'), diff --git a/yarn.lock b/yarn.lock index 572f419c..b65b8108 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6375,10 +6375,10 @@ typescript@^4.5.4: resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz" integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== -typescript@^5.6.3: - version "5.6.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b" - integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw== +typescript@^5.9.3: + version "5.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" + integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== uc.micro@^2.0.0, uc.micro@^2.1.0: version "2.1.0"