eddev 0.2.18 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,16 @@
1
1
  import { z } from "zod";
2
2
  export declare const EDConfigSchema: z.ZodObject<{
3
3
  $schema: z.ZodOptional<z.ZodString>;
4
+ tracking: z.ZodOptional<z.ZodObject<{
5
+ tagManagerID: z.ZodOptional<z.ZodString>;
6
+ analyticsID: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ tagManagerID?: string | undefined;
9
+ analyticsID?: string | undefined;
10
+ }, {
11
+ tagManagerID?: string | undefined;
12
+ analyticsID?: string | undefined;
13
+ }>>;
4
14
  serverless: z.ZodOptional<z.ZodObject<{
5
15
  enabled: z.ZodBoolean;
6
16
  uploads: z.ZodEnum<["proxy", "remote"]>;
@@ -45,6 +55,10 @@ export declare const EDConfigSchema: z.ZodObject<{
45
55
  devUI: z.ZodEnum<["disabled", "enabled"]>;
46
56
  }, "strip", z.ZodTypeAny, {
47
57
  $schema?: string | undefined;
58
+ tracking?: {
59
+ tagManagerID?: string | undefined;
60
+ analyticsID?: string | undefined;
61
+ } | undefined;
48
62
  serverless?: {
49
63
  themeAssets?: string[] | undefined;
50
64
  apiOnly?: boolean | undefined;
@@ -63,6 +77,10 @@ export declare const EDConfigSchema: z.ZodObject<{
63
77
  devUI: "disabled" | "enabled";
64
78
  }, {
65
79
  $schema?: string | undefined;
80
+ tracking?: {
81
+ tagManagerID?: string | undefined;
82
+ analyticsID?: string | undefined;
83
+ } | undefined;
66
84
  serverless?: {
67
85
  themeAssets?: string[] | undefined;
68
86
  apiOnly?: boolean | undefined;
@@ -4,6 +4,12 @@ exports.EDConfigSchema = void 0;
4
4
  var zod_1 = require("zod");
5
5
  exports.EDConfigSchema = zod_1.z.object({
6
6
  $schema: zod_1.z.string().optional(),
7
+ tracking: zod_1.z
8
+ .object({
9
+ tagManagerID: zod_1.z.string().optional(),
10
+ analyticsID: zod_1.z.string().optional(),
11
+ })
12
+ .optional(),
7
13
  serverless: zod_1.z
8
14
  .object({
9
15
  enabled: zod_1.z.boolean(),
@@ -1,5 +1,9 @@
1
1
  export declare function getEDConfig(dir?: string): import("zod").SafeParseReturnType<{
2
2
  $schema?: string | undefined;
3
+ tracking?: {
4
+ tagManagerID?: string | undefined;
5
+ analyticsID?: string | undefined;
6
+ } | undefined;
3
7
  serverless?: {
4
8
  themeAssets?: string[] | undefined;
5
9
  apiOnly?: boolean | undefined;
@@ -18,6 +22,10 @@ export declare function getEDConfig(dir?: string): import("zod").SafeParseReturn
18
22
  devUI: "disabled" | "enabled";
19
23
  }, {
20
24
  $schema?: string | undefined;
25
+ tracking?: {
26
+ tagManagerID?: string | undefined;
27
+ analyticsID?: string | undefined;
28
+ } | undefined;
21
29
  serverless?: {
22
30
  themeAssets?: string[] | undefined;
23
31
  apiOnly?: boolean | undefined;
@@ -37,6 +45,10 @@ export declare function getEDConfig(dir?: string): import("zod").SafeParseReturn
37
45
  }>;
38
46
  export declare function getEDConfigUnwrapped(dir?: string): {
39
47
  $schema?: string | undefined;
48
+ tracking?: {
49
+ tagManagerID?: string | undefined;
50
+ analyticsID?: string | undefined;
51
+ } | undefined;
40
52
  serverless?: {
41
53
  themeAssets?: string[] | undefined;
42
54
  apiOnly?: boolean | undefined;
@@ -1,5 +1,9 @@
1
1
  export declare function parseConfig(config: any): import("zod").SafeParseReturnType<{
2
2
  $schema?: string | undefined;
3
+ tracking?: {
4
+ tagManagerID?: string | undefined;
5
+ analyticsID?: string | undefined;
6
+ } | undefined;
3
7
  serverless?: {
4
8
  themeAssets?: string[] | undefined;
5
9
  apiOnly?: boolean | undefined;
@@ -18,6 +22,10 @@ export declare function parseConfig(config: any): import("zod").SafeParseReturnT
18
22
  devUI: "disabled" | "enabled";
19
23
  }, {
20
24
  $schema?: string | undefined;
25
+ tracking?: {
26
+ tagManagerID?: string | undefined;
27
+ analyticsID?: string | undefined;
28
+ } | undefined;
21
29
  serverless?: {
22
30
  themeAssets?: string[] | undefined;
23
31
  apiOnly?: boolean | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "0.2.18",
3
+ "version": "0.2.21",
4
4
  "main": "./index.js",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,15 +1,57 @@
1
1
  import React from "react"
2
2
  import NextDocument, { Html, Head, Main, NextScript } from "next/document"
3
+ // @ts-ignore
3
4
  import { getCssText } from "@theme"
5
+ import Script from "next/script"
6
+ import settings from "_utils/ed-config"
4
7
 
5
8
  export default class Document extends NextDocument {
6
9
  render() {
10
+ console.log("GTM", settings.tracking?.tagManagerID)
7
11
  return (
8
12
  <Html lang="en">
9
13
  <Head>
10
14
  <style id="stitches" dangerouslySetInnerHTML={{ __html: getCssText() }} />
15
+ {settings.tracking?.tagManagerID ? (
16
+ <script
17
+ dangerouslySetInnerHTML={{
18
+ __html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
19
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
20
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
21
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
22
+ })(window,document,'script','dataLayer',${JSON.stringify(settings.tracking.tagManagerID)});`,
23
+ }}
24
+ ></script>
25
+ ) : null}
26
+ {settings.tracking?.analyticsID ? (
27
+ <>
28
+ <script
29
+ async
30
+ src={`https://www.googletagmanager.com/gtag/js?id={settings.tracking.analyticsID}`}
31
+ ></script>
32
+ <script
33
+ dangerouslySetInnerHTML={{
34
+ __html: `
35
+ window.dataLayer = window.dataLayer || [];
36
+ function gtag(){dataLayer.push(arguments);}
37
+ gtag('js', new Date());
38
+
39
+ gtag('config', "${settings.tracking.analyticsID}");
40
+ `,
41
+ }}
42
+ />
43
+ </>
44
+ ) : null}
11
45
  </Head>
12
46
  <body>
47
+ {settings.tracking?.tagManagerID ? (
48
+ <noscript
49
+ dangerouslySetInnerHTML={{
50
+ __html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${settings.tracking.tagManagerID}"
51
+ height="0" width="0" style="display:none;visibility:hidden"></iframe>`,
52
+ }}
53
+ ></noscript>
54
+ ) : null}
13
55
  <Main />
14
56
  <NextScript />
15
57
  </body>
@@ -4,7 +4,7 @@ import { fetchWP } from "../../../_utils/fetch-wp"
4
4
  const validProxyPaths = {
5
5
  "form-submit": {
6
6
  path: "/wp-json/ed/v1/gf/submit",
7
- method: "GET",
7
+ method: "POST",
8
8
  },
9
9
  query: {
10
10
  path: "/wp-json/ed/v1/query/*",
@@ -35,6 +35,7 @@ export default async function (req: NextApiRequest, res: NextApiResponse) {
35
35
  headers: {
36
36
  "Content-Type": "application/json",
37
37
  },
38
+ body: proxyPath.method === "POST" ? JSON.stringify(req.body) : undefined,
38
39
  },
39
40
  async (response) => ({
40
41
  payload: await response.json(),