Skip to content

Commit

Permalink
feat: Add Sourei app (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgimenes authored Nov 4, 2023
1 parent e439d2a commit 50e9bb3
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 8 deletions.
1 change: 1 addition & 0 deletions deco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const config = {
name: "deco-sites/admin",
},
app("analytics"),
app("sourei"),
app("typesense"),
app("algolia"),
app("handlebars"),
Expand Down
7 changes: 7 additions & 0 deletions decohub/apps/sourei.ts
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,
);
18 changes: 10 additions & 8 deletions decohub/manifest.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@ import * as $$$$$$$$$$$7 from "./apps/admin.ts";
import * as $$$$$$$$$$$8 from "./apps/linx.ts";
import * as $$$$$$$$$$$9 from "./apps/vtex.ts";
import * as $$$$$$$$$$$10 from "./apps/weather.ts";
import * as $$$$$$$$$$$11 from "./apps/shopify.ts";
import * as $$$$$$$$$$$12 from "./apps/handlebars.ts";
import * as $$$$$$$$$$$13 from "./apps/verified-reviews.ts";
import * as $$$$$$$$$$$14 from "./apps/power-reviews.ts";
import * as $$$$$$$$$$$11 from "./apps/sourei.ts";
import * as $$$$$$$$$$$12 from "./apps/shopify.ts";
import * as $$$$$$$$$$$13 from "./apps/handlebars.ts";
import * as $$$$$$$$$$$14 from "./apps/verified-reviews.ts";
import * as $$$$$$$$$$$15 from "./apps/power-reviews.ts";

const manifest = {
"apps": {
"decohub/apps/admin.ts": $$$$$$$$$$$7,
"decohub/apps/algolia.ts": $$$$$$$$$$$6,
"decohub/apps/analytics.ts": $$$$$$$$$$$2,
"decohub/apps/handlebars.ts": $$$$$$$$$$$12,
"decohub/apps/handlebars.ts": $$$$$$$$$$$13,
"decohub/apps/implementation.ts": $$$$$$$$$$$4,
"decohub/apps/linx.ts": $$$$$$$$$$$8,
"decohub/apps/power-reviews.ts": $$$$$$$$$$$14,
"decohub/apps/shopify.ts": $$$$$$$$$$$11,
"decohub/apps/power-reviews.ts": $$$$$$$$$$$15,
"decohub/apps/shopify.ts": $$$$$$$$$$$12,
"decohub/apps/sourei.ts": $$$$$$$$$$$11,
"decohub/apps/typesense.ts": $$$$$$$$$$$0,
"decohub/apps/verified-reviews.ts": $$$$$$$$$$$13,
"decohub/apps/verified-reviews.ts": $$$$$$$$$$$14,
"decohub/apps/vnda.ts": $$$$$$$$$$$5,
"decohub/apps/vtex.ts": $$$$$$$$$$$9,
"decohub/apps/wake.ts": $$$$$$$$$$$1,
Expand Down
14 changes: 14 additions & 0 deletions sourei/README.md
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>

33 changes: 33 additions & 0 deletions sourei/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions sourei/manifest.gen.ts
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;
11 changes: 11 additions & 0 deletions sourei/mod.ts
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;
}
80 changes: 80 additions & 0 deletions sourei/sections/Analytics/Sourei.tsx
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;

0 comments on commit 50e9bb3

Please sign in to comment.