-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import from deco instead of live (#23)
* Import from deco instead of live Signed-off-by: Marcos Candeia <[email protected]> * Import analytics from deco-sites/std Signed-off-by: Marcos Candeia <[email protected]> --------- Signed-off-by: Marcos Candeia <[email protected]>
- Loading branch information
Showing
57 changed files
with
258 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export type { ConfigShopify as ShopifyAccount } from "https://denopkg.com/deco-sites/[email protected]/commerce/shopify/client.ts"; | ||
export type { Manifest as StdManifest } from "https://denopkg.com/deco-sites/[email protected]/live.gen.ts"; | ||
export type { Account as VNDAAccount } from "https://denopkg.com/deco-sites/[email protected]/packs/vnda/accounts/vnda.ts"; | ||
export type { Account as VTEXAccount } from "https://denopkg.com/deco-sites/[email protected]/packs/vtex/accounts/vtex.ts"; | ||
export { default as Analytics } from "https://denopkg.com/deco-sites/[email protected]/sections/Analytics.tsx"; | ||
export { default as VTEXCompat } from "https://denopkg.com/deco-sites/[email protected]/sections/VTEXPortalDataLayerCompatibility.tsx"; | ||
export type { ConfigShopify as ShopifyAccount } from "https://denopkg.com/deco-sites/[email protected]/commerce/shopify/client.ts"; | ||
export type { Manifest as StdManifest } from "https://denopkg.com/deco-sites/[email protected]/live.gen.ts"; | ||
export type { Account as VNDAAccount } from "https://denopkg.com/deco-sites/[email protected]/packs/vnda/accounts/vnda.ts"; | ||
export type { Account as VTEXAccount } from "https://denopkg.com/deco-sites/[email protected]/packs/vtex/accounts/vtex.ts"; | ||
export { default as VTEXCompat } from "https://denopkg.com/deco-sites/[email protected]/sections/VTEXPortalDataLayerCompatibility.tsx"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
// deno-lint-ignore-file no-explicit-any | ||
export { onBeforeResolveProps } from "../../website/mod.ts"; | ||
import { SourceMap } from "$live/blocks/app.ts"; | ||
import { buildSourceMap } from "$live/blocks/utils.tsx"; | ||
import type { App, AppManifest } from "$live/mod.ts"; | ||
import { SourceMap } from "deco/blocks/app.ts"; | ||
import { buildSourceMap } from "deco/blocks/utils.tsx"; | ||
import type { App, AppManifest } from "deco/mod.ts"; | ||
import type { PickByValue } from "https://esm.sh/[email protected]"; | ||
import $live from "../$live/mod.ts"; | ||
import commerce, { Props as CommerceProps } from "../../commerce/mod.ts"; | ||
import type { Manifest as ShopifyManifest } from "../../shopify/manifest.gen.ts"; | ||
import shopify, { Props as ShopifyProps } from "../../shopify/mod.ts"; | ||
import type { Manifest as VNDAManifest } from "../../vnda/manifest.gen.ts"; | ||
import vnda, { Props as VNDAProps } from "../../vnda/mod.ts"; | ||
import type { Manifest as VTEXManifest } from "../../vtex/manifest.gen.ts"; | ||
import vtex, { Props as VTEXProps } from "../../vtex/mod.ts"; | ||
import commerce, { Props as CommerceProps } from "../../commerce/mod.ts"; | ||
|
||
import type { Manifest as WebSiteManifest } from "../../website/manifest.gen.ts"; | ||
import type { | ||
|
@@ -31,32 +31,32 @@ export type ManifestWithStdCompat = | |
export type ManifestMappings = Partial< | ||
{ | ||
[ | ||
blockType in keyof Omit< | ||
StdManifest, | ||
"name" | "baseUrl" | "routes" | "islands" | ||
> | ||
blockType in keyof Omit< | ||
StdManifest, | ||
"name" | "baseUrl" | "routes" | "islands" | ||
> | ||
]: { | ||
[ | ||
blockKey in | ||
& Exclude< | ||
(keyof Omit< | ||
StdManifest, | ||
"name" | "baseUrl" | "routes" | "islands" | ||
>[blockType]), | ||
blockType extends keyof _Manifest ? keyof _Manifest[blockType] : "" | ||
> | ||
& `deco-sites/std/${string}` | ||
blockKey in | ||
& Exclude< | ||
(keyof Omit< | ||
StdManifest, | ||
"name" | "baseUrl" | "routes" | "islands" | ||
>[blockType]), | ||
blockType extends keyof _Manifest ? keyof _Manifest[blockType] : "" | ||
> | ||
& `deco-sites/std/${string}` | ||
]: blockType extends | ||
keyof (ShopifyManifest & VNDAManifest & VTEXManifest & WebSiteManifest) | ||
? | ||
| (keyof ( | ||
& ShopifyManifest | ||
& VNDAManifest | ||
& VTEXManifest | ||
& WebSiteManifest | ||
)[blockType]) | ||
| null | ||
: string; | ||
keyof (ShopifyManifest & VNDAManifest & VTEXManifest & WebSiteManifest) | ||
? | ||
| (keyof ( | ||
& ShopifyManifest | ||
& VNDAManifest | ||
& VTEXManifest | ||
& WebSiteManifest | ||
)[blockType]) | ||
| null | ||
: string; | ||
}; | ||
} | ||
>; | ||
|
@@ -106,6 +106,7 @@ const manifestMappings = { | |
"deco-sites/std/loaders/nuvemShop/nuvemShopProductList.ts": NOT_IMPLEMENTED, | ||
"deco-sites/std/loaders/nuvemShop/nuvemShopProductListingPage.ts": | ||
NOT_IMPLEMENTED, | ||
"deco-sites/std/loaders/vtex/legacy/suggestions.ts": "vtex/loaders/legacy/suggestions.ts", | ||
"deco-sites/std/loaders/vnda/cart.ts": "vnda/loaders/cart.ts", | ||
"deco-sites/std/loaders/vnda/productDetailsPage.ts": | ||
"vnda/loaders/productDetailsPage.ts", | ||
|
@@ -154,9 +155,9 @@ const manifestMappings = { | |
"deco-sites/std/actions/vnda/cart/addItem.ts": | ||
"vnda/actions/cart/addItem.ts", | ||
"deco-sites/std/actions/vnda/cart/setShippingAddress.ts": | ||
"vnda/actions/cart/setShippingAddress.ts", | ||
NOT_IMPLEMENTED, | ||
"deco-sites/std/actions/vnda/cart/updateCoupon.ts": | ||
"vnda/actions/cart/updateCoupon.ts", | ||
NOT_IMPLEMENTED, | ||
"deco-sites/std/actions/vnda/cart/updateItem.ts": | ||
"vnda/actions/cart/updateItem.ts", | ||
"deco-sites/std/actions/vtex/analytics/sendEvent.ts": | ||
|
@@ -198,17 +199,17 @@ const manifestMappings = { | |
type Mappings = typeof manifestMappings; | ||
type Manifest = { | ||
[key in keyof ManifestWithStdCompat]: key extends keyof Mappings ? { | ||
[ | ||
blockKey in keyof Omit< | ||
ManifestWithStdCompat[key], | ||
keyof PickByValue<Mappings[key], null> | ||
> | ||
]: Omit< | ||
ManifestWithStdCompat[key], | ||
keyof PickByValue<Mappings[key], null> | ||
>[blockKey]; | ||
} | ||
: ManifestWithStdCompat[key]; | ||
[ | ||
blockKey in keyof Omit< | ||
ManifestWithStdCompat[key], | ||
keyof PickByValue<Mappings[key], null> | ||
> | ||
]: Omit< | ||
ManifestWithStdCompat[key], | ||
keyof PickByValue<Mappings[key], null> | ||
>[blockKey]; | ||
} | ||
: ManifestWithStdCompat[key]; | ||
}; | ||
|
||
type AvailableCommerceProps = CommerceProps["commerce"]; | ||
|
@@ -311,7 +312,7 @@ export default function Std( | |
} | ||
for ( | ||
const [target, { sourceMap: appSourceMap, manifest: appManifest }] | ||
of Object.entries(targetApps) | ||
of Object.entries(targetApps) | ||
) { | ||
if (to?.startsWith(target)) { | ||
// @ts-ignore: blockkeys and from/to always exists for those types | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { forApp } from "$live/clients/withManifest.ts"; | ||
import { forApp } from "deco/clients/withManifest.ts"; | ||
import app from "./mod.ts"; | ||
|
||
export const Runtime = forApp<ReturnType<typeof app>>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,93 @@ | ||
export { Analytics as default } from "../deps.ts"; | ||
import { context } from "deco/live.ts"; | ||
import GoogleTagManager from "partytown/integrations/GTM.tsx"; | ||
import GoogleTagScript from "partytown/integrations/GTAG.tsx"; | ||
import Script from "partytown/Script.tsx"; | ||
import { AnalyticsEvent } from "../../../commerce/types.ts"; | ||
|
||
/** | ||
* This function handles all ecommerce analytics events. | ||
* Add another ecommerce analytics modules here. | ||
*/ | ||
const sendAnalyticsEvent = <T extends AnalyticsEvent>( | ||
event: T, | ||
) => { | ||
window.dataLayer && window.dataLayer.push({ ecommerce: null }); | ||
window.dataLayer && window.dataLayer.push({ | ||
event: event.name, | ||
ecommerce: event.params, | ||
}); | ||
|
||
window.jitsu && window.jitsu("track", "ecommerce", event); | ||
}; | ||
|
||
export interface Props { | ||
/** | ||
* @description google tag manager container id. For more info: https://developers.google.com/tag-platform/tag-manager/web#standard_web_page_installation . | ||
*/ | ||
trackingIds?: string[]; | ||
/** | ||
* @title GA Measurement Ids | ||
* @label measurement id | ||
* @description the google analytics property measurement id. For more info: https://support.google.com/analytics/answer/9539598 | ||
*/ | ||
googleAnalyticsIds?: string[]; | ||
/** | ||
* @description custom url for serving google tag manager. Set either this url or the tracking id | ||
*/ | ||
src?: string; | ||
/** | ||
* @description run GTM directly on the main thread, without Partytown. This is useful for debugging purposes. Default: false | ||
*/ | ||
dangerouslyRunOnMainThread?: boolean; | ||
} | ||
|
||
export default function Analtyics( | ||
{ trackingIds, src, dangerouslyRunOnMainThread, googleAnalyticsIds }: Props, | ||
) { | ||
const isDeploy = !!context.isDeploy; | ||
return ( | ||
<> | ||
{/* TODO: Add debug from query string @author Igor Brasileiro */} | ||
{/* Add Tag Manager script during production only. To test it locally remove the condition */} | ||
{isDeploy && trackingIds && ( | ||
trackingIds.map((trackingId) => ( | ||
<GoogleTagManager | ||
trackingId={trackingId.trim()} | ||
dangerouslyRunOnMainThread={dangerouslyRunOnMainThread} | ||
/> | ||
)) | ||
)} | ||
{isDeploy && googleAnalyticsIds && ( | ||
googleAnalyticsIds.map((trackingId) => ( | ||
<GoogleTagScript | ||
trackingId={trackingId.trim()} | ||
dangerouslyRunOnMainThread={dangerouslyRunOnMainThread} | ||
/> | ||
)) | ||
)} | ||
{isDeploy && src && ( | ||
<GoogleTagManager | ||
src={src} | ||
dangerouslyRunOnMainThread={dangerouslyRunOnMainThread} | ||
/> | ||
)} | ||
|
||
<Script | ||
dangerouslySetInnerHTML={{ | ||
// add all globals variables here | ||
__html: | ||
`debugGlobals = () => { console.table([["datalayer", dataLayer]]); }`, | ||
}} | ||
forward={["debugGlobals"]} | ||
/> | ||
<script | ||
type="module" | ||
id="analytics-script" | ||
dangerouslySetInnerHTML={{ | ||
__html: | ||
`window.DECO_SITES_STD = { sendAnalyticsEvent: ${sendAnalyticsEvent.toString()} }`, | ||
}} | ||
/> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default as HTMLRenderer } from "https://denopkg.com/deco-sites/std@1.20.11/components/HTMLRenderer.tsx"; | ||
export { default as HTMLRenderer } from "https://denopkg.com/deco-sites/std@1.21.7/components/HTMLRenderer.tsx"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"imports": { | ||
"$live/": "https://denopkg.com/deco-cx/[email protected]/", | ||
"$fresh/": "https://denopkg.com/denoland/[email protected]/", | ||
"preact": "https://esm.sh/[email protected]", | ||
"preact/": "https://esm.sh/[email protected]/", | ||
|
@@ -10,6 +9,7 @@ | |
"std/": "https://deno.land/[email protected]/", | ||
"partytown/": "https://deno.land/x/[email protected]/", | ||
"deco-sites/std/": "https://denopkg.com/deco-sites/[email protected]/", | ||
"deco/": "https://denopkg.com/deco-cx/[email protected]/" | ||
"deco/": "https://deno.land/x/[email protected]/", | ||
"$live/": "https://deno.land/x/[email protected]/" | ||
} | ||
} |
Oops, something went wrong.