@amon-analytics/next 0.0.1 → 0.0.2

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.
package/dist/index.d.mts CHANGED
@@ -4,5 +4,11 @@ type Props = {
4
4
  publicApiKey: string;
5
5
  };
6
6
  declare function Amon({ publicApiKey }: Props): react_jsx_runtime.JSX.Element;
7
+ declare global {
8
+ interface Window {
9
+ __amonChatContainer?: HTMLElement | null;
10
+ }
11
+ }
12
+ declare function useAmonContainer<T extends HTMLElement = HTMLDivElement>(): (node: T | null) => void;
7
13
 
8
- export { Amon };
14
+ export { Amon, useAmonContainer };
package/dist/index.d.ts CHANGED
@@ -4,5 +4,11 @@ type Props = {
4
4
  publicApiKey: string;
5
5
  };
6
6
  declare function Amon({ publicApiKey }: Props): react_jsx_runtime.JSX.Element;
7
+ declare global {
8
+ interface Window {
9
+ __amonChatContainer?: HTMLElement | null;
10
+ }
11
+ }
12
+ declare function useAmonContainer<T extends HTMLElement = HTMLDivElement>(): (node: T | null) => void;
7
13
 
8
- export { Amon };
14
+ export { Amon, useAmonContainer };
package/dist/index.js CHANGED
@@ -31,10 +31,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/index.tsx
32
32
  var index_exports = {};
33
33
  __export(index_exports, {
34
- Amon: () => Amon
34
+ Amon: () => Amon,
35
+ useAmonContainer: () => useAmonContainer
35
36
  });
36
37
  module.exports = __toCommonJS(index_exports);
37
38
  var import_script = __toESM(require("next/script"));
39
+ var import_react = require("react");
38
40
  var import_jsx_runtime = require("react/jsx-runtime");
39
41
  function Amon({ publicApiKey }) {
40
42
  const gtmloader = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
@@ -71,8 +73,14 @@ function Amon({ publicApiKey }) {
71
73
  ) })
72
74
  ] });
73
75
  }
76
+ function useAmonContainer() {
77
+ return (0, import_react.useCallback)((node) => {
78
+ window.__amonChatContainer = node;
79
+ }, []);
80
+ }
74
81
  // Annotate the CommonJS export names for ESM import in node:
75
82
  0 && (module.exports = {
76
- Amon
83
+ Amon,
84
+ useAmonContainer
77
85
  });
