@shware/analytics 16.3.4 → 16.3.5
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/next/index.cjs +2 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts.map +1 -1
- package/dist/next/index.d.mts.map +1 -1
- package/dist/next/index.mjs +2 -1
- package/dist/next/index.mjs.map +1 -1
- package/dist/third-parties/analytics-props.cjs +2 -1
- package/dist/third-parties/analytics-props.cjs.map +1 -1
- package/dist/third-parties/analytics-props.mjs +2 -1
- package/dist/third-parties/analytics-props.mjs.map +1 -1
- package/dist/third-parties/index.cjs +1 -0
- package/dist/third-parties/index.d.cts +2 -2
- package/dist/third-parties/index.d.mts +2 -2
- package/dist/third-parties/index.mjs +2 -2
- package/dist/third-parties/integration.cjs +31 -0
- package/dist/third-parties/integration.cjs.map +1 -1
- package/dist/third-parties/integration.d.cts +16 -0
- package/dist/third-parties/integration.d.cts.map +1 -1
- package/dist/third-parties/integration.d.mts +16 -0
- package/dist/third-parties/integration.d.mts.map +1 -1
- package/dist/third-parties/integration.mjs +29 -1
- package/dist/third-parties/integration.mjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.cjs +2 -2
- package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.mjs +2 -2
- package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
- package/dist/third-parties/meta-pixel.cjs +1 -2
- package/dist/third-parties/meta-pixel.cjs.map +1 -1
- package/dist/third-parties/meta-pixel.d.cts.map +1 -1
- package/dist/third-parties/meta-pixel.d.mts.map +1 -1
- package/dist/third-parties/meta-pixel.mjs +2 -3
- package/dist/third-parties/meta-pixel.mjs.map +1 -1
- package/dist/third-parties/microsoft-uet.cjs +2 -5
- package/dist/third-parties/microsoft-uet.cjs.map +1 -1
- package/dist/third-parties/microsoft-uet.d.cts.map +1 -1
- package/dist/third-parties/microsoft-uet.d.mts.map +1 -1
- package/dist/third-parties/microsoft-uet.mjs +3 -6
- package/dist/third-parties/microsoft-uet.mjs.map +1 -1
- package/dist/third-parties/openai-pixel.cjs +1 -2
- package/dist/third-parties/openai-pixel.cjs.map +1 -1
- package/dist/third-parties/openai-pixel.d.cts.map +1 -1
- package/dist/third-parties/openai-pixel.d.mts.map +1 -1
- package/dist/third-parties/openai-pixel.mjs +2 -3
- package/dist/third-parties/openai-pixel.mjs.map +1 -1
- package/dist/third-parties/posthog.cjs +2 -2
- package/dist/third-parties/posthog.cjs.map +1 -1
- package/dist/third-parties/posthog.d.cts.map +1 -1
- package/dist/third-parties/posthog.d.mts.map +1 -1
- package/dist/third-parties/posthog.mjs +2 -2
- package/dist/third-parties/posthog.mjs.map +1 -1
- package/dist/third-parties/reddit-pixel.cjs +1 -2
- package/dist/third-parties/reddit-pixel.cjs.map +1 -1
- package/dist/third-parties/reddit-pixel.d.cts.map +1 -1
- package/dist/third-parties/reddit-pixel.d.mts.map +1 -1
- package/dist/third-parties/reddit-pixel.mjs +2 -3
- package/dist/third-parties/reddit-pixel.mjs.map +1 -1
- package/package.json +1 -1
package/dist/next/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_track_index = require("../track/index.cjs");
|
|
5
5
|
const require_hooks_use_outbound_click_analytics = require("../hooks/use-outbound-click-analytics.cjs");
|
|
6
|
+
const require_third_parties_integration = require("../third-parties/integration.cjs");
|
|
6
7
|
const require_third_parties_microsoft_uet = require("../third-parties/microsoft-uet.cjs");
|
|
7
8
|
const require_hooks_use_uet_id_sync = require("../hooks/use-uet-id-sync.cjs");
|
|
8
9
|
const require_hooks_use_web_analytics = require("../hooks/use-web-analytics.cjs");
|
|
@@ -51,7 +52,7 @@ function Analytics({ integrations = [], facebookAppId, nonce, reportWebVitals =
|
|
|
51
52
|
property: "fb:app_id",
|
|
52
53
|
content: facebookAppId
|
|
53
54
|
}),
|
|
54
|
-
|
|
55
|
+
require_third_parties_integration.integrationScripts(integrations).map((script) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(next_script.default, {
|
|
55
56
|
id: script.id,
|
|
56
57
|
nonce,
|
|
57
58
|
strategy: script.strategy ?? "afterInteractive",
|
package/dist/next/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["usePathname","useSearchParams","uetCustomerIdOf","Suspense","Script"],"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { Suspense } from 'react';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useUETIdSync } from '../hooks/use-uet-id-sync';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport { type AnalyticsProps, preconnectIntegrations } from '../third-parties/analytics-props';\nimport { uetCustomerIdOf } from '../third-parties/microsoft-uet';\nimport { track } from '../track/index';\n\n/**\n * Its own component under a Suspense boundary: `useSearchParams` in a statically rendered route\n * bails the whole tree out to client rendering unless something above it suspends, and Next\n * fails the build for a page that lets it. The boundary is here so a host does not have to know.\n */\nfunction PageViews() {\n const pathname = usePathname();\n const searchParams = useSearchParams();\n useWebAnalytics(pathname, searchParams.toString());\n return null;\n}\n\nexport function Analytics({\n integrations = [],\n facebookAppId,\n nonce,\n reportWebVitals = true,\n}: AnalyticsProps) {\n useOutboundClickAnalytics();\n useUETIdSync(uetCustomerIdOf(integrations));\n preconnectIntegrations(integrations);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n <Suspense fallback={null}>\n <PageViews />\n </Suspense>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {integrations
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["usePathname","useSearchParams","uetCustomerIdOf","Suspense","integrationScripts","Script"],"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { Suspense } from 'react';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useUETIdSync } from '../hooks/use-uet-id-sync';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport { type AnalyticsProps, preconnectIntegrations } from '../third-parties/analytics-props';\nimport { integrationScripts } from '../third-parties/integration';\nimport { uetCustomerIdOf } from '../third-parties/microsoft-uet';\nimport { track } from '../track/index';\n\n/**\n * Its own component under a Suspense boundary: `useSearchParams` in a statically rendered route\n * bails the whole tree out to client rendering unless something above it suspends, and Next\n * fails the build for a page that lets it. The boundary is here so a host does not have to know.\n */\nfunction PageViews() {\n const pathname = usePathname();\n const searchParams = useSearchParams();\n useWebAnalytics(pathname, searchParams.toString());\n return null;\n}\n\nexport function Analytics({\n integrations = [],\n facebookAppId,\n nonce,\n reportWebVitals = true,\n}: AnalyticsProps) {\n useOutboundClickAnalytics();\n useUETIdSync(uetCustomerIdOf(integrations));\n preconnectIntegrations(integrations);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n <Suspense fallback={null}>\n <PageViews />\n </Suspense>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {integrationScripts(integrations).map((script) => (\n <Script\n key={script.id}\n id={script.id}\n nonce={nonce}\n strategy={script.strategy ?? 'afterInteractive'}\n dangerouslySetInnerHTML={{ __html: script.inline }}\n />\n ))}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBA,SAAS,YAAY;CACnB,MAAM,YAAA,GAAWA,gBAAAA,YAAAA,CAAY;CAC7B,MAAM,gBAAA,GAAeC,gBAAAA,gBAAAA,CAAgB;CACrC,gCAAA,gBAAgB,UAAU,aAAa,SAAS,CAAC;CACjD,OAAO;AACT;AAEA,SAAgB,UAAU,EACxB,eAAe,CAAC,GAChB,eACA,OACA,kBAAkB,QACD;CACjB,2CAAA,0BAA0B;CAC1B,8BAAA,aAAaC,oCAAAA,gBAAgB,YAAY,CAAC;CAC1C,sCAAA,uBAAuB,YAAY;CAEnC,CAAA,GAAA,gBAAA,mBAAA,EAAoB,WAAW;EAC7B,IAAI,CAAC,iBAAiB;EACtB,MAAM,aAAa;GACjB,OAAO,OAAO;GACd,WAAW,OAAO;GAClB,cAAc,OAAO;GACrB,cAAc,OAAO;GACrB,eAAe,OAAO;GACtB,wBAAwB,OAAO;GAC/B,iBAAiB;EACnB;EACA,oBAAA,MAAM,OAAO,MAAM,UAAU;CAC/B,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;EACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,MAAAA,UAAD;GAAU,UAAU;GAClB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD,CAAY,CAAA;EACJ,CAAA;EACT,iBAAiB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;GAAM,UAAS;GAAY,SAAS;EAAgB,CAAA;EACrEC,kCAAAA,mBAAmB,YAAY,CAAC,CAAC,KAAK,WACrC,iBAAA,GAAA,kBAAA,IAAA,CAACC,YAAAA,SAAD;GAEE,IAAI,OAAO;GACJ;GACP,UAAU,OAAO,YAAY;GAC7B,yBAAyB,EAAE,QAAQ,OAAO,OAAO;EAClD,GALM,OAAO,EAKb,CACF;CACD,EAAA,CAAA;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/next/index.tsx"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/next/index.tsx"],"mappings":";wBA0BgB,YACd,cACA,eACA,OACA,mBACC,iCAAc,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/next/index.tsx"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/next/index.tsx"],"mappings":";wBA0BgB,YACd,cACA,eACA,OACA,mBACC,iCAAc,IAAA"}
|
package/dist/next/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { track } from "../track/index.mjs";
|
|
3
3
|
import { useOutboundClickAnalytics } from "../hooks/use-outbound-click-analytics.mjs";
|
|
4
|
+
import { integrationScripts } from "../third-parties/integration.mjs";
|
|
4
5
|
import { uetCustomerIdOf } from "../third-parties/microsoft-uet.mjs";
|
|
5
6
|
import { useUETIdSync } from "../hooks/use-uet-id-sync.mjs";
|
|
6
7
|
import { useWebAnalytics } from "../hooks/use-web-analytics.mjs";
|
|
@@ -48,7 +49,7 @@ function Analytics({ integrations = [], facebookAppId, nonce, reportWebVitals =
|
|
|
48
49
|
property: "fb:app_id",
|
|
49
50
|
content: facebookAppId
|
|
50
51
|
}),
|
|
51
|
-
integrations
|
|
52
|
+
integrationScripts(integrations).map((script) => /* @__PURE__ */ jsx(Script, {
|
|
52
53
|
id: script.id,
|
|
53
54
|
nonce,
|
|
54
55
|
strategy: script.strategy ?? "afterInteractive",
|
package/dist/next/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { Suspense } from 'react';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useUETIdSync } from '../hooks/use-uet-id-sync';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport { type AnalyticsProps, preconnectIntegrations } from '../third-parties/analytics-props';\nimport { uetCustomerIdOf } from '../third-parties/microsoft-uet';\nimport { track } from '../track/index';\n\n/**\n * Its own component under a Suspense boundary: `useSearchParams` in a statically rendered route\n * bails the whole tree out to client rendering unless something above it suspends, and Next\n * fails the build for a page that lets it. The boundary is here so a host does not have to know.\n */\nfunction PageViews() {\n const pathname = usePathname();\n const searchParams = useSearchParams();\n useWebAnalytics(pathname, searchParams.toString());\n return null;\n}\n\nexport function Analytics({\n integrations = [],\n facebookAppId,\n nonce,\n reportWebVitals = true,\n}: AnalyticsProps) {\n useOutboundClickAnalytics();\n useUETIdSync(uetCustomerIdOf(integrations));\n preconnectIntegrations(integrations);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n <Suspense fallback={null}>\n <PageViews />\n </Suspense>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {integrations
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { Suspense } from 'react';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useUETIdSync } from '../hooks/use-uet-id-sync';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport { type AnalyticsProps, preconnectIntegrations } from '../third-parties/analytics-props';\nimport { integrationScripts } from '../third-parties/integration';\nimport { uetCustomerIdOf } from '../third-parties/microsoft-uet';\nimport { track } from '../track/index';\n\n/**\n * Its own component under a Suspense boundary: `useSearchParams` in a statically rendered route\n * bails the whole tree out to client rendering unless something above it suspends, and Next\n * fails the build for a page that lets it. The boundary is here so a host does not have to know.\n */\nfunction PageViews() {\n const pathname = usePathname();\n const searchParams = useSearchParams();\n useWebAnalytics(pathname, searchParams.toString());\n return null;\n}\n\nexport function Analytics({\n integrations = [],\n facebookAppId,\n nonce,\n reportWebVitals = true,\n}: AnalyticsProps) {\n useOutboundClickAnalytics();\n useUETIdSync(uetCustomerIdOf(integrations));\n preconnectIntegrations(integrations);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n <Suspense fallback={null}>\n <PageViews />\n </Suspense>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {integrationScripts(integrations).map((script) => (\n <Script\n key={script.id}\n id={script.id}\n nonce={nonce}\n strategy={script.strategy ?? 'afterInteractive'}\n dangerouslySetInnerHTML={{ __html: script.inline }}\n />\n ))}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,SAAS,YAAY;CACnB,MAAM,WAAW,YAAY;CAC7B,MAAM,eAAe,gBAAgB;CACrC,gBAAgB,UAAU,aAAa,SAAS,CAAC;CACjD,OAAO;AACT;AAEA,SAAgB,UAAU,EACxB,eAAe,CAAC,GAChB,eACA,OACA,kBAAkB,QACD;CACjB,0BAA0B;CAC1B,aAAa,gBAAgB,YAAY,CAAC;CAC1C,uBAAuB,YAAY;CAEnC,oBAAoB,WAAW;EAC7B,IAAI,CAAC,iBAAiB;EACtB,MAAM,aAAa;GACjB,OAAO,OAAO;GACd,WAAW,OAAO;GAClB,cAAc,OAAO;GACrB,cAAc,OAAO;GACrB,eAAe,OAAO;GACtB,wBAAwB,OAAO;GAC/B,iBAAiB;EACnB;EACA,MAAM,OAAO,MAAM,UAAU;CAC/B,CAAC;CAED,OACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,UAAD;GAAU,UAAU;GAClB,UAAA,oBAAC,WAAD,CAAY,CAAA;EACJ,CAAA;EACT,iBAAiB,oBAAC,QAAD;GAAM,UAAS;GAAY,SAAS;EAAgB,CAAA;EACrE,mBAAmB,YAAY,CAAC,CAAC,KAAK,WACrC,oBAAC,QAAD;GAEE,IAAI,OAAO;GACJ;GACP,UAAU,OAAO,YAAY;GAC7B,yBAAyB,EAAE,QAAQ,OAAO,OAAO;EAClD,GALM,OAAO,EAKb,CACF;CACD,EAAA,CAAA;AAEN"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_third_parties_integration = require("./integration.cjs");
|
|
2
3
|
let react_dom = require("react-dom");
|
|
3
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
5
|
// src/third-parties/analytics-props.tsx
|
|
@@ -16,7 +17,7 @@ function preconnectIntegrations(integrations = []) {
|
|
|
16
17
|
* they are (react).
|
|
17
18
|
*/
|
|
18
19
|
function IntegrationScripts({ integrations = [], nonce }) {
|
|
19
|
-
return
|
|
20
|
+
return require_third_parties_integration.integrationScripts(integrations).map((script) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("script", {
|
|
20
21
|
id: script.id,
|
|
21
22
|
nonce,
|
|
22
23
|
dangerouslySetInnerHTML: { __html: script.inline }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-props.cjs","names":["preconnect"],"sources":["../../src/third-parties/analytics-props.tsx"],"sourcesContent":["import { preconnect } from 'react-dom';\nimport type
|
|
1
|
+
{"version":3,"file":"analytics-props.cjs","names":["preconnect","integrationScripts"],"sources":["../../src/third-parties/analytics-props.tsx"],"sourcesContent":["import { preconnect } from 'react-dom';\nimport { type Integration, integrationScripts } from './integration';\n\n/** The props every framework's `<Analytics>` takes (react, next). */\nexport interface AnalyticsProps {\n /** The integrations passed to `setupAnalytics`, whose scripts this renders. */\n integrations?: readonly Integration[];\n /** Renders `<meta property=\"fb:app_id\">`, for Facebook's sharing insights. */\n facebookAppId?: string;\n /** The request's CSP nonce, set on every script rendered. */\n nonce?: string;\n /** Reports Core Web Vitals as events (on by default). */\n reportWebVitals?: boolean;\n}\n\n/**\n * Preconnects to every integration's `preconnect` origins. Called while rendering: React dedupes\n * the hints and, on the server, puts them at the top of `<head>`.\n */\nexport function preconnectIntegrations(integrations: readonly Integration[] = []) {\n integrations.forEach((integration) => {\n integration.preconnect?.forEach((origin) => preconnect(origin, { crossOrigin: 'anonymous' }));\n });\n}\n\n/**\n * The integrations' scripts as plain `<script>` elements, for the frameworks that render them as\n * they are (react).\n */\nexport function IntegrationScripts({\n integrations = [],\n nonce,\n}: Pick<AnalyticsProps, 'integrations' | 'nonce'>) {\n return integrationScripts(integrations).map((script) => (\n <script\n key={script.id}\n id={script.id}\n nonce={nonce}\n dangerouslySetInnerHTML={{ __html: script.inline }}\n />\n ));\n}\n"],"mappings":";;;;;;;;;AAmBA,SAAgB,uBAAuB,eAAuC,CAAC,GAAG;CAChF,aAAa,SAAS,gBAAgB;EACpC,YAAY,YAAY,SAAS,YAAA,GAAWA,UAAAA,WAAAA,CAAW,QAAQ,EAAE,aAAa,YAAY,CAAC,CAAC;CAC9F,CAAC;AACH;;;;;AAMA,SAAgB,mBAAmB,EACjC,eAAe,CAAC,GAChB,SACiD;CACjD,OAAOC,kCAAAA,mBAAmB,YAAY,CAAC,CAAC,KAAK,WAC3C,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;EAEE,IAAI,OAAO;EACJ;EACP,yBAAyB,EAAE,QAAQ,OAAO,OAAO;CAClD,GAJM,OAAO,EAIb,CACF;AACH"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { integrationScripts } from "./integration.mjs";
|
|
1
2
|
import { preconnect } from "react-dom";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
// src/third-parties/analytics-props.tsx
|
|
@@ -15,7 +16,7 @@ function preconnectIntegrations(integrations = []) {
|
|
|
15
16
|
* they are (react).
|
|
16
17
|
*/
|
|
17
18
|
function IntegrationScripts({ integrations = [], nonce }) {
|
|
18
|
-
return integrations
|
|
19
|
+
return integrationScripts(integrations).map((script) => /* @__PURE__ */ jsx("script", {
|
|
19
20
|
id: script.id,
|
|
20
21
|
nonce,
|
|
21
22
|
dangerouslySetInnerHTML: { __html: script.inline }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-props.mjs","names":[],"sources":["../../src/third-parties/analytics-props.tsx"],"sourcesContent":["import { preconnect } from 'react-dom';\nimport type
|
|
1
|
+
{"version":3,"file":"analytics-props.mjs","names":[],"sources":["../../src/third-parties/analytics-props.tsx"],"sourcesContent":["import { preconnect } from 'react-dom';\nimport { type Integration, integrationScripts } from './integration';\n\n/** The props every framework's `<Analytics>` takes (react, next). */\nexport interface AnalyticsProps {\n /** The integrations passed to `setupAnalytics`, whose scripts this renders. */\n integrations?: readonly Integration[];\n /** Renders `<meta property=\"fb:app_id\">`, for Facebook's sharing insights. */\n facebookAppId?: string;\n /** The request's CSP nonce, set on every script rendered. */\n nonce?: string;\n /** Reports Core Web Vitals as events (on by default). */\n reportWebVitals?: boolean;\n}\n\n/**\n * Preconnects to every integration's `preconnect` origins. Called while rendering: React dedupes\n * the hints and, on the server, puts them at the top of `<head>`.\n */\nexport function preconnectIntegrations(integrations: readonly Integration[] = []) {\n integrations.forEach((integration) => {\n integration.preconnect?.forEach((origin) => preconnect(origin, { crossOrigin: 'anonymous' }));\n });\n}\n\n/**\n * The integrations' scripts as plain `<script>` elements, for the frameworks that render them as\n * they are (react).\n */\nexport function IntegrationScripts({\n integrations = [],\n nonce,\n}: Pick<AnalyticsProps, 'integrations' | 'nonce'>) {\n return integrationScripts(integrations).map((script) => (\n <script\n key={script.id}\n id={script.id}\n nonce={nonce}\n dangerouslySetInnerHTML={{ __html: script.inline }}\n />\n ));\n}\n"],"mappings":";;;;;;;;AAmBA,SAAgB,uBAAuB,eAAuC,CAAC,GAAG;CAChF,aAAa,SAAS,gBAAgB;EACpC,YAAY,YAAY,SAAS,WAAW,WAAW,QAAQ,EAAE,aAAa,YAAY,CAAC,CAAC;CAC9F,CAAC;AACH;;;;;AAMA,SAAgB,mBAAmB,EACjC,eAAe,CAAC,GAChB,SACiD;CACjD,OAAO,mBAAmB,YAAY,CAAC,CAAC,KAAK,WAC3C,oBAAC,UAAD;EAEE,IAAI,OAAO;EACJ;EACP,yBAAyB,EAAE,QAAQ,OAAO,OAAO;CAClD,GAJM,OAAO,EAIb,CACF;AACH"}
|
|
@@ -13,6 +13,7 @@ exports.configureUET = require_third_parties_microsoft_uet.configureUET;
|
|
|
13
13
|
exports.getLoadedPosthog = require_third_parties_posthog.getLoadedPosthog;
|
|
14
14
|
exports.getPosthog = require_third_parties_posthog.getPosthog;
|
|
15
15
|
exports.googleAnalytics = require_third_parties_google_analytics.googleAnalytics;
|
|
16
|
+
exports.isLocalHost = require_third_parties_integration.isLocalHost;
|
|
16
17
|
exports.linkedInAds = require_third_parties_linkedin_insight_tag.linkedInAds;
|
|
17
18
|
exports.metaAds = require_third_parties_meta_pixel.metaAds;
|
|
18
19
|
exports.microsoftAds = require_third_parties_microsoft_uet.microsoftAds;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript } from "./integration.cjs";
|
|
1
|
+
import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript, isLocalHost } from "./integration.cjs";
|
|
2
2
|
import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.cjs";
|
|
3
3
|
import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.cjs";
|
|
4
4
|
import { LinkedinConversionConfig, linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.cjs";
|
|
@@ -7,4 +7,4 @@ import { UETConsent, UETEventParams, UETItem, UETPageType, UETPid } from "../tra
|
|
|
7
7
|
import { MicrosoftAdsIntegration, configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.cjs";
|
|
8
8
|
import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.cjs";
|
|
9
9
|
import { ErrorPattern, PostHog, PostHogConfig, PosthogErrorTrackingOptions, capturePosthogException, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.cjs";
|
|
10
|
-
export { type AdsOptions, CONVERSION_EVENTS, type ErrorPattern, type Integration, type IntegrationScript, type LinkedinConversionConfig, type MicrosoftAdsIntegration, type PostHog, type PostHogConfig, type PosthogErrorTrackingOptions, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, capturePosthogException, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
10
|
+
export { type AdsOptions, CONVERSION_EVENTS, type ErrorPattern, type Integration, type IntegrationScript, type LinkedinConversionConfig, type MicrosoftAdsIntegration, type PostHog, type PostHogConfig, type PosthogErrorTrackingOptions, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, capturePosthogException, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, isLocalHost, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript } from "./integration.mjs";
|
|
1
|
+
import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript, isLocalHost } from "./integration.mjs";
|
|
2
2
|
import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.mjs";
|
|
3
3
|
import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
|
|
4
4
|
import { LinkedinConversionConfig, linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
|
|
@@ -7,4 +7,4 @@ import { UETConsent, UETEventParams, UETItem, UETPageType, UETPid } from "../tra
|
|
|
7
7
|
import { MicrosoftAdsIntegration, configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.mjs";
|
|
8
8
|
import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.mjs";
|
|
9
9
|
import { ErrorPattern, PostHog, PostHogConfig, PosthogErrorTrackingOptions, capturePosthogException, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.mjs";
|
|
10
|
-
export { type AdsOptions, CONVERSION_EVENTS, type ErrorPattern, type Integration, type IntegrationScript, type LinkedinConversionConfig, type MicrosoftAdsIntegration, type PostHog, type PostHogConfig, type PosthogErrorTrackingOptions, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, capturePosthogException, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
10
|
+
export { type AdsOptions, CONVERSION_EVENTS, type ErrorPattern, type Integration, type IntegrationScript, type LinkedinConversionConfig, type MicrosoftAdsIntegration, type PostHog, type PostHogConfig, type PosthogErrorTrackingOptions, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, capturePosthogException, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, isLocalHost, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONVERSION_EVENTS } from "./integration.mjs";
|
|
1
|
+
import { CONVERSION_EVENTS, isLocalHost } from "./integration.mjs";
|
|
2
2
|
import { configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.mjs";
|
|
3
3
|
import { capturePosthogException, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.mjs";
|
|
4
4
|
import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.mjs";
|
|
@@ -6,4 +6,4 @@ import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.mjs";
|
|
|
6
6
|
import { linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
|
|
7
7
|
import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
|
|
8
8
|
import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
|
|
9
|
-
export { CONVERSION_EVENTS, capturePosthogException, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
9
|
+
export { CONVERSION_EVENTS, capturePosthogException, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, isLocalHost, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
// src/third-parties/integration.ts
|
|
3
3
|
/**
|
|
4
|
+
* A page served by a development setup: `localhost`, a `*.localhost` subdomain (a worktree under
|
|
5
|
+
* portless is `<branch>.web.localhost:1355`) or the loopback address, with or without a port. One
|
|
6
|
+
* pattern, used as a string in the inline scripts and as a RegExp here, so the two agree.
|
|
7
|
+
*/
|
|
8
|
+
const LOCAL_HOST_PATTERN = String.raw`(^|\.)localhost(:|$)|^127\.0\.0\.1(:|$)`;
|
|
9
|
+
const LOCAL_HOST = new RegExp(LOCAL_HOST_PATTERN);
|
|
10
|
+
/** Whether the page is served from a development host (`LOCAL_HOST_PATTERN`). */
|
|
11
|
+
function isLocalHost(host = window.location.host) {
|
|
12
|
+
return LOCAL_HOST.test(host);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The script an ad platform's integration puts on the page, silenced on a development host.
|
|
16
|
+
* Every vendor snippet reports a page view as it loads (`fbq('track', 'PageView')`,
|
|
17
|
+
* `rdt('track', 'PageVisit')`, UET's `pageLoad`), before any sender's own local check can run, so
|
|
18
|
+
* a worktree served at `*.web.localhost` showed up at Meta as a new domain sending data. The
|
|
19
|
+
* guard is in the snippet itself: the renderer has no request host on the server.
|
|
20
|
+
*/
|
|
21
|
+
function integrationScripts(integrations) {
|
|
22
|
+
return integrations.flatMap(({ type, script }) => {
|
|
23
|
+
if (!script) return [];
|
|
24
|
+
if (type !== "ads") return [script];
|
|
25
|
+
return [{
|
|
26
|
+
...script,
|
|
27
|
+
inline: `if (!/${LOCAL_HOST_PATTERN}/.test(window.location.host)) {${script.inline}}`
|
|
28
|
+
}];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
4
32
|
* The GA4 recommended events that are conversions or close to one, for an ad platform with no
|
|
5
33
|
* standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
|
|
6
34
|
*/
|
|
@@ -40,7 +68,10 @@ function adsTracker(send, accepts) {
|
|
|
40
68
|
};
|
|
41
69
|
}
|
|
42
70
|
exports.CONVERSION_EVENTS = CONVERSION_EVENTS;
|
|
71
|
+
exports.LOCAL_HOST_PATTERN = LOCAL_HOST_PATTERN;
|
|
43
72
|
exports.adEvents = adEvents;
|
|
44
73
|
exports.adsTracker = adsTracker;
|
|
74
|
+
exports.integrationScripts = integrationScripts;
|
|
75
|
+
exports.isLocalHost = isLocalHost;
|
|
45
76
|
|
|
46
77
|
//# sourceMappingURL=integration.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.cjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker, TrackName } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\n/**\n * The one script an integration puts on the page, rendered by `<Analytics integrations>`\n * (react, next) with the request's `nonce`: an inline snippet that loads the\n * vendor's own script from its host, as every vendor's official snippet does.\n */\nexport interface IntegrationScript {\n /**\n * The element id; also its React key, and how a test or a CSP report finds it. Never a global's\n * name: an element's id is readable as `window[id]` until a script defines it, so an id like\n * `posthog` hands the snippet's `window.posthog || []` the <script> element. Keep a hyphen in it.\n */\n readonly id: string;\n readonly inline: string;\n /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */\n readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';\n}\n\n/**\n * One third party, configured in one place: how events reach it, how it learns the signed-in\n * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`\n * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and\n * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.\n *\n * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every\n * event, for behavior analysis. An `ads` integration receives only what helps an ad platform\n * optimize and build audiences — the conversion events it maps to its own standard events, plus\n * the custom events it was explicitly given — and filters in its own `track`.\n */\nexport interface Integration {\n readonly type: 'analytics' | 'ads';\n readonly track: ThirdPartyTracker;\n readonly setUser?: ThirdPartyUserSetter;\n readonly script?: IntegrationScript;\n /**\n * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up\n * before the script asks for something there — e.g. where a snippet loads its library from.\n */\n readonly preconnect?: readonly string[];\n}\n\n/**\n * The GA4 recommended events that are conversions or close to one, for an ad platform with no\n * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.\n */\nexport const CONVERSION_EVENTS = [\n 'sign_up',\n 'login',\n 'generate_lead',\n 'view_item',\n 'add_to_cart',\n 'add_to_wishlist',\n 'begin_checkout',\n 'add_payment_info',\n 'purchase',\n 'subscribe',\n 'trial_begin',\n 'search',\n 'schedule',\n 'submit_application',\n 'contact',\n] as const satisfies readonly EventName[];\n\nexport interface AdsOptions {\n /**\n * Custom events this platform receives besides the conversions it maps to its standard\n * events, e.g. one used as an optimization goal or for an audience. Everything else is not\n * sent to it. The names `track` accepts, so with strict event names a typo is a compile error.\n */\n customEvents?: readonly TrackName[];\n}\n\n/**\n * Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns\n * into one of its standard events — and the custom events the host listed. Everything else in the\n * product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and\n * PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the\n * browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two\n * report the same events.\n */\nexport function adEvents(\n isStandard: (name: string) => boolean,\n customEvents: readonly string[] = []\n): (name: string) => boolean {\n return (name) => isStandard(name) || customEvents.includes(name);\n}\n\n/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */\nexport function adsTracker(\n send: ThirdPartyTracker,\n accepts: (name: string) => boolean\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!accepts(name)) return;\n return send(name, properties, eventId);\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"integration.cjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker, TrackName } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\n/**\n * The one script an integration puts on the page, rendered by `<Analytics integrations>`\n * (react, next) with the request's `nonce`: an inline snippet that loads the\n * vendor's own script from its host, as every vendor's official snippet does.\n */\nexport interface IntegrationScript {\n /**\n * The element id; also its React key, and how a test or a CSP report finds it. Never a global's\n * name: an element's id is readable as `window[id]` until a script defines it, so an id like\n * `posthog` hands the snippet's `window.posthog || []` the <script> element. Keep a hyphen in it.\n */\n readonly id: string;\n readonly inline: string;\n /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */\n readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';\n}\n\n/**\n * One third party, configured in one place: how events reach it, how it learns the signed-in\n * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`\n * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and\n * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.\n *\n * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every\n * event, for behavior analysis. An `ads` integration receives only what helps an ad platform\n * optimize and build audiences — the conversion events it maps to its own standard events, plus\n * the custom events it was explicitly given — and filters in its own `track`.\n */\nexport interface Integration {\n readonly type: 'analytics' | 'ads';\n readonly track: ThirdPartyTracker;\n readonly setUser?: ThirdPartyUserSetter;\n readonly script?: IntegrationScript;\n /**\n * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up\n * before the script asks for something there — e.g. where a snippet loads its library from.\n */\n readonly preconnect?: readonly string[];\n}\n\n/**\n * A page served by a development setup: `localhost`, a `*.localhost` subdomain (a worktree under\n * portless is `<branch>.web.localhost:1355`) or the loopback address, with or without a port. One\n * pattern, used as a string in the inline scripts and as a RegExp here, so the two agree.\n */\nexport const LOCAL_HOST_PATTERN = String.raw`(^|\\.)localhost(:|$)|^127\\.0\\.0\\.1(:|$)`;\nconst LOCAL_HOST = new RegExp(LOCAL_HOST_PATTERN);\n\n/** Whether the page is served from a development host (`LOCAL_HOST_PATTERN`). */\nexport function isLocalHost(host: string = window.location.host): boolean {\n return LOCAL_HOST.test(host);\n}\n\n/**\n * The script an ad platform's integration puts on the page, silenced on a development host.\n * Every vendor snippet reports a page view as it loads (`fbq('track', 'PageView')`,\n * `rdt('track', 'PageVisit')`, UET's `pageLoad`), before any sender's own local check can run, so\n * a worktree served at `*.web.localhost` showed up at Meta as a new domain sending data. The\n * guard is in the snippet itself: the renderer has no request host on the server.\n */\nexport function integrationScripts(integrations: readonly Integration[]): IntegrationScript[] {\n return integrations.flatMap(({ type, script }) => {\n if (!script) return [];\n if (type !== 'ads') return [script];\n return [\n {\n ...script,\n inline: `if (!/${LOCAL_HOST_PATTERN}/.test(window.location.host)) {${script.inline}}`,\n },\n ];\n });\n}\n\n/**\n * The GA4 recommended events that are conversions or close to one, for an ad platform with no\n * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.\n */\nexport const CONVERSION_EVENTS = [\n 'sign_up',\n 'login',\n 'generate_lead',\n 'view_item',\n 'add_to_cart',\n 'add_to_wishlist',\n 'begin_checkout',\n 'add_payment_info',\n 'purchase',\n 'subscribe',\n 'trial_begin',\n 'search',\n 'schedule',\n 'submit_application',\n 'contact',\n] as const satisfies readonly EventName[];\n\nexport interface AdsOptions {\n /**\n * Custom events this platform receives besides the conversions it maps to its standard\n * events, e.g. one used as an optimization goal or for an audience. Everything else is not\n * sent to it. The names `track` accepts, so with strict event names a typo is a compile error.\n */\n customEvents?: readonly TrackName[];\n}\n\n/**\n * Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns\n * into one of its standard events — and the custom events the host listed. Everything else in the\n * product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and\n * PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the\n * browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two\n * report the same events.\n */\nexport function adEvents(\n isStandard: (name: string) => boolean,\n customEvents: readonly string[] = []\n): (name: string) => boolean {\n return (name) => isStandard(name) || customEvents.includes(name);\n}\n\n/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */\nexport function adsTracker(\n send: ThirdPartyTracker,\n accepts: (name: string) => boolean\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!accepts(name)) return;\n return send(name, properties, eventId);\n };\n}\n"],"mappings":";;;;;;;AAgDA,MAAa,qBAAqB,OAAO,GAAG;AAC5C,MAAM,aAAa,IAAI,OAAO,kBAAkB;;AAGhD,SAAgB,YAAY,OAAe,OAAO,SAAS,MAAe;CACxE,OAAO,WAAW,KAAK,IAAI;AAC7B;;;;;;;;AASA,SAAgB,mBAAmB,cAA2D;CAC5F,OAAO,aAAa,SAAS,EAAE,MAAM,aAAa;EAChD,IAAI,CAAC,QAAQ,OAAO,CAAC;EACrB,IAAI,SAAS,OAAO,OAAO,CAAC,MAAM;EAClC,OAAO,CACL;GACE,GAAG;GACH,QAAQ,SAAS,mBAAmB,iCAAiC,OAAO,OAAO;EACrF,CACF;CACF,CAAC;AACH;;;;;AAMA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;AAmBA,SAAgB,SACd,YACA,eAAkC,CAAC,GACR;CAC3B,QAAQ,SAAS,WAAW,IAAI,KAAK,aAAa,SAAS,IAAI;AACjE;;AAGA,SAAgB,WACd,MACA,SACmB;CACnB,QAAQ,MAAM,YAAY,YAAY;EACpC,IAAI,CAAC,QAAQ,IAAI,GAAG;EACpB,OAAO,KAAK,MAAM,YAAY,OAAO;CACvC;AACF"}
|
|
@@ -38,6 +38,22 @@ export interface Integration {
|
|
|
38
38
|
*/
|
|
39
39
|
readonly preconnect?: readonly string[];
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* A page served by a development setup: `localhost`, a `*.localhost` subdomain (a worktree under
|
|
43
|
+
* portless is `<branch>.web.localhost:1355`) or the loopback address, with or without a port. One
|
|
44
|
+
* pattern, used as a string in the inline scripts and as a RegExp here, so the two agree.
|
|
45
|
+
*/
|
|
46
|
+
export declare const LOCAL_HOST_PATTERN: string;
|
|
47
|
+
/** Whether the page is served from a development host (`LOCAL_HOST_PATTERN`). */
|
|
48
|
+
export declare function isLocalHost(host?: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The script an ad platform's integration puts on the page, silenced on a development host.
|
|
51
|
+
* Every vendor snippet reports a page view as it loads (`fbq('track', 'PageView')`,
|
|
52
|
+
* `rdt('track', 'PageVisit')`, UET's `pageLoad`), before any sender's own local check can run, so
|
|
53
|
+
* a worktree served at `*.web.localhost` showed up at Meta as a new domain sending data. The
|
|
54
|
+
* guard is in the snippet itself: the renderer has no request host on the server.
|
|
55
|
+
*/
|
|
56
|
+
export declare function integrationScripts(integrations: readonly Integration[]): IntegrationScript[];
|
|
41
57
|
/**
|
|
42
58
|
* The GA4 recommended events that are conversions or close to one, for an ad platform with no
|
|
43
59
|
* standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.cts","names":[],"sources":["../../src/third-parties/integration.ts"],"mappings":";;;;;;;iBAQiB;;;;;;WAMN;WACA;;WAEA;;;;;;;;;;;;;iBAcM;WACN;WACA,OAAO;WACP,UAAU;WACV,SAAS;;;;;WAKT
|
|
1
|
+
{"version":3,"file":"integration.d.cts","names":[],"sources":["../../src/third-parties/integration.ts"],"mappings":";;;;;;;iBAQiB;;;;;;WAMN;WACA;;WAEA;;;;;;;;;;;;;iBAcM;WACN;WACA,OAAO;WACP,UAAU;WACV,SAAS;;;;;WAKT;;;;;;;qBAQE;;wBAIG,YAAY;;;;;;;;wBAWZ,mBAAmB,uBAAuB,gBAAgB;;;;;qBAiB7D;iBAkBI;;;;;;EAMf,wBAAwB;;;;;;;;;;wBAWV,SACd,aAAa,0BACb,oCACE;;wBAKY,WACd,MAAM,mBACN,UAAU,2BACT"}
|
|
@@ -38,6 +38,22 @@ export interface Integration {
|
|
|
38
38
|
*/
|
|
39
39
|
readonly preconnect?: readonly string[];
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* A page served by a development setup: `localhost`, a `*.localhost` subdomain (a worktree under
|
|
43
|
+
* portless is `<branch>.web.localhost:1355`) or the loopback address, with or without a port. One
|
|
44
|
+
* pattern, used as a string in the inline scripts and as a RegExp here, so the two agree.
|
|
45
|
+
*/
|
|
46
|
+
export declare const LOCAL_HOST_PATTERN: string;
|
|
47
|
+
/** Whether the page is served from a development host (`LOCAL_HOST_PATTERN`). */
|
|
48
|
+
export declare function isLocalHost(host?: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The script an ad platform's integration puts on the page, silenced on a development host.
|
|
51
|
+
* Every vendor snippet reports a page view as it loads (`fbq('track', 'PageView')`,
|
|
52
|
+
* `rdt('track', 'PageVisit')`, UET's `pageLoad`), before any sender's own local check can run, so
|
|
53
|
+
* a worktree served at `*.web.localhost` showed up at Meta as a new domain sending data. The
|
|
54
|
+
* guard is in the snippet itself: the renderer has no request host on the server.
|
|
55
|
+
*/
|
|
56
|
+
export declare function integrationScripts(integrations: readonly Integration[]): IntegrationScript[];
|
|
41
57
|
/**
|
|
42
58
|
* The GA4 recommended events that are conversions or close to one, for an ad platform with no
|
|
43
59
|
* standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.mts","names":[],"sources":["../../src/third-parties/integration.ts"],"mappings":";;;;;;;iBAQiB;;;;;;WAMN;WACA;;WAEA;;;;;;;;;;;;;iBAcM;WACN;WACA,OAAO;WACP,UAAU;WACV,SAAS;;;;;WAKT
|
|
1
|
+
{"version":3,"file":"integration.d.mts","names":[],"sources":["../../src/third-parties/integration.ts"],"mappings":";;;;;;;iBAQiB;;;;;;WAMN;WACA;;WAEA;;;;;;;;;;;;;iBAcM;WACN;WACA,OAAO;WACP,UAAU;WACV,SAAS;;;;;WAKT;;;;;;;qBAQE;;wBAIG,YAAY;;;;;;;;wBAWZ,mBAAmB,uBAAuB,gBAAgB;;;;;qBAiB7D;iBAkBI;;;;;;EAMf,wBAAwB;;;;;;;;;;wBAWV,SACd,aAAa,0BACb,oCACE;;wBAKY,WACd,MAAM,mBACN,UAAU,2BACT"}
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
// src/third-parties/integration.ts
|
|
2
2
|
/**
|
|
3
|
+
* A page served by a development setup: `localhost`, a `*.localhost` subdomain (a worktree under
|
|
4
|
+
* portless is `<branch>.web.localhost:1355`) or the loopback address, with or without a port. One
|
|
5
|
+
* pattern, used as a string in the inline scripts and as a RegExp here, so the two agree.
|
|
6
|
+
*/
|
|
7
|
+
const LOCAL_HOST_PATTERN = String.raw`(^|\.)localhost(:|$)|^127\.0\.0\.1(:|$)`;
|
|
8
|
+
const LOCAL_HOST = new RegExp(LOCAL_HOST_PATTERN);
|
|
9
|
+
/** Whether the page is served from a development host (`LOCAL_HOST_PATTERN`). */
|
|
10
|
+
function isLocalHost(host = window.location.host) {
|
|
11
|
+
return LOCAL_HOST.test(host);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The script an ad platform's integration puts on the page, silenced on a development host.
|
|
15
|
+
* Every vendor snippet reports a page view as it loads (`fbq('track', 'PageView')`,
|
|
16
|
+
* `rdt('track', 'PageVisit')`, UET's `pageLoad`), before any sender's own local check can run, so
|
|
17
|
+
* a worktree served at `*.web.localhost` showed up at Meta as a new domain sending data. The
|
|
18
|
+
* guard is in the snippet itself: the renderer has no request host on the server.
|
|
19
|
+
*/
|
|
20
|
+
function integrationScripts(integrations) {
|
|
21
|
+
return integrations.flatMap(({ type, script }) => {
|
|
22
|
+
if (!script) return [];
|
|
23
|
+
if (type !== "ads") return [script];
|
|
24
|
+
return [{
|
|
25
|
+
...script,
|
|
26
|
+
inline: `if (!/${LOCAL_HOST_PATTERN}/.test(window.location.host)) {${script.inline}}`
|
|
27
|
+
}];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
3
31
|
* The GA4 recommended events that are conversions or close to one, for an ad platform with no
|
|
4
32
|
* standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
|
|
5
33
|
*/
|
|
@@ -38,6 +66,6 @@ function adsTracker(send, accepts) {
|
|
|
38
66
|
return send(name, properties, eventId);
|
|
39
67
|
};
|
|
40
68
|
}
|
|
41
|
-
export { CONVERSION_EVENTS, adEvents, adsTracker };
|
|
69
|
+
export { CONVERSION_EVENTS, LOCAL_HOST_PATTERN, adEvents, adsTracker, integrationScripts, isLocalHost };
|
|
42
70
|
|
|
43
71
|
//# sourceMappingURL=integration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.mjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker, TrackName } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\n/**\n * The one script an integration puts on the page, rendered by `<Analytics integrations>`\n * (react, next) with the request's `nonce`: an inline snippet that loads the\n * vendor's own script from its host, as every vendor's official snippet does.\n */\nexport interface IntegrationScript {\n /**\n * The element id; also its React key, and how a test or a CSP report finds it. Never a global's\n * name: an element's id is readable as `window[id]` until a script defines it, so an id like\n * `posthog` hands the snippet's `window.posthog || []` the <script> element. Keep a hyphen in it.\n */\n readonly id: string;\n readonly inline: string;\n /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */\n readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';\n}\n\n/**\n * One third party, configured in one place: how events reach it, how it learns the signed-in\n * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`\n * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and\n * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.\n *\n * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every\n * event, for behavior analysis. An `ads` integration receives only what helps an ad platform\n * optimize and build audiences — the conversion events it maps to its own standard events, plus\n * the custom events it was explicitly given — and filters in its own `track`.\n */\nexport interface Integration {\n readonly type: 'analytics' | 'ads';\n readonly track: ThirdPartyTracker;\n readonly setUser?: ThirdPartyUserSetter;\n readonly script?: IntegrationScript;\n /**\n * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up\n * before the script asks for something there — e.g. where a snippet loads its library from.\n */\n readonly preconnect?: readonly string[];\n}\n\n/**\n * The GA4 recommended events that are conversions or close to one, for an ad platform with no\n * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.\n */\nexport const CONVERSION_EVENTS = [\n 'sign_up',\n 'login',\n 'generate_lead',\n 'view_item',\n 'add_to_cart',\n 'add_to_wishlist',\n 'begin_checkout',\n 'add_payment_info',\n 'purchase',\n 'subscribe',\n 'trial_begin',\n 'search',\n 'schedule',\n 'submit_application',\n 'contact',\n] as const satisfies readonly EventName[];\n\nexport interface AdsOptions {\n /**\n * Custom events this platform receives besides the conversions it maps to its standard\n * events, e.g. one used as an optimization goal or for an audience. Everything else is not\n * sent to it. The names `track` accepts, so with strict event names a typo is a compile error.\n */\n customEvents?: readonly TrackName[];\n}\n\n/**\n * Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns\n * into one of its standard events — and the custom events the host listed. Everything else in the\n * product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and\n * PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the\n * browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two\n * report the same events.\n */\nexport function adEvents(\n isStandard: (name: string) => boolean,\n customEvents: readonly string[] = []\n): (name: string) => boolean {\n return (name) => isStandard(name) || customEvents.includes(name);\n}\n\n/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */\nexport function adsTracker(\n send: ThirdPartyTracker,\n accepts: (name: string) => boolean\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!accepts(name)) return;\n return send(name, properties, eventId);\n };\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"integration.mjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker, TrackName } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\n/**\n * The one script an integration puts on the page, rendered by `<Analytics integrations>`\n * (react, next) with the request's `nonce`: an inline snippet that loads the\n * vendor's own script from its host, as every vendor's official snippet does.\n */\nexport interface IntegrationScript {\n /**\n * The element id; also its React key, and how a test or a CSP report finds it. Never a global's\n * name: an element's id is readable as `window[id]` until a script defines it, so an id like\n * `posthog` hands the snippet's `window.posthog || []` the <script> element. Keep a hyphen in it.\n */\n readonly id: string;\n readonly inline: string;\n /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */\n readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';\n}\n\n/**\n * One third party, configured in one place: how events reach it, how it learns the signed-in\n * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`\n * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and\n * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.\n *\n * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every\n * event, for behavior analysis. An `ads` integration receives only what helps an ad platform\n * optimize and build audiences — the conversion events it maps to its own standard events, plus\n * the custom events it was explicitly given — and filters in its own `track`.\n */\nexport interface Integration {\n readonly type: 'analytics' | 'ads';\n readonly track: ThirdPartyTracker;\n readonly setUser?: ThirdPartyUserSetter;\n readonly script?: IntegrationScript;\n /**\n * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up\n * before the script asks for something there — e.g. where a snippet loads its library from.\n */\n readonly preconnect?: readonly string[];\n}\n\n/**\n * A page served by a development setup: `localhost`, a `*.localhost` subdomain (a worktree under\n * portless is `<branch>.web.localhost:1355`) or the loopback address, with or without a port. One\n * pattern, used as a string in the inline scripts and as a RegExp here, so the two agree.\n */\nexport const LOCAL_HOST_PATTERN = String.raw`(^|\\.)localhost(:|$)|^127\\.0\\.0\\.1(:|$)`;\nconst LOCAL_HOST = new RegExp(LOCAL_HOST_PATTERN);\n\n/** Whether the page is served from a development host (`LOCAL_HOST_PATTERN`). */\nexport function isLocalHost(host: string = window.location.host): boolean {\n return LOCAL_HOST.test(host);\n}\n\n/**\n * The script an ad platform's integration puts on the page, silenced on a development host.\n * Every vendor snippet reports a page view as it loads (`fbq('track', 'PageView')`,\n * `rdt('track', 'PageVisit')`, UET's `pageLoad`), before any sender's own local check can run, so\n * a worktree served at `*.web.localhost` showed up at Meta as a new domain sending data. The\n * guard is in the snippet itself: the renderer has no request host on the server.\n */\nexport function integrationScripts(integrations: readonly Integration[]): IntegrationScript[] {\n return integrations.flatMap(({ type, script }) => {\n if (!script) return [];\n if (type !== 'ads') return [script];\n return [\n {\n ...script,\n inline: `if (!/${LOCAL_HOST_PATTERN}/.test(window.location.host)) {${script.inline}}`,\n },\n ];\n });\n}\n\n/**\n * The GA4 recommended events that are conversions or close to one, for an ad platform with no\n * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.\n */\nexport const CONVERSION_EVENTS = [\n 'sign_up',\n 'login',\n 'generate_lead',\n 'view_item',\n 'add_to_cart',\n 'add_to_wishlist',\n 'begin_checkout',\n 'add_payment_info',\n 'purchase',\n 'subscribe',\n 'trial_begin',\n 'search',\n 'schedule',\n 'submit_application',\n 'contact',\n] as const satisfies readonly EventName[];\n\nexport interface AdsOptions {\n /**\n * Custom events this platform receives besides the conversions it maps to its standard\n * events, e.g. one used as an optimization goal or for an audience. Everything else is not\n * sent to it. The names `track` accepts, so with strict event names a typo is a compile error.\n */\n customEvents?: readonly TrackName[];\n}\n\n/**\n * Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns\n * into one of its standard events — and the custom events the host listed. Everything else in the\n * product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and\n * PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the\n * browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two\n * report the same events.\n */\nexport function adEvents(\n isStandard: (name: string) => boolean,\n customEvents: readonly string[] = []\n): (name: string) => boolean {\n return (name) => isStandard(name) || customEvents.includes(name);\n}\n\n/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */\nexport function adsTracker(\n send: ThirdPartyTracker,\n accepts: (name: string) => boolean\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!accepts(name)) return;\n return send(name, properties, eventId);\n };\n}\n"],"mappings":";;;;;;AAgDA,MAAa,qBAAqB,OAAO,GAAG;AAC5C,MAAM,aAAa,IAAI,OAAO,kBAAkB;;AAGhD,SAAgB,YAAY,OAAe,OAAO,SAAS,MAAe;CACxE,OAAO,WAAW,KAAK,IAAI;AAC7B;;;;;;;;AASA,SAAgB,mBAAmB,cAA2D;CAC5F,OAAO,aAAa,SAAS,EAAE,MAAM,aAAa;EAChD,IAAI,CAAC,QAAQ,OAAO,CAAC;EACrB,IAAI,SAAS,OAAO,OAAO,CAAC,MAAM;EAClC,OAAO,CACL;GACE,GAAG;GACH,QAAQ,SAAS,mBAAmB,iCAAiC,OAAO,OAAO;EACrF,CACF;CACF,CAAC;AACH;;;;;AAMA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;AAmBA,SAAgB,SACd,YACA,eAAkC,CAAC,GACR;CAC3B,QAAQ,SAAS,WAAW,IAAI,KAAK,aAAa,SAAS,IAAI;AACjE;;AAGA,SAAgB,WACd,MACA,SACmB;CACnB,QAAQ,MAAM,YAAY,YAAY;EACpC,IAAI,CAAC,QAAQ,IAAI,GAAG;EACpB,OAAO,KAAK,MAAM,YAAY,OAAO;CACvC;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils_field = require("../utils/field.cjs");
|
|
3
|
+
const require_third_parties_integration = require("./integration.cjs");
|
|
3
4
|
// src/third-parties/linkedin-insight-tag.ts
|
|
4
5
|
function sendLinkedinEvent(config) {
|
|
5
6
|
return (name, _properties, event_id) => {
|
|
@@ -7,8 +8,7 @@ function sendLinkedinEvent(config) {
|
|
|
7
8
|
console.warn("lintrk has not been initialized");
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
10
|
-
if (
|
|
11
|
-
if (window.location.host.includes("localhost")) return;
|
|
11
|
+
if (require_third_parties_integration.isLocalHost()) return;
|
|
12
12
|
const conversion_id = config[name];
|
|
13
13
|
if (!conversion_id) return;
|
|
14
14
|
window.lintrk("track", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.cjs","names":["isLocalHost","getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { type Integration, isLocalHost } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the LinkedIn Insight Tag script has loaded. */\n lintrk?: Lintrk['lintrk'];\n }\n}\n\n/**\n * Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the\n * names `track` accepts, so with strict event names a typo or undeclared event is a compile error.\n */\nexport type LinkedinConversionConfig = { readonly [K in TrackName]?: number };\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return false;\n }\n if (isLocalHost()) return;\n\n const conversion_id = config[name];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n\n/**\n * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps\n * to (LinkedIn conversions are created in Campaign Manager and addressed by id).\n */\n/** LinkedIn's configuration, shared by `linkedInAds` and `linkedinConversions` on the server. */\nexport interface LinkedInAdsOptions {\n partnerId: `${number}`;\n conversions: LinkedinConversionConfig;\n}\n\nexport function linkedInAds(options: LinkedInAdsOptions): Integration {\n return {\n type: 'ads',\n track: sendLinkedinEvent(options.conversions),\n setUser: setLinkedinUser,\n script: {\n id: 'linkedin-insight-tag',\n inline: `\n _linkedin_partner_id = ${JSON.stringify(options.partnerId)};\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n },\n };\n}\n"],"mappings":";;;;AAmBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C,OAAO;EACT;EACA,IAAIA,kCAAAA,YAAY,GAAG;EAEnB,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQC,oBAAAA,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;AAYA,SAAgB,YAAY,SAA0C;CACpE,OAAO;EACL,MAAM;EACN,OAAO,kBAAkB,QAAQ,WAAW;EAC5C,SAAS;EACT,QAAQ;GACN,IAAI;GACJ,QAAQ;iCACmB,KAAK,UAAU,QAAQ,SAAS,EAAE;;;;;;;;;;;;;;;;;EAiB/D;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAepB,kBAAkB,aAAa;;;;;;iBAgB9B;EACf;EACA,aAAa;;wBAGC,YAAY,SAAS,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAepB,kBAAkB,aAAa;;;;;;iBAgB9B;EACf;EACA,aAAa;;wBAGC,YAAY,SAAS,qBAAqB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getFirst } from "../utils/field.mjs";
|
|
2
|
+
import { isLocalHost } from "./integration.mjs";
|
|
2
3
|
// src/third-parties/linkedin-insight-tag.ts
|
|
3
4
|
function sendLinkedinEvent(config) {
|
|
4
5
|
return (name, _properties, event_id) => {
|
|
@@ -6,8 +7,7 @@ function sendLinkedinEvent(config) {
|
|
|
6
7
|
console.warn("lintrk has not been initialized");
|
|
7
8
|
return false;
|
|
8
9
|
}
|
|
9
|
-
if (
|
|
10
|
-
if (window.location.host.includes("localhost")) return;
|
|
10
|
+
if (isLocalHost()) return;
|
|
11
11
|
const conversion_id = config[name];
|
|
12
12
|
if (!conversion_id) return;
|
|
13
13
|
window.lintrk("track", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.mjs","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.mjs","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { type Integration, isLocalHost } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the LinkedIn Insight Tag script has loaded. */\n lintrk?: Lintrk['lintrk'];\n }\n}\n\n/**\n * Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the\n * names `track` accepts, so with strict event names a typo or undeclared event is a compile error.\n */\nexport type LinkedinConversionConfig = { readonly [K in TrackName]?: number };\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return false;\n }\n if (isLocalHost()) return;\n\n const conversion_id = config[name];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n\n/**\n * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps\n * to (LinkedIn conversions are created in Campaign Manager and addressed by id).\n */\n/** LinkedIn's configuration, shared by `linkedInAds` and `linkedinConversions` on the server. */\nexport interface LinkedInAdsOptions {\n partnerId: `${number}`;\n conversions: LinkedinConversionConfig;\n}\n\nexport function linkedInAds(options: LinkedInAdsOptions): Integration {\n return {\n type: 'ads',\n track: sendLinkedinEvent(options.conversions),\n setUser: setLinkedinUser,\n script: {\n id: 'linkedin-insight-tag',\n inline: `\n _linkedin_partner_id = ${JSON.stringify(options.partnerId)};\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n },\n };\n}\n"],"mappings":";;;AAmBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C,OAAO;EACT;EACA,IAAI,YAAY,GAAG;EAEnB,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQ,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;AAYA,SAAgB,YAAY,SAA0C;CACpE,OAAO;EACL,MAAM;EACN,OAAO,kBAAkB,QAAQ,WAAW;EAC5C,SAAS;EACT,QAAQ;GACN,IAAI;GACJ,QAAQ;iCACmB,KAAK,UAAU,QAAQ,SAAS,EAAE;;;;;;;;;;;;;;;;;EAiB/D;CACF;AACF"}
|
|
@@ -17,8 +17,7 @@ function sendFBEvent(name, properties, event_id) {
|
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
if (metrics.includes(name)) return;
|
|
20
|
-
if (
|
|
21
|
-
if (window.location.host.includes("localhost")) return;
|
|
20
|
+
if (require_third_parties_integration.isLocalHost()) return;
|
|
22
21
|
const options = { eventID: event_id };
|
|
23
22
|
const [type, fbEventName, fbEventProperties] = require_track_fbq.mapFBEvent(name, properties);
|
|
24
23
|
if (type === "track") window.fbq(type, fbEventName, fbEventProperties, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst","adsTracker","adEvents","isStandardFBEvent"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, isStandardFBEvent, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport {
|
|
1
|
+
{"version":3,"file":"meta-pixel.cjs","names":["isLocalHost","mapFBEvent","getFirst","adsTracker","adEvents","isStandardFBEvent"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, isStandardFBEvent, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport {\n type AdsOptions,\n type Integration,\n adEvents,\n adsTracker,\n isLocalHost,\n} from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the Meta Pixel script has loaded. */\n fbq?: FBQ['fbq'];\n }\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return false;\n }\n if (metrics.includes(name)) return;\n if (isLocalHost()) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n // The two branches are identical on purpose. `fbq` is overloaded per `type` — 'track' takes a\n // standard event name with its typed properties, 'trackCustom' an arbitrary string — and what\n // `mapFBEvent` returns is a union of both shapes. Narrowing `type` is what picks a single\n // overload; collapsing the branches leaves the call matching none of them.\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, user_data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n // `st` is Meta's state/province field, not the street address.\n st: address?.region,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n\n/** Meta Pixel: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`. */\n/** Meta's configuration, shared by `metaAds` in the browser and `metaConversions` on the server. */\nexport interface MetaAdsOptions extends AdsOptions {\n pixelId: PixelId;\n}\n\nexport function metaAds(options: MetaAdsOptions): Integration {\n return {\n type: 'ads',\n track: adsTracker(sendFBEvent, adEvents(isStandardFBEvent, options.customEvents)),\n setUser: setFBUser(options.pixelId),\n script: {\n id: 'meta-pixel',\n inline: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', ${JSON.stringify(options.pixelId)});\n fbq('track', 'PageView');\n `,\n },\n };\n}\n"],"mappings":";;;;;AAmBA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,YACd,MACA,YACA,UACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;EAChD,QAAQ,KAAK,8BAA8B;EAC3C,OAAO;CACT;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAIA,kCAAAA,YAAY,GAAG;CAEnB,MAAM,UAAU,EAAE,SAAS,SAAS;CACpC,MAAM,CAAC,MAAM,aAAa,qBAAqBC,kBAAAA,WAAW,MAAM,UAAU;CAK1E,IAAI,SAAS,SACX,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;MAExD,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAE5D;AAEA,SAAgB,UAAU,SAAkB;CAC1C,QAAQ,EAAE,SAAS,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAIA,oBAAAA,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAIA,oBAAAA,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GAEb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF;AAQA,SAAgB,QAAQ,SAAsC;CAC5D,OAAO;EACL,MAAM;EACN,OAAOC,kCAAAA,WAAW,aAAaC,kCAAAA,SAASC,kBAAAA,mBAAmB,QAAQ,YAAY,CAAC;EAChF,SAAS,UAAU,QAAQ,OAAO;EAClC,QAAQ;GACN,IAAI;GACJ,QAAQ;;;;;;;;;;;;;;;;;sBAiBQ,KAAK,UAAU,QAAQ,OAAO,EAAE;;;EAGlD;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.d.cts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"meta-pixel.d.cts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAYQ;YACI;;IAER,MAAM;;;wBAMM,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;wBAsBc,UAAU,SAAS,aAAO,SAAA,aACR;;;iBAyBjB,uBAAuB;EACtC,SAAS;;wBAGK,QAAQ,SAAS,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAYQ;YACI;;IAER,MAAM;;;wBAMM,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;wBAsBc,UAAU,SAAS,aAAO,SAAA,aACR;;;iBAyBjB,uBAAuB;EACtC,SAAS;;wBAGK,QAAQ,SAAS,iBAAiB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getFirst } from "../utils/field.mjs";
|
|
2
|
-
import { adEvents, adsTracker } from "./integration.mjs";
|
|
2
|
+
import { adEvents, adsTracker, isLocalHost } from "./integration.mjs";
|
|
3
3
|
import { isStandardFBEvent, mapFBEvent } from "../track/fbq.mjs";
|
|
4
4
|
// src/third-parties/meta-pixel.ts
|
|
5
5
|
const metrics = [
|
|
@@ -16,8 +16,7 @@ function sendFBEvent(name, properties, event_id) {
|
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
18
|
if (metrics.includes(name)) return;
|
|
19
|
-
if (
|
|
20
|
-
if (window.location.host.includes("localhost")) return;
|
|
19
|
+
if (isLocalHost()) return;
|
|
21
20
|
const options = { eventID: event_id };
|
|
22
21
|
const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);
|
|
23
22
|
if (type === "track") window.fbq(type, fbEventName, fbEventProperties, options);
|