1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[172],{54170:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/docs",function(){return t(83348)}])},29906:function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},s=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),s.forEach((function(n){r(e,n,t[n])}))}return e}n.default=function(e,n){var t=a.default,r={loading:function(e){e.error,e.isLoading;return e.pastDelay,null}};i=e,o=Promise,(null!=o&&"undefined"!==typeof Symbol&&o[Symbol.hasInstance]?o[Symbol.hasInstance](i):i instanceof o)?r.loader=function(){return e}:"function"===typeof e?r.loader=e:"object"===typeof e&&(r=s({},r,e));var i,o;var c=r=s({},r,n);if(c.suspense)throw new Error("Invalid suspense option usage in next/dynamic. Read more: https://nextjs.org/docs/messages/invalid-dynamic-suspense");if(c.suspense)return t(c);r.loadableGenerated&&delete(r=s({},r,r.loadableGenerated)).loadableGenerated;if("boolean"===typeof r.ssr){if(!r.ssr)return delete r.ssr,l(t,r);delete r.ssr}return t(r)};i(t(27378));var a=i(t(62456));function i(e){return e&&e.__esModule?e:{default:e}}function l(e,n){return delete n.webpack,delete n.modules,e(n)}},37815:function(e,n,t){"use strict";var r;Object.defineProperty(n,"__esModule",{value:!0}),n.LoadableContext=void 0;var s=((r=t(27378))&&r.__esModule?r:{default:r}).default.createContext(null);n.LoadableContext=s},62456:function(e,n,t){"use strict";function r(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){s(e,n,t[n])}))}return e}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var i,l=(i=t(27378))&&i.__esModule?i:{default:i},o=t(23247),c=t(37815);var d=[],u=[],h=!1;function f(e){var n=e(),t={loading:!0,loaded:null,error:null};return t.promise=n.then((function(e){return t.loading=!1,t.loaded=e,e})).catch((function(e){throw t.loading=!1,t.error=e,e})),t}var p=function(){function e(n,t){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this._loadFn=n,this._opts=t,this._callbacks=new Set,this._delay=null,this._timeout=null,this.retry()}var n,t,s;return n=e,(t=[{key:"promise",value:function(){return this._res.promise}},{key:"retry",value:function(){var e=this;this._clearTimeouts(),this._res=this._loadFn(this._opts.loader),this._state={pastDelay:!1,timedOut:!1};var n=this._res,t=this._opts;if(n.loading){if("number"===typeof t.delay)if(0===t.delay)this._state.pastDelay=!0;else{var r=this;this._delay=setTimeout((function(){r._update({pastDelay:!0})}),t.delay)}if("number"===typeof t.timeout){var s=this;this._timeout=setTimeout((function(){s._update({timedOut:!0})}),t.timeout)}}this._res.promise.then((function(){e._update({}),e._clearTimeouts()})).catch((function(n){e._update({}),e._clearTimeouts()})),this._update({})}},{key:"_update",value:function(e){this._state=a({},this._state,{error:this._res.error,loaded:this._res.loaded,loading:this._res.loading},e),this._callbacks.forEach((function(e){return e()}))}},{key:"_clearTimeouts",value:function(){clearTimeout(this._delay),clearTimeout(this._timeout)}},{key:"getCurrentValue",value:function(){return this._state}},{key:"subscribe",value:function(e){var n=this;return this._callbacks.add(e),function(){n._callbacks.delete(e)}}}])&&r(n.prototype,t),s&&r(n,s),e}();function m(e){return function(e,n){var t=function(){if(!s){var n=new p(e,r);s={getCurrentValue:n.getCurrentValue.bind(n),subscribe:n.subscribe.bind(n),retry:n.retry.bind(n),promise:n.promise.bind(n)}}return s.promise()},r=Object.assign({loader:null,loading:null,delay:200,timeout:null,webpack:null,modules:null,suspense:!1},n);r.suspense&&(r.lazy=l.default.lazy(r.loader));var s=null;if(!h&&!r.suspense){var i=r.webpack?r.webpack():r.modules;i&&u.push((function(e){var n=!0,r=!1,s=void 0;try{for(var a,l=i[Symbol.iterator]();!(n=(a=l.next()).done);
1n=!0){var o=a.value;if(-1!==e.indexOf(o))return t()}}catch(c){r=!0,s=c}finally{try{n||null==l.return||l.return()}finally{if(r)throw s}}}))}var d=r.suspense?function(e,n){return l.default.createElement(r.lazy,a({},e,{ref:n}))}:function(e,n){t();var a=l.default.useContext(c.LoadableContext),i=o.useSubscription(s);return l.default.useImperativeHandle(n,(function(){return{retry:s.retry}}),[]),a&&Array.isArray(r.modules)&&r.modules.forEach((function(e){a(e)})),l.default.useMemo((function(){return i.loading||i.error?l.default.createElement(r.loading,{isLoading:i.loading,pastDelay:i.pastDelay,timedOut:i.timedOut,error:i.error,retry:s.retry}):i.loaded?l.default.createElement(function(e){return e&&e.__esModule?e.default:e}(i.loaded),e):null}),[e,i])};return d.preload=function(){return!r.suspense&&t()},d.displayName="LoadableComponent",l.default.forwardRef(d)}(f,e)}function x(e,n){for(var t=[];e.length;){var r=e.pop();t.push(r(n))}return Promise.all(t).then((function(){if(e.length)return x(e,n)}))}m.preloadAll=function(){return new Promise((function(e,n){x(d).then(e,n)}))},m.preloadReady=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return new Promise((function(n){var t=function(){return h=!0,n()};x(u,e).then(t,t)}))},window.__NEXT_PRELOADREADY=m.preloadReady;var j=m;n.default=j},10207:function(e,n,t){"use strict";t.d(n,{E:function(){return a}});var r=t(24246),s=(0,t(65218).default)((function(){return Promise.all([t.e(723),t.e(517)]).then(t.bind(t,56517)).then((function(e){return e.CodeSync}))}),{loadableGenerated:{webpack:function(){return[56517]}},loading:function(){return(0,r.jsx)("pre",{children:(0,r.jsx)("code",{children:"Loading..."})})}});function a(e){var n=e.language,t=e.children,a=e.className;return(0,r.jsx)(s,{language:n,className:a,children:t})}},79071:function(e,n,t){"use strict";t.d(n,{$:function(){return o}});var r=t(24246),s=t(60042),a=t.n(s),i=t(83435),l=t.n(i);function o(e){return(0,r.jsxs)("footer",{className:a()("flex flex-wrap items-center justify-center text-sm h-24 bg-slate-800 text-gray-300 px-6",l().contentEvenly),children:[(0,r.jsx)("a",{href:"/terms",className:"text-gray-300 hover:text-white",children:"Terms and Conditions"}),(0,r.jsx)("div",{className:"mx-2",children:"|"}),(0,r.jsx)("a",{href:"/privacy",className:"text-gray-300 hover:text-white",children:"Privacy Policy"}),(0,r.jsx)("div",{className:"mx-2",children:"|"}),(0,r.jsx)("a",{href:"/what-data-we-collect",className:"text-gray-300 hover:text-white",children:"What Data We Collect"}),(0,r.jsx)("div",{className:"mx-2",children:"|"}),(0,r.jsx)("a",{href:"/about",className:"text-gray-300 hover:text-white",children:"About Us"}),(0,r.jsx)("div",{className:"mx-2",children:"|"}),(0,r.jsx)("a",{href:"mailto:[email protected]",className:"text-gray-300 hover:text-white",children:"Contact Us"})]})}},81405:function(e,n,t){"use strict";t.d(n,{h:function(){return x}});var r=t(24246),s=t(8054),a=t(87100),i=t(11626),l=t(62730),o=t(60042),c=t.n(o);function d(e){return(0,r.jsx)("div",{className:c()("mx-2 border-b border-gray-600",e.className)})}var u=t(30589),h=t(9582),f=t(77804),p=t.n(f);function m(e){var n=e.href,t=e.blank,s=e.children,i=e.className,l=void 0===i?"":i,o=e.onClick,d=e.buttonStyle,u=void 0===d?"unstyled":d;return(0,r.jsx)(a.Link,{href:n,style:u,target:t?"_blank":void 0,className:c()("block font-semibold",p().headerLink,l),onClick:o,children:s})}function x(e){var n=e.transparent,t=(0,h.aC)();return(0,r.jsxs)(l.Row,{align:"space-between",valign:"center",className:c()("h-24 px-6 md:px-20 w-full absolute",n?"text-white":"bg-website text-gray-800"),children:[(0,r.jsx)(m,{href:"/",className:c()("text-xl font-bold mr-6",n?"hover:text-gray-300":"hover:text-gray-600"),children:"Insights"}),(0,r.jsxs)(l.Row,{valign:"center",className:"hidden md:flex",children:[!t.user&&(0,r.jsx)(m,{href:"/features",className:c()("mr-6",n?"hover:text-gray-300":"hover:text-gray-600"),children:"Features"}),!t.user&&(0,r.jsx)(m,{href:"/#pricing",className:c()("mr-6",n?"hover:text-gray-300":"hover:text-gray-600"),children:"Pricing"}),t.user&&(0,r.jsx)("div",{className:c()("mr-6 block font-semibold cursor-pointer",n?"hover:text-gray-300":"hover:text-red-600"),onClick:t.signOut,children:"Sign Out"}),t.user&&(0,r.jsx)(m,{href:"/billing",className:c()("hidden md:block mr-6",n?"hover:text-gray-300":"hover:text-gray-600"),children:"Billing"}),(0,r.jsx)(m,{href:"/docs",className:c()("mr-6",n?"hover:text-gray-300":"hover:text-gray-600"),children:"Docs"}),(0,r.jsx)(m,{href:"/blog",className:c()("mr-6",n?"hover:text-gray-300":"hover:text-gray-600"),children:"Blog"}),!t.user&&(0,r.jsx)(m,{href:"/signin",onClick:function(){(0,u.p_)("header-signup")},className:c()("mr-6",n?"hover:text-gray-300":"hover:text-gray-600"),children:"Sign In"}),!t.user&&(0,r.jsx)(m,{href:"/signup",onClick:function(){(0,u.p_)("header-signup")},buttonStyle:"primary",children:"Get Started"}),t.user&&(0,r.jsx)(m,{href:"/dashboard",className:n?"hover:text-gray-300":"hover:text-gray-600",children:"Dashboard"})]}),(0,r.jsxs)(l.Row,{valign:"center",className:"flex md:hidden",children:[!t.user&&(0,r.jsxs)(s.h,{label:"Menu",className:"block md:hidden",right:!0,children:[(0,r.jsx)(i.s,{label:"Features",href:"/features"}),(0,r.jsx)(i.s,{label:"Pricing",href:"/#pricing"}),(0,r.jsx)(i.s,{label:"Docs",href:"/docs"}),(0,r.jsx)(i.s,{label:"Sign In",href:"/signin"}),(0,r.jsx)(d,{}),(0,r.jsx)(i.s,{label:"Get Started",href:"/signup"})]}),t.user&&(0,r.jsxs)(s.h,{label:"Menu",right:!0,children:[(0,r.jsx)(i.s,{label:t.user.email}),(0,r.jsx)(d,{}),(0,r.jsx)(i.s,{className:"show-sm",label:"Billing",href:"/billing"}),(0,r.jsx)(i.s,{className:"show-sm",label:"Docs",href:"/docs"}),(0,r.jsx)(i.s,{className:"show-sm",label:"Dashboard",href:"/dashboard"}),(0,r.jsx)(d,{className:"show-sm"}),(0,r.jsx)(i.s,{label:"Sign Out",onClick:t.signOut})]})]})]})}},47281:function(e,n,t){"use strict";t.d(n,{A:function(){return f}});var r=t(24246),s=t(88038),a=t(7325),i=t(56343),l=t(54697),o=t(60042),c=t.n(o),d=t(79071),u=t(81405),h=t(43218);function f(e){var n=e.title,t=e._100vh,o=e.noIndex,f=e.smallFooter,p=e.children,m=e.transparentHeader;return(0,r.jsxs)("div",{children:[(0,r.jsxs)(s.default,{children:[(0,r.jsx)("title",{children:n}),(0,r.jsx)("meta",{charSet:"utf-8"}),(0,r.jsx)("meta",{name:"viewport",content:"initial-scale=1.0, width=device-width"}),(0,r.jsx)("meta",{name:"description",content:"Insights is the next level of privacy-focused web analytics. We provide full event, page views, and user journeys tracking while respecting your user's privacy."}),(0,r.jsx)("meta",{property:"og:title",content:n}),(0,r.jsx)("meta",{property:"og:image",content:"/static/images/page-views-small.png"}),(0,r.jsx)("meta",{property:"og:site_name",content:"GetInsights.io"}),o&&(0,r.jsx)("meta",{name:"robots",content:"noindex"}),(0,r.jsx)("link",{rel:"shortcut icon",type:"image/png",href:"/images/favicon.svg"})]}),(0,r.jsx)(h.default,{src:"https://js.stripe.com/v3/"}),(0,r.jsxs)(a.Column,{className:"min-h-screen ".concat(t?"h-screen":""),children:[(0,r.jsx)(i.F,{}),(0,r.jsx)(u.h,{transparent:m}),(0,r.jsx)(a.Column,{className:c()("flex-grow",!m&&"mt-24"),children:p}),(0,r.jsx)(d.$,{large:!f}),(0,r.jsx)(l.T,{})]})]})}},83348:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return C}});var r=t(24246),s=t(47281),a=t(52786),i=t(63392),l=t(31910),o=t(62730),c=t(10207),d=t(27378);function u(e,n,t,r){var s=0,a=!1,i=setInterval((function(){!function(){var n=document.getElementById(e);if(!n)return!1;var t=n.getBoundingClientRect().top,r=-.2*window.outerHeight,s=.4*window.outerHeight;return t>=r&&t<=s}()?s=0:++s>=(r||2)&&!a&&(clearInterval(i),a=!0,n())}),t||800);return{cancel:function(){a||(clearInterval(i),a=!1)}}}var h=t(30589);function f(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function p(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function x(e,n){return!n||"object"!==g(n)&&"function"!==typeof n?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):n}
1function j(e,n){return j=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},j(e,n)}var g=function(e){return e&&"undefined"!==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};function v(e){var n=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var t,r=m(e);if(n){var s=m(this).constructor;t=Reflect.construct(r,arguments,s)}else t=r.apply(this,arguments);return x(this,t)}}var y=function(e){!function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&j(e,n)}(i,e);var n,t,s,a=v(i);function i(){var e;return f(this,i),(e=a.apply(this,arguments)).cancel=function(){},e}return n=i,(t=[{key:"componentDidMount",value:function(){var e=this.props,n=e.simulated,t=e.eventId,r=e.parameter,s=e.elements,a=e.intervalMS,i=e.successCount,l=!1,o=s.map((function(e){return u(e.elementId,(function(){if(n)return console.log("[Simulated] Element id ".concat(e.elementId," is in view: ").concat(JSON.stringify({eventId:t,update:l,value:e.parameterValue}))),void(l=!0);var s,a,i;(0,h.j)({id:t,parameters:(s={},a=r,i=e.parameterValue,a in s?Object.defineProperty(s,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):s[a]=i,s),update:l,unique:!0}),l=!0}),a,i)}));this.cancel=function(){o.forEach((function(e){return e.cancel()}))}}},{key:"componentWillUnmount",value:function(){this.cancel()}},{key:"render",value:function(){return(0,r.jsx)(d.Fragment,{children:this.props.children})}}])&&p(n.prototype,t),s&&p(n,s),i}(d.Component);function b(){return(0,r.jsxs)(i.a,{ordered:!0,className:"list-decimal mt-2",children:[(0,r.jsxs)(l.H,{children:[(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline font-semibold text-lg",href:"#getting-started",children:"Getting Started"}),(0,r.jsxs)(i.a,{ordered:!0,className:"list-decimal pl-4 my-3",children:[(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#with-npm-or-yarn",children:"With npm or yarn"})}),(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#with-the-umd-build",children:"With the umd build"})})]})]}),(0,r.jsxs)(l.H,{children:[(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline font-semibold text-lg",href:"#guides",children:"Guides"}),(0,r.jsxs)(i.a,{ordered:!0,className:"list-decimal pl-4 my-3",children:[(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#tracking-simple-events",children:"Tracking simple events"})}),(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#custom-parameters",children:"Custom parameters"})}),(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#untracking-events",children:"Untracking events"})}),(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#tracking-page-views",children:"Tracking page views"})}),(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#tracking-on-multiple-projects",children:"Tracking on multiple projects"})})]})]}),(0,r.jsxs)(l.H,{children:[(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline font-semibold text-lg",href:"#api",children:"API"}),(0,r.jsxs)(i.a,{ordered:!0,className:"list-decimal pl-4 my-3",children:[(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#api-init",children:"init(projectId, options)"})}),(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#api-track-event",children:"track(event)"})}),(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#api-track-pages",children:"trackPage(options)"})}),(0,r.jsx)(l.H,{children:(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#api-parameters",children:"parameters"})})]})]})]})}function k(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"with-npm-or-yarn",children:"With npm or yarn"}),(0,r.jsx)("p",{children:"You can just install from npm or yarn, typescript definitions are included in the base package:"}),(0,r.jsx)(c.E,{language:"js",children:"npm install insights-js"}),(0,r.jsxs)("p",{children:["Then import as a ",(0,r.jsx)("code",{children:"commonjs"})," module:"]}),(0,r.jsx)(c.E,{language:"js",children:'const { init, track, parameters } = require("insights-js")'}),(0,r.jsxs)("p",{children:["Or as an ",(0,r.jsx)("code",{children:"es6"})," module:"]}),(0,r.jsx)(c.E,{language:"js",children:'import { init, track, parameters } from "insights-js"'}),(0,r.jsx)("p",{children:"And track something:"}),(0,r.jsx)(c.E,{language:"js",children:'// Initialize for your project, you can find this on your dashboard\ninit("XkJsfa5KasGf9W_8")\n\n// ...\n\n// track something\ntrack({\n id: "user-sub
1scribed",\n parameters: {\n plan: "Startup"\n }\n})'}),(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"with-the-umd-build",children:"With the umd build"}),(0,r.jsx)(c.E,{language:"html",children:'<script src="https://getinsights.io/js/insights.js"><\/script>\n\n<script>\n// Initialize for your project,\n// you can find this on your dashboard\ninsights.init("XkJsfa5KasGf9W_8")\n\n// ...\n\n// track page views\ninsights.trackPages()\n\n// track some other event\ninsights.track({\n id: "user-subcriptions",\n parameters: {\n plan: "Startup"\n }\n})\n<\/script>'})]})}function w(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4 squeeze",id:"tracking-simple-events",children:"Tracking simple events"}),(0,r.jsx)("div",{children:(0,r.jsx)(o.Row,{className:"md:flex-row",children:(0,r.jsxs)("div",{className:"flex-none w-full",children:[(0,r.jsxs)("p",{children:["Just call ",(0,r.jsx)("code",{children:"track()"})," (or ",(0,r.jsx)("code",{children:"insights.track()"})," if you are using the UMD build):"]}),(0,r.jsx)(c.E,{language:"js",children:'// Initialize for your project,\n// you can find this on your dashboard\ninit("XkJsfa5KasGf9W_8")\n\n// ...\n\ntrack({\n id: "user-registered",\n parameters: {\n method: "google",\n from: "front-page-link"\n }\n})'})]})})})]})}function N(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"custom-parameters",children:"Custom parameters"}),(0,r.jsx)("div",{children:(0,r.jsx)(o.Row,{className:"md:flex-row",children:(0,r.jsxs)("div",{className:"flex-none w-full",children:[(0,r.jsxs)("p",{children:["In addition to customer parameters, ",(0,r.jsx)("code",{children:"insights-js"})," ships with handy built-in parameters, to track values that are often useful, use as follow:"]}),(0,r.jsx)(c.E,{language:"js",children:'import { parameters } from "insights-js"\n\ntrack({\n id: "read-post",\n parameters: {\n // this will track the locale of the user, useful to know if we should translate our posts\n locale: parameters.locale(),\n // this will track the type of screen on which the user reads the post, useful for useability\n screenSize: parameters.screenType()\n }\n})'}),(0,r.jsxs)("p",{children:["See the full list"," ",(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#parameters",children:"in the API documentation"}),"."]})]})})})]})}function _(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"untracking-events",children:"Untracking events"}),(0,r.jsx)("p",{children:"Certain events last through time and may be undone or cancelled after they have been logged. For example, when tracking subscription to services or people."}),(0,r.jsx)("p",{children:"For these events, it is very useful to be able to know:"}),(0,r.jsxs)(i.a,{children:[(0,r.jsx)(l.H,{children:"When an event is tracked"}),(0,r.jsx)(l.H,{children:"When an event is marked as cancelled"}),(0,r.jsxs)(l.H,{children:["The current number of active (",(0,r.jsx)("code",{children:"tracked - cancelled"}),") events"]})]}),(0,r.jsxs)("p",{children:["When this flag is set to ",(0,r.jsx)("code",{children:"true"}),", the given event is marked as cancelled:"]}),(0,r.jsx)("div",{children:(0,r.jsx)(o.Row,{className:"md:flex-row",children:(0,r.jsx)("div",{className:"flex-none w-full",children:(0,r.jsx)(c.E,{language:"js",children:'// A user just subscribed!\ntrack({\n id: "user-subscribed",\n parameters: {\n plan: "Startup",\n currency: "usd"\n }\n})\n\n// A user unsubscribed.\ntrack({\n id: "user-subscribed",\n parameters: {\n plan: "Startup",\n currency: "usd"\n },\n remove: true\n})'})})})})]})}function E(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"tracking-page-views",children:"Tracking page views"}),(0,r.jsx)("div",{children:(0,r.jsx)(o.Row,{className:"md:flex-row",children:(0,r.jsxs)("div",{className:"flex-none w-full",children:[(0,r.jsxs)("p",{children:[(0,r.jsx)("code",{children:"insights-js"})," provides an automated way of collecting page views, just call the",(0,r.jsx)("code",{children:"trackPages()"})," function:"]}),(0,r.jsx)(c.E,{language:"js",children:"trackPages()"}),(0,r.jsx)("p",{children:"This function tracks the current page then listen for URL changes and track any subsequent page views. You may configure its behaviour by passing an options object."})]})})})]})}function O(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"tracking-on-multiple-projects",children:"Tracking on multiple projects"}),(0,r.jsxs)("p",{children:["The calls to ",(0,r.jsx)("code",{children:"init()"})," and ",(0,r.jsx)("code",{children:"track()"})," are wrappers are methods on the ",(0,r.jsx)("code",{children:"App"})," ","class. You may instantiate any use one app per project - with or without the default App:"]}),(0,r.jsx)(c.E,{language:"js",children:'\x1cimport { App } from "insights-js"\n\n// equivalent to init("project-1-id")\nconst app1 = new App("project-1-id")\nconst app2 = new App("project-2-id")\n\n// will show up in project 1\'s dashboard\napp1.track({\n id: "user-registered",\n parameters: {\n method: "google",\n from: "top-link"\n }\n})\n\n// will show up in project 2\'s dashboard\napp2.track({\n id: "read-post",\n parameters: {\n // this will track the locale of the user, useful to know if we should translate our posts\n locale: parameters.locale(),\n // this will track the type of screen on which the user reads the post, useful for useability\n screenSize: parameters.screenType()\n }\n})\n'})]})}function H(e){var n=e.code,t=e.mandatory,s=e.defaultValue,a=e.children,i=e.optional;return(0,r.jsxs)("div",{className:"api-parameter my-3 leading-relaxed",children:[(0,r.jsx)("p",{children:(0,r.jsx)("code",{children:(0,r.jsx)("strong",{children:n})})}),t&&(0,r.jsx)("p",{children:(0,r.jsx)("em",{children:"Mandatory"})}),(i||s)&&(0,r.jsx)("p",{children:(0,r.jsx)("em",{children:"Optional"})}),s&&(0,r.jsx)("p",{children:(0,r.jsxs)("em",{children:["Default value: ",(0,r.jsx)("code",{children:s})]})}),(0,r.jsx)("div",{children:a})]})}function P(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"api-init",children:(0,r.jsx)("code",{children:"init(projectId, options)"})}),(0,r.jsx)(c.E,{language:"js",children:"init(projectId: string, options?: InitOptions): void"}),(0,r.jsx)(H,{code:"projectId: string",mandatory:!0,children:"The projectId to track this event with, you can find this in the page of your project."}),(0,r.jsx)(H,{code:"options?: AppOptions",defaultValue:"{}"}),(0,r.jsxs)(H,{code:"options.ignoreErrors: boolean",defaultValue:"false",children:["When set to ",(0,r.jsx)("code",{children:"true"})," any error that may occur when tracking events will be ignored. It is reccomended to set this flag to ",(0,r.jsx)("code",{children:"true"})," on production."]}),(0,r.jsxs)(H,{code:"options.disabled: boolean",defaultValue:"false",children:["When set to ",(0,r.jsx)("code",{children:"true"}),", all calls are disabled. This flag is useful to disable the tracking based on the environment or URL."]})]})}function S(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"api-track-event",children:(0,r.jsx)("code",{children:"track(event)"})}),(0,r.jsx)(c.E,{language:"js",children:"\x1ctrack(event: Event): Promise<void>"}),(0,r.jsx)(H,{code:"event: Event",mandatory:!0,children:"The event to track."}),(0,r.jsxs)(H,{code:"event.id: string",mandatory:!0,children:["The id of the event to track, should be a human readable id in ",(0,r.jsx)("code",{children:"kebab-case"}),"."]}),(0,r.jsxs)(H,{code:"event.parameters: { [key: string]: string }",defaultValue:"{}",children:["A map of ",(0,r.jsx)("code",{children:"(key: string) -> (value: string)"})," pairs. Insights keeps track of the number of events logged for each value. You may also use the ",(0,r.jsx)("code",{children:"parameters"})," variable to generate built-in values. See the full list"," ",(0,r.jsx)("a",{className:"text-sky-700 underline hover:no-underline",href:"#parameters",children:"in the parameters'API documentation"}),"."]}),(0,r.jsxs)(H,{code:"event.unique: boolean",defaultValue:"false",children:["When true, check if a similar event (i.e. same id & same parameters), has already been logged"," ",(0,r.jsx)("strong",{children:"with the unique flag"})," in this session. If a similar event has already been logged, it skips it."]}),(0,r.jsxs)(H,{code:"event.update: boolean",defaultValue:"false",children:["When true, does not update the count of the event itself, only update the parameters. ",(0,r.jsx)("br",{}),"Use this parameter when/if the value of some parameter(s) changes."]}),(0,r.jsxs)(H,{code:"event.remove: boolean",defaultValue:"false",children:[(0,r.jsx)("p",{children:"Certain events last through time and may be undone or cancelled after they have been logged. For example, when tracking subscription to services or people."}),(0,r.jsx)("p",{children:"For these events, it is very useful to be able to know:"}),(0,r.jsxs)(i.a,{ordered:!1,className:"pl-4 list-disc",children:[(0,r.jsx)(l.H,{children:"when an event is tracked"}),(0,r.jsx)(l.H,{children:"when an event is marked as cancelled"}),(0,r.jsxs)(l.H,{children:["the current number of active (",(0,r.jsx)("code",{children:"tracked - cancelled"}),") events."]})]}),(0,r.jsxs)("p",{children:["When this flag is set to ",(0,r.jsx)("code",{children:"true"}),", the given event is marked as cancelled."]})]}),(0,r.jsx)("p",{children:(0,r.jsx)("strong",{children:"Examples:"})}),(0,r.jsx)(c.E,{language:"js",children:'import { track, parameters } from "insights-js"\n\n// user signed up with their email/password\ntrack({\n id: "user-signed-up",\n parameters: {\n provider: "email"\n }\n})\n\n// user signed up with facebook\ntrack({\n id: "user-signed-up",\n parameters: {\n provider: "facebook"\n }\n})\n\n// a product was sold\ntrack({\n id: "product-sale",\n parameters: {\n product: product.name,\n currency: customer.currency\n }\n})\n\n// a page was opened\ntrack({\n id: "open-page",\n parameters: {\n path: parameters.path(),\n screenType: parameters.screenType(),\n referrer: parameters.referrer()\n }\n})\n'})]})}function I(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"api-track-pages",children:(0,r.jsx)("code",{children:"trackPage(options)"})}),(0,r.jsx)(c.E,{language:"js",children:"\x1dtrackPage(options?: TrackPageOptions): TrackPageResult"}),(0,r.jsxs)(H,{code:"options: TrackPagesOptions",defaultValue:"{}",children:[(0,r.jsx)("p",{children:"The options to configure the behaviour of the tracking, namely:"}),(0,r.jsxs)(i.a,{ordered:!1,className:"pl-4 list-disc",children:[(0,r.jsxs)(l.H,{children:["wether or not to track the hash portion of the URL (defaults to ",(0,r.jsx)("code",{children:"false"}),")"]}),(0,r.jsxs)(l.H,{children:["wether or not to track the search portion of the URL (defaults to ",(0,r.jsx)("code",{children:"false"}),")"]})]})]}),(0,r.jsxs)(H,{code:"options.hash: boolean",defaultValue:"false",children:[(0,r.jsx)("code",{children:"true"})," to also track the hash portion of the URL."]}),(0,r.jsxs)(H,{code:"options.search: boolean",defaultValue:"false",children:[(0,r.jsx)("code",{children:"true"})," to also track the search portion of the URL."]}),(0,r.jsxs)(H,{code:"returns",children:["An object of the form"," ",(0,r.jsxs)("code",{children:["{"," stop(): void ","}"]})," ","to cancel page tracking if needed."]})]})}function T(){return(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Heading,{level:"3",className:"my-4",id:"api-parameters",children:"Parameters"}),(0,r.jsxs)(H,{code:"parameters.locale()",children:["Gets the ",(0,r.jsx)("code",{children:"locale"})," of the current user, for example: ",(0,r.jsx)("code",{children:"en-US"}),", ",(0,r.jsx)("code",{children:"pt-BR"})," or",(0,r.jsx)("code",{children:"fr-FR"}),"."]}),(0,r.jsxs)(H,{code:"parameters.screenType()",children:[(0,r.jsx)("p",{children:"Gets the type of screen the user is currently on, possible return values:"}),(0,r.jsxs)(i.a,{ordered:!1,className:"pl-4 list-disc",children:[(0,r.jsxs)(l.H,{children:[(0,r.jsx)("code",{children:'"XS"'})," if ",(0,r.jsx)("code",{children:"screen width <= 414px"}),": Mobile phone"]}),(0,r.jsxs)(l.H,{children:[(0,r.jsx)("code",{children:'"S"'})," if ",(0,r.jsx)("code",{children:"screen width <= 800px"}),": Tablet"]}),(0,r.jsxs)(l.H,{children:[(0,r.jsx)("code",{children:'"M"'})," if ",(0,r.jsx)("code",{children:"screen width <= 1200px"}),": Small laptop"]}),(0,r.jsxs)(l.H,{children:[(0,r.jsx)("code",{children:'"L"'})," if ",(0,r.jsx)("code",{children:"screen width <= 1600px"}),": Large laptop / small desktop"]}),(0,r.jsxs)(l.H,{children:[(0,r.jsx)("code",{children:'"XL"'})," if ",(0,r.jsx)("code",{children:"screen width > 1600px"}),": Large desktop"]})]})]}),(0,r.jsxs)(H,{code:"parameters.referrer()",children:[(0,r.jsx)("p",{children:"Gets the referrer of the user."}),(0,r.jsxs)("p",{children:["For example ",(0,r.jsx)("code",{children:'"https://google.com"'})," if the user came from Google."]})]}),(0,r.jsx)(H,{code:"parameters.path(hash?: boolean, search?: boolean)",children:"Gets the current path (segment of the URL after the domain) of the user."}),(0,r.jsxs)(H,{code:"hash?: boolean",defaultValue:"false",children:["When ",(0,r.jsx)("code",{children:"true"}),", also returns the hash segment of the URL."]}),(0,r.jsxs)(H,{code:"search?: boolean",defaultValue:"false",children:["When ",(0,r.jsx)("code",{children:"true"}),", also returns the search segment of the URL."]})]})}function C(){return(0,r.jsxs)(s.A,{title:"Insights - Docs",children:[(0,r.jsx)(y,{eventId:"docs-page-scrolls",parameter:"section",elements:[{elementId:"getting-started",parameterValue:"1 - Getting Started"},{elementId:"guides",parameterValue:"2- Guides"},{elementId:"api",parameterValue:"3 - API"}]}),(0,r.jsxs)("div",{className:"max-w-full md:max-w-screen-md overflow-auto mx-auto text-left md:mt-12 px-6 mb-8",children:[(0,r.jsx)(a.Heading,{level:"1",className:"text-3xl md:text-5xl font-bold leading-tight text-left mb-4",unstyled:!0,children:"Documentation"}),(0,r.jsx)(b,{}),(0,r.jsx)(a.Heading,{level:"2",className:"my-5",id:"getting-started",children:"Getting Started"}),(0,r.jsx)(k,{}),(0,r.jsx)(a.Heading,{level:"2",className:"my-5",id:"guides",children:"Guides"}),(0,r.jsx)(w,{}),(0,r.jsx)(N,{}),(0,r.jsx)(_,{}),(0,r.jsx)(E,{}),(0,r.jsx)(O,{}),(0,r.jsx)(a.Heading,{level:"2",className:"my-5",id:"api",children:"API"}),(0,r.jsx)(P,{}),(0,r.jsx)(S,{}),(0,r.jsx)(I,{}),(0,r.jsx)(T,{})]})]})}},83435:function(e){e.exports={contentEvenly:"Footer_contentEvenly__4gMbu"}},77804:function(e){e.exports={headerLink:"Header_headerLink__t0A2S"}},65218:function(e,n,t){e.exports=t(29906)},43218:function(e,n,t){e.exports=t(17162)},63392:function(e,n,t){"use strict";var r=t(27378),s=t(60042);function a(e){return e&&"object"===typeof e&&"default"in e?e:{default:e}}var i=a(r),l=a(s);n.a=function(e){var n=e.ordered,t=e.style,r=e.children,s=l.default("",e.className);return n?i.default.createElement("ol",{className:s,style:t},r):i.default.createElement("ul",{className:s,style:t},r)}},31910:function(e,n,t){"use strict";var r=t(27378),s=t(60042);function a(e){return e&&"object"===typeof e&&"default"in e?e:{default:e}}var i=a(r),l=a(s);n.H=function(e){var n=e.children,t=l.default("mb-2 list-inside",e.className);return i.default.createElement("li",{className:t},n)}},56343:function(e,n,t){"use strict";t(89552),t(48536),t(85565);var r=t(27378);t(74230),t(88914),t(11814);var s=t(38943),a=t(64571);function i(e){return e&&"object"===typeof e&&"default"in e?e:{default:e}}var l=i(r);a.styleInject("@keyframes loadingbar {\n 0% {\n transform: translate(-100vw);\n }\n 100% {\n transform: translate(100vw);\n }\n}\n\n.loading-bar {\n color: transparent;\n min-height: 0.2rem;\n pointer-events: none;\n position: fixed;\n top: 0;\n left: 0;\n}\n\n.loading-bar .loading-bar-content {\n animation: loadingbar 2s infinite linear;\n height: 0.2rem;\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n margin: 0;\n width: 60vw;\n z-index: 10000;\n}\n"),n.F=function(e){var n=e.className,t=void 0===n?"bg-blue-600":n;
1return s.useLogger().loading?l.default.createElement("div",{className:"loading-bar"},l.default.createElement("div",{className:"loading-bar-content "+t})):l.default.createElement("div",null)}},54697:function(e,n,t){"use strict";t(89552),t(48536),t(85565);var r=t(27378);t(74230),t(88914),t(11814);var s=t(38943);t(60042);var a=t(64571),i=t(7325);function l(e){return e&&"object"===typeof e&&"default"in e?e:{default:e}}var o=l(r);function c(e){switch(e.type){case"error":return"bg-red-200 text-bold w-64 h-8 p-2";case"info":return"bg-green-200 text-bold w-64 h-8 p-2"}}function d(e){var n=e.notification;return o.default.createElement("div",{className:c(n)},n.text)}a.styleInject(".max-w-content {\n max-width: max-content;\n}\n\n.left-40 {\n left: 40%;\n}\n"),n.T=function(e){var n=s.useLogger();return o.default.createElement(i.Column,{align:"center",reverse:!0,className:"fixed bottom-0 left-40 max-w-content"},n.notifications.map((function(e,n){return o.default.createElement(d,{notification:e,key:n})})))}},37274:function(e,n,t){"use strict";var r=t(76493),s=t(27378);n.useSubscription=function(e){var n=e.getCurrentValue,t=e.subscribe,a=s.useState((function(){return{getCurrentValue:n,subscribe:t,value:n()}}));e=a[0];var i=a[1];return a=e.value,e.getCurrentValue===n&&e.subscribe===t||(a=n(),i({getCurrentValue:n,subscribe:t,value:a})),s.useDebugValue(a),s.useEffect((function(){function e(){if(!s){var e=n();i((function(s){return s.getCurrentValue!==n||s.subscribe!==t||s.value===e?s:r({},s,{value:e})}))}}var s=!1,a=t(e);return e(),function(){s=!0,a()}}),[n,t]),a}},23247:function(e,n,t){"use strict";e.exports=t(37274)}},function(e){e.O(0,[150,774,888,179],(function(){return n=54170,e(e.s=n);var n}));var n=e.O();_N_E=n}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.