78
86
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["// Official SDK file for Amon. Published to npm, and will be used by client apps. Not meant for public use.\r\n\r\n\"use client\";\r\n\r\nimport Script from \"next/script\";\r\n\r\ntype Props = {\r\n publicApiKey: string;\r\n}\r\n\r\nexport function Amon({ publicApiKey }: Props) {\r\n const gtmloader = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\r\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\r\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\r\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\r\n })(window,document,'script','dataLayer','GTM-K4SQR86R');`\r\n\r\n return (\r\n <>\r\n {/* Load GTM Script */}\r\n <Script\r\n id=\"amon\"\r\n strategy=\"afterInteractive\"\r\n dangerouslySetInnerHTML={{\r\n __html: gtmloader,\r\n }}\r\n />\r\n\r\n {/* Send api key to backend */}\r\n <script src=\"https://ai-analytics-7tka.onrender.com/gtmtracker.js\"\r\n public-api-key={publicApiKey}>\r\n </script>\r\n\r\n {/* Fallback when no script is allowed */}\r\n <noscript>\r\n <iframe\r\n src=\"https://www.googletagmanager.com/ns.html?id=GTM-K4SQR86R\"\r\n height=\"0\"\r\n width=\"0\"\r\n style={{ display: \"none\", visibility: \"hidden\" }}\r\n ></iframe>\r\n </noscript>\r\n </>\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAmB;AAcX;AARD,SAAS,KAAK,EAAE,aAAa,GAAU;AAC1C,QAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAMlB,SACI,4EAEI;AAAA;AAAA,MAAC,cAAAA;AAAA,MAAA;AAAA,QACG,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACrB,QAAQ;AAAA,QACZ;AAAA;AAAA,IACJ;AAAA,IAGA;AAAA,MAAC;AAAA;AAAA,QAAO,KAAI;AAAA,QACJ,kBAAgB;AAAA;AAAA,IACxB;AAAA,IAGA,4CAAC,cACG;AAAA,MAAC;AAAA;AAAA,QACG,KAAI;AAAA,QACJ,QAAO;AAAA,QACP,OAAM;AAAA,QACN,OAAO,EAAE,SAAS,QAAQ,YAAY,SAAS;AAAA;AAAA,IAClD,GACL;AAAA,KACJ;AAER;","names":["Script"]}
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["// Official SDK file for Amon. Published to npm, and will be used by client apps. Not meant for public use.\r\n\r\n\"use client\";\r\n\r\nimport Script from \"next/script\";\r\nimport { useCallback } from \"react\";\r\n\r\ntype Props = {\r\n publicApiKey: string;\r\n}\r\n\r\n// Processes all of the backend analytics\r\nexport function Amon({ publicApiKey }: Props) {\r\n const gtmloader = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\r\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\r\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\r\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\r\n })(window,document,'script','dataLayer','GTM-K4SQR86R');`\r\n\r\n return (\r\n <>\r\n {/* Load GTM Script */}\r\n <Script\r\n id=\"amon\"\r\n strategy=\"afterInteractive\"\r\n dangerouslySetInnerHTML={{\r\n __html: gtmloader,\r\n }}\r\n />\r\n\r\n {/* Send api key to backend */}\r\n <script src=\"https://ai-analytics-7tka.onrender.com/gtmtracker.js\"\r\n public-api-key={publicApiKey}>\r\n </script>\r\n\r\n {/* Fallback when no script is allowed */}\r\n <noscript>\r\n <iframe\r\n src=\"https://www.googletagmanager.com/ns.html?id=GTM-K4SQR86R\"\r\n height=\"0\"\r\n width=\"0\"\r\n style={{ display: \"none\", visibility: \"hidden\" }}\r\n ></iframe>\r\n </noscript>\r\n </>\r\n );\r\n}\r\n\r\n// Globally declares this hook so that it can be referenced literally anywhere (including the google tag tracker script)\r\ndeclare global {\r\n interface Window {\r\n __amonChatContainer?: HTMLElement | null;\r\n }\r\n}\r\n\r\n\r\n// Frontend analytics just on the container\r\nexport function useAmonContainer<T extends HTMLElement = HTMLDivElement>() {\r\n // Sets the global variable to this node whenever it changes (even if the node is initially null this still works)\r\n return useCallback((node: T | null) => {\r\n window.__amonChatContainer = node;\r\n }, []);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAmB;AACnB,mBAA4B;AAepB;AARD,SAAS,KAAK,EAAE,aAAa,GAAU;AAC1C,QAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAMlB,SACI,4EAEI;AAAA;AAAA,MAAC,cAAAA;AAAA,MAAA;AAAA,QACG,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACrB,QAAQ;AAAA,QACZ;AAAA;AAAA,IACJ;AAAA,IAGA;AAAA,MAAC;AAAA;AAAA,QAAO,KAAI;AAAA,QACJ,kBAAgB;AAAA;AAAA,IACxB;AAAA,IAGA,4CAAC,cACG;AAAA,MAAC;AAAA;AAAA,QACG,KAAI;AAAA,QACJ,QAAO;AAAA,QACP,OAAM;AAAA,QACN,OAAO,EAAE,SAAS,QAAQ,YAAY,SAAS;AAAA;AAAA,IAClD,GACL;AAAA,KACJ;AAER;AAWO,SAAS,mBAA2D;AAEvE,aAAO,0BAAY,CAAC,SAAmB;AACvC,WAAO,sBAAsB;AAAA,EAC7B,GAAG,CAAC,CAAC;AACT;","names":["Script"]}
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  // src/index.tsx
4
4
  import Script from "next/script";
5
+ import { useCallback } from "react";
5
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
7
  function Amon({ publicApiKey }) {
7
8
  const gtmloader = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
@@ -38,7 +39,13 @@ function Amon({ publicApiKey }) {
38
39
  ) })
39
40
  ] });
40
41
  }
42
+ function useAmonContainer() {
43
+ return useCallback((node) => {
44
+ window.__amonChatContainer = node;
45
+ }, []);
46
+ }
41
47
  export {
42
- Amon
48
+ Amon,
49
+ useAmonContainer
43
50
  };
