Skip to content

Commit

Permalink
remove globalThis
Browse files Browse the repository at this point in the history
  • Loading branch information
guitavano committed Apr 15, 2024
1 parent 027b87e commit 0da8cd3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions commerce/sdk/sendAnalyticsEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { AnalyticsEvent } from "../types.ts";
export const sendAnalyticsEvent = <T extends AnalyticsEvent>(
event: T,
) => {
window.dataLayer && window.dataLayer.push({ ecommerce: null });
window.dataLayer && window.dataLayer.push({
globalThis.window.dataLayer &&
globalThis.window.dataLayer.push({ ecommerce: null });
globalThis.window.dataLayer && globalThis.window.dataLayer.push({
event: event.name,
ecommerce: event.params,
});
Expand Down
1 change: 0 additions & 1 deletion commerce/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ export interface Author extends Omit<Thing, "@type"> {

// TODO: fix this hack and use Product directly where it appears
// Hack to prevent type self referencing and we end up with an infinite loop
// deno-lint-ignore no-empty-interface
export interface ProductLeaf extends Omit<Product, "isVariantOf"> {}

export interface ProductGroup extends Omit<Thing, "@type"> {
Expand Down
6 changes: 3 additions & 3 deletions components/VTEXPortalDataLayerCompatibility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function addVTEXPortalDataSnippet(accountName: string) {
if (pageType === "productView") {
props.pageCategory = "Product";
props.pageDepartment = department?.name || null;
const product = window.datalayer_product || {};
const product = globalThis.window.datalayer_product || {};
Object.assign(props, product);
}

Expand Down Expand Up @@ -96,9 +96,9 @@ function addVTEXPortalDataSnippet(accountName: string) {
props.pageCategory = pathNames.pop() || null;
}

props.shelfProductIds = window.shelfProductIds || [];
props.shelfProductIds = globalThis.window.shelfProductIds || [];

window.dataLayer = window.dataLayer || [];
globalThis.window.dataLayer = globalThis.window.dataLayer || [];
// VTEX Default position is first...
window.dataLayer.unshift(props);
// But GTM handles .push function
Expand Down
2 changes: 1 addition & 1 deletion components/seo/components/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Telegram from "./Telegram.tsx";
import Google from "./Google.tsx";
import Twitter from "./Twitter.tsx";
import Slack from "./Slack.tsx";
import instructions from "./instructions.json" assert { type: "json" };
import instructions from "./instructions.json" with { type: "json" };
import type { PreviewItens, Props } from "../types.ts";

const tailwind = {
Expand Down
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { $live } from "deco/mod.ts";
import partytownPlugin from "partytown/mod.ts";
import manifest from "./live.gen.ts";
import plugins from "./plugins/mod.ts";
import site from "./site.json" assert { type: "json" };
import site from "./site.json" with { type: "json" };

// @ts-ignore this should work.
await start($live(manifest, site), {
Expand Down

0 comments on commit 0da8cd3

Please sign in to comment.