-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
173 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Markdown } from "../components/Markdown.tsx"; | ||
|
||
export { default } from "../../sourei/mod.ts"; | ||
|
||
export const Preview = await Markdown( | ||
new URL("../../sourei/README.md", import.meta.url).href, | ||
); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h1> | ||
<p align="center"> | ||
<a href="https://sourei.com.br/"> | ||
<img alt="Sourei" src="https://raw.githubusercontent.com/deco-cx/apps/main/sourei/logo.svg" width="250" /> | ||
</a> | ||
</p> | ||
</h1> | ||
|
||
<p align="center"> | ||
<strong> | ||
Sourei | ||
</strong> | ||
</p> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// DO NOT EDIT. This file is generated by deco. | ||
// This file SHOULD be checked into source version control. | ||
// This file is automatically updated during development when running `dev.ts`. | ||
|
||
import * as $$$$$$0 from "./sections/Analytics/Sourei.tsx"; | ||
|
||
const manifest = { | ||
"sections": { | ||
"sourei/sections/Analytics/Sourei.tsx": $$$$$$0, | ||
}, | ||
"name": "sourei", | ||
"baseUrl": import.meta.url, | ||
}; | ||
|
||
export type Manifest = typeof manifest; | ||
|
||
export default manifest; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { App } from "deco/mod.ts"; | ||
import manifest, { Manifest } from "./manifest.gen.ts"; | ||
|
||
/** | ||
* @title Sourei | ||
*/ | ||
export default function App() { | ||
const app: App<Manifest> = { manifest, state: {} }; | ||
|
||
return 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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Head } from "$fresh/runtime.ts"; | ||
import { scriptAsDataURI } from "../../../utils/dataURI.ts"; | ||
|
||
interface Props { | ||
/** | ||
* @title Hostname | ||
* @description e.g: https://ss.sourei.com | ||
* @default https://www.googletagmanager.com | ||
*/ | ||
hostname: string; | ||
/** | ||
* @title GTM ID | ||
* @description e.g: GTM-XXXXXXXX | ||
*/ | ||
gtmId: string; | ||
} | ||
|
||
const snippet = () => { | ||
window.dataLayer = window.dataLayer || []; | ||
window.dataLayer.push({ | ||
"gtm.start": new Date().getTime(), | ||
event: "gtm.js", | ||
}); | ||
|
||
window.DECO.events.subscribe((event) => { | ||
if (!event) return; | ||
|
||
if (event.name === "deco-flags") { | ||
window.dataLayer.push(event); | ||
return; | ||
} | ||
|
||
// deno-lint-ignore no-explicit-any | ||
const ecommerce: any = { ...event.params }; | ||
|
||
if (ecommerce && Array.isArray(ecommerce.items)) { | ||
ecommerce.items = ecommerce.items.map(( | ||
// deno-lint-ignore no-explicit-any | ||
{ item_id, item_group_id, item_url, ...rest }: any, | ||
) => | ||
item_group_id | ||
? ({ item_id: `${item_id}_${item_group_id}`, ...rest }) | ||
: ({ item_id, ...rest }) | ||
); | ||
} | ||
|
||
window.dataLayer.push({ ecommerce: null }); | ||
window.dataLayer.push({ event: event.name, ecommerce }); | ||
}); | ||
}; | ||
|
||
function Section({ | ||
gtmId, | ||
hostname = "https://www.googletagmanager.com", | ||
}: Props) { | ||
const src = new URL(`/gtm.js?id=${gtmId}`, hostname); | ||
const iframeSrc = new URL(`/ns.html?id=${gtmId}`, hostname); | ||
|
||
return ( | ||
<> | ||
{/* Head */} | ||
<Head> | ||
<script src={src.href} defer /> | ||
<script src={scriptAsDataURI(snippet)} defer /> | ||
</Head> | ||
|
||
{/* Body */} | ||
<noscript> | ||
<iframe | ||
src={iframeSrc.href} | ||
height="0" | ||
width="0" | ||
style="display:none;visibility:hidden" | ||
/> | ||
</noscript> | ||
</> | ||
); | ||
} | ||
|
||
export default Section; |