44
51
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["// Official SDK file for Amon. Published to npm, and will be used by client apps. Not meant for public use.\r\n\r\n\"use client\";\r\n\r\nimport Script from \"next/script\";\r\n\r\ntype Props = {\r\n publicApiKey: string;\r\n}\r\n\r\nexport function Amon({ publicApiKey }: Props) {\r\n const gtmloader = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\r\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\r\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\r\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\r\n })(window,document,'script','dataLayer','GTM-K4SQR86R');`\r\n\r\n return (\r\n <>\r\n {/* Load GTM Script */}\r\n <Script\r\n id=\"amon\"\r\n strategy=\"afterInteractive\"\r\n dangerouslySetInnerHTML={{\r\n __html: gtmloader,\r\n }}\r\n />\r\n\r\n {/* Send api key to backend */}\r\n <script src=\"https://ai-analytics-7tka.onrender.com/gtmtracker.js\"\r\n public-api-key={publicApiKey}>\r\n </script>\r\n\r\n {/* Fallback when no script is allowed */}\r\n <noscript>\r\n <iframe\r\n src=\"https://www.googletagmanager.com/ns.html?id=GTM-K4SQR86R\"\r\n height=\"0\"\r\n width=\"0\"\r\n style={{ display: \"none\", visibility: \"hidden\" }}\r\n ></iframe>\r\n </noscript>\r\n </>\r\n );\r\n}\r\n"],"mappings":";;;AAIA,OAAO,YAAY;AAcX,mBAEI,KAFJ;AARD,SAAS,KAAK,EAAE,aAAa,GAAU;AAC1C,QAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAMlB,SACI,iCAEI;AAAA;AAAA,MAAC;AAAA;AAAA,QACG,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACrB,QAAQ;AAAA,QACZ;AAAA;AAAA,IACJ;AAAA,IAGA;AAAA,MAAC;AAAA;AAAA,QAAO,KAAI;AAAA,QACJ,kBAAgB;AAAA;AAAA,IACxB;AAAA,IAGA,oBAAC,cACG;AAAA,MAAC;AAAA;AAAA,QACG,KAAI;AAAA,QACJ,QAAO;AAAA,QACP,OAAM;AAAA,QACN,OAAO,EAAE,SAAS,QAAQ,YAAY,SAAS;AAAA;AAAA,IAClD,GACL;AAAA,KACJ;AAER;","names":[]}
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["// Official SDK file for Amon. Published to npm, and will be used by client apps. Not meant for public use.\r\n\r\n\"use client\";\r\n\r\nimport Script from \"next/script\";\r\nimport { useCallback } from \"react\";\r\n\r\ntype Props = {\r\n publicApiKey: string;\r\n}\r\n\r\n// Processes all of the backend analytics\r\nexport function Amon({ publicApiKey }: Props) {\r\n const gtmloader = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\r\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\r\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\r\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\r\n })(window,document,'script','dataLayer','GTM-K4SQR86R');`\r\n\r\n return (\r\n <>\r\n {/* Load GTM Script */}\r\n <Script\r\n id=\"amon\"\r\n strategy=\"afterInteractive\"\r\n dangerouslySetInnerHTML={{\r\n __html: gtmloader,\r\n }}\r\n />\r\n\r\n {/* Send api key to backend */}\r\n <script src=\"https://ai-analytics-7tka.onrender.com/gtmtracker.js\"\r\n public-api-key={publicApiKey}>\r\n </script>\r\n\r\n {/* Fallback when no script is allowed */}\r\n <noscript>\r\n <iframe\r\n src=\"https://www.googletagmanager.com/ns.html?id=GTM-K4SQR86R\"\r\n height=\"0\"\r\n width=\"0\"\r\n style={{ display: \"none\", visibility: \"hidden\" }}\r\n ></iframe>\r\n </noscript>\r\n </>\r\n );\r\n}\r\n\r\n// Globally declares this hook so that it can be referenced literally anywhere (including the google tag tracker script)\r\ndeclare global {\r\n interface Window {\r\n __amonChatContainer?: HTMLElement | null;\r\n }\r\n}\r\n\r\n\r\n// Frontend analytics just on the container\r\nexport function useAmonContainer<T extends HTMLElement = HTMLDivElement>() {\r\n // Sets the global variable to this node whenever it changes (even if the node is initially null this still works)\r\n return useCallback((node: T | null) => {\r\n window.__amonChatContainer = node;\r\n }, []);\r\n}\r\n"],"mappings":";;;AAIA,OAAO,YAAY;AACnB,SAAS,mBAAmB;AAepB,mBAEI,KAFJ;AARD,SAAS,KAAK,EAAE,aAAa,GAAU;AAC1C,QAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAMlB,SACI,iCAEI;AAAA;AAAA,MAAC;AAAA;AAAA,QACG,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB;AAAA,UACrB,QAAQ;AAAA,QACZ;AAAA;AAAA,IACJ;AAAA,IAGA;AAAA,MAAC;AAAA;AAAA,QAAO,KAAI;AAAA,QACJ,kBAAgB;AAAA;AAAA,IACxB;AAAA,IAGA,oBAAC,cACG;AAAA,MAAC;AAAA;AAAA,QACG,KAAI;AAAA,QACJ,QAAO;AAAA,QACP,OAAM;AAAA,QACN,OAAO,EAAE,SAAS,QAAQ,YAAY,SAAS;AAAA;AAAA,IAClD,GACL;AAAA,KACJ;AAER;AAWO,SAAS,mBAA2D;AAEvE,SAAO,YAAY,CAAC,SAAmB;AACvC,WAAO,sBAAsB;AAAA,EAC7B,GAAG,CAAC,CAAC;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amon-analytics/next",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [