@shware/analytics 8.15.0 → 8.16.0
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/attribution/classify.cjs +15 -3
- package/dist/attribution/classify.cjs.map +1 -1
- package/dist/attribution/classify.d.cts +2 -1
- package/dist/attribution/classify.d.cts.map +1 -1
- package/dist/attribution/classify.d.mts +2 -1
- package/dist/attribution/classify.d.mts.map +1 -1
- package/dist/attribution/classify.mjs +15 -3
- package/dist/attribution/classify.mjs.map +1 -1
- package/dist/attribution/vocabulary.cjs +100 -19
- package/dist/attribution/vocabulary.cjs.map +1 -1
- package/dist/attribution/vocabulary.d.cts +16 -4
- package/dist/attribution/vocabulary.d.cts.map +1 -1
- package/dist/attribution/vocabulary.d.mts +16 -4
- package/dist/attribution/vocabulary.d.mts.map +1 -1
- package/dist/attribution/vocabulary.mjs +100 -19
- package/dist/attribution/vocabulary.mjs.map +1 -1
- package/dist/bot/index.cjs +39 -1
- package/dist/bot/index.cjs.map +1 -1
- package/dist/bot/index.d.cts +3 -2
- package/dist/bot/index.d.cts.map +1 -1
- package/dist/bot/index.d.mts +3 -2
- package/dist/bot/index.d.mts.map +1 -1
- package/dist/bot/index.mjs +39 -1
- package/dist/bot/index.mjs.map +1 -1
- package/dist/schema/index.cjs +3 -1
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +18 -6
- package/dist/schema/index.d.cts.map +1 -1
- package/dist/schema/index.d.mts +18 -6
- package/dist/schema/index.d.mts.map +1 -1
- package/dist/schema/index.mjs +3 -1
- package/dist/schema/index.mjs.map +1 -1
- package/dist/server/openai-conversions-api.cjs +1 -0
- package/dist/server/openai-conversions-api.cjs.map +1 -1
- package/dist/server/openai-conversions-api.d.cts.map +1 -1
- package/dist/server/openai-conversions-api.d.mts.map +1 -1
- package/dist/server/openai-conversions-api.mjs +1 -0
- package/dist/server/openai-conversions-api.mjs.map +1 -1
- package/dist/track/types.d.cts +3 -1
- package/dist/track/types.d.cts.map +1 -1
- package/dist/track/types.d.mts +3 -1
- package/dist/track/types.d.mts.map +1 -1
- package/dist/web/index.cjs +3 -1
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts.map +1 -1
- package/dist/web/index.d.mts.map +1 -1
- package/dist/web/index.mjs +3 -1
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/page-key.cjs +4 -2
- package/dist/web/page-key.cjs.map +1 -1
- package/dist/web/page-key.d.cts.map +1 -1
- package/dist/web/page-key.d.mts.map +1 -1
- package/dist/web/page-key.mjs +4 -2
- package/dist/web/page-key.mjs.map +1 -1
- package/package.json +1 -1
package/dist/web/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["uuidv4","Bowser"],"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport { parseCookie } from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport { parseGcl, parseUetMsclkid } from '../click-id/index';\nimport { keys } from '../constants/storage';\nimport { type Link, getLink } from '../link/index';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\nimport { getPageKey } from './page-key';\n\n// lib.dom types `crypto.randomUUID` as always present, but it is missing in insecure contexts\n// and older browsers, so probe it before use.\nfunction randomUUID(): string {\n return (crypto as Partial<Crypto>).randomUUID ? crypto.randomUUID() : uuidv4();\n}\n\nexport function getDeviceId() {\n const cached = config.storage.getItem(keys.device_id);\n if (cached) return cached;\n const id = randomUUID();\n config.storage.setItem(keys.device_id, id);\n return id;\n}\n\n/**\n * The current page load, keyed by the page it was loaded at. A module variable and nothing more\n * persistent: the id must die with the page (a reload is a new page load, and storage would\n * carry it over — or, shared across tabs, let two pages overwrite each other's).\n *\n * Keyed by `getPageKey` because that is what the SDK's own `page_view` fires on (see\n * `useWebAnalytics`): the id exists to link an event to the `page_view` of the page it happened\n * on, so it must rotate exactly when a `page_view` is sent — path or query change, yes; hash\n * change or tracking-parameter cleanup, no.\n */\nlet pageLoad: { page: string; id: string } | undefined;\n\nfunction getPageLoadId(page: string): string {\n if (pageLoad?.page !== page) pageLoad = { page, id: randomUUID() };\n return pageLoad.id;\n}\n\nconst links = new Map<string, Promise<Link | null>>();\n\n/**\n * `getTags` runs once per event now, and the link a `?s=` id points at cannot change while the\n * page is open, so an uncached lookup would put an identical request on the wire for every\n * event the page sends.\n */\nfunction getCachedLink(id: string) {\n const cached = links.get(id);\n if (cached) return cached;\n const link = getLink(id).then((result) => {\n // A lookup that came back empty must not stick for the lifetime of the page. `getLink`\n // answers null for a network failure as well as for a link that does not exist, and losing\n // the link's utm params for every later event costs more than repeating a rare request.\n if (!result) links.delete(id);\n return result;\n });\n links.set(id, link);\n return link;\n}\n\n/** The user agent cannot change while the page is open, so it is parsed once. */\nlet parser: ReturnType<typeof Bowser.getParser> | undefined;\n\nexport async function getTags() {\n // Read the page before the first await: `getTags` runs when the event happens, and a single\n // page app can navigate while the link lookup below is still in flight.\n const page_location = window.location.href;\n const page_load_id = getPageLoadId(getPageKey(window.location.pathname, window.location.search));\n const page_referrer = document.referrer || undefined;\n const page_title = document.title;\n\n parser ??= Bowser.getParser(window.navigator.userAgent);\n const params = new URLSearchParams(window.location.search);\n const os = parser.getOS();\n const browser = parser.getBrowser();\n const platform = parser.getPlatform();\n const parsed = parseCookie(document.cookie);\n\n const linkId = params.get('s');\n const link = linkId ? await getCachedLink(linkId) : null;\n\n const tags: TrackTags = {\n os: `${os.name} ${os.version}`,\n os_name: os.name,\n os_version: os.version,\n browser: `${browser.name} ${browser.version}`,\n browser_name: browser.name,\n browser_version: browser.version,\n device: platform.model,\n device_id: getDeviceId(),\n device_type: platform.type,\n device_vendor: platform.vendor,\n device_pixel_ratio: window.devicePixelRatio,\n screen_width: window.screen.width,\n screen_height: window.screen.height,\n screen_resolution: `${window.screen.width}x${window.screen.height}`,\n webdriver: navigator.webdriver || undefined,\n release: config.release,\n language: navigator.language,\n time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n page_location,\n page_referrer,\n page_title,\n page_load_id,\n // Meta Ads — _fbc is set server-side (see @shware/analytics/server resolveClickIdCookies)\n fbc: parsed._fbc ?? undefined,\n fbp: parsed._fbp,\n fbclid: params.get('fbclid') ?? undefined,\n ad_id: params.get('ad_id') ?? undefined,\n ad_name: params.get('ad_name') ?? undefined,\n adset_id: params.get('adset_id') ?? undefined,\n adset_name: params.get('adset_name') ?? undefined,\n campaign_id: params.get('campaign_id') ?? undefined,\n campaign_name: params.get('campaign_name') ?? undefined,\n placement: params.get('placement') ?? undefined,\n // Google Ads — _gcl_aw/_gcl_gb are written by gtag and kept alive server-side (see\n // @shware/analytics/server resolveClickIdCookies); the URL wins, the cookie carries the\n // click id to every later page of the visit and to returning visits.\n gclid: params.get('gclid') ?? parseGcl(parsed._gcl_aw)?.clickId,\n gclsrc: params.get('gclsrc') ?? undefined,\n gad_source: params.get('gad_source') ?? undefined,\n gad_campaignid: params.get('gad_campaignid') ?? undefined,\n // Reddit Ads — _rdt_cid is set server-side (see @shware/analytics/server resolveClickIdCookies)\n rdt_cid: params.get('rdt_cid') ?? parsed._rdt_cid ?? undefined,\n rdt_uuid: parsed._rdt_uuid,\n // LinkedIn Ads: get click id from url params or first-party cookie\n li_fat_id: params.get('li_fat_id') ?? parsed.li_fat_id ?? undefined,\n // click ids\n dclid: params.get('dclid') ?? undefined,\n ko_click_id: params.get('ko_click_id') ?? undefined,\n // Microsoft Ads — _uetmsclkid is written by the UET tag and kept alive server-side (see\n // @shware/analytics/server resolveClickIdCookies); the URL wins, the cookie carries the\n // click id to every later page of the visit and to returning visits.\n msclkid: params.get('msclkid') ?? parseUetMsclkid(parsed._uetmsclkid),\n sccid: params.get('sccid') ?? undefined,\n ttclid: params.get('ttclid') ?? undefined,\n twclid: params.get('twclid') ?? undefined,\n wbraid: params.get('wbraid') ?? parseGcl(parsed._gcl_gb)?.clickId,\n gbraid: params.get('gbraid') ?? undefined,\n yclid: params.get('yclid') ?? undefined,\n // utm params\n utm_source: link?.utm_source ?? params.get('utm_source') ?? undefined,\n utm_medium: link?.utm_medium ?? params.get('utm_medium') ?? undefined,\n utm_campaign: link?.utm_campaign ?? params.get('utm_campaign') ?? undefined,\n utm_term: link?.utm_term ?? params.get('utm_term') ?? undefined,\n utm_content: link?.utm_content ?? params.get('utm_content') ?? undefined,\n utm_id: link?.utm_id ?? params.get('utm_id') ?? undefined,\n utm_source_platform:\n link?.utm_source_platform ?? params.get('utm_source_platform') ?? undefined,\n utm_creative_format:\n link?.utm_creative_format ?? params.get('utm_creative_format') ?? undefined,\n utm_marketing_tactic:\n link?.utm_marketing_tactic ?? params.get('utm_marketing_tactic') ?? undefined,\n };\n\n cache.tags = tags;\n return tags;\n}\n\nconst map = new Map<string, string>();\n\nexport const storage: Storage = {\n getItem: (key) => {\n try {\n return localStorage.getItem(key);\n } catch {\n console.error('localStorage is not available');\n return map.get(key) ?? null;\n }\n },\n setItem: (key, value) => {\n try {\n localStorage.setItem(key, value);\n } catch {\n console.error('localStorage is not available');\n map.set(key, value);\n }\n },\n};\n"],"mappings":";;;;;;;;;;;AAYA,SAAS,aAAqB;CAC5B,OAAQ,OAA2B,aAAa,OAAO,WAAW,IAAIA,GAAO;AAC/E;AAEA,SAAgB,cAAc;CAC5B,MAAM,SAAS,OAAO,QAAQ,QAAQ,KAAK,SAAS;CACpD,IAAI,QAAQ,OAAO;CACnB,MAAM,KAAK,WAAW;CACtB,OAAO,QAAQ,QAAQ,KAAK,WAAW,EAAE;CACzC,OAAO;AACT;;;;;;;;;;;AAYA,IAAI;AAEJ,SAAS,cAAc,MAAsB;CAC3C,IAAI,UAAU,SAAS,MAAM,WAAW;EAAE;EAAM,IAAI,WAAW;CAAE;CACjE,OAAO,SAAS;AAClB;AAEA,MAAM,wBAAQ,IAAI,IAAkC;;;;;;AAOpD,SAAS,cAAc,IAAY;CACjC,MAAM,SAAS,MAAM,IAAI,EAAE;CAC3B,IAAI,QAAQ,OAAO;CACnB,MA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AAK,KAAA;EAC5D,cAAc,MAAM,gBAAgB,OAAO,IAAI,cAAc,KAAK,KAAA;EAClE,UAAU,MAAM,YAAY,OAAO,IAAI,UAAU,KAAK,KAAA;EACtD,aAAa,MAAM,eAAe,OAAO,IAAI,aAAa,KAAK,KAAA;EAC/D,QAAQ,MAAM,UAAU,OAAO,IAAI,QAAQ,KAAK,KAAA;EAChD,qBACE,MAAM,uBAAuB,OAAO,IAAI,qBAAqB,KAAK,KAAA;EACpE,qBACE,MAAM,uBAAuB,OAAO,IAAI,qBAAqB,KAAK,KAAA;EACpE,sBACE,MAAM,wBAAwB,OAAO,IAAI,sBAAsB,KAAK,KAAA;CACxE;CAEA,MAAM,OAAO;CACb,OAAO;AACT;AAEA,MAAM,sBAAM,IAAI,IAAoB;AAEpC,MAAa,UAAmB;CAC9B,UAAU,QAAQ;EAChB,IAAI;GACF,OAAO,aAAa,QAAQ,GAAG;EACjC,QAAQ;GACN,QAAQ,MAAM,+BAA+B;GAC7C,OAAO,IAAI,IAAI,GAAG,KAAK;EACzB;CACF;CACA,UAAU,KAAK,UAAU;EACvB,IAAI;GACF,aAAa,QAAQ,KAAK,KAAK;EACjC,QAAQ;GACN,QAAQ,MAAM,+BAA+B;GAC7C,IAAI,IAAI,KAAK,KAAK;EACpB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["uuidv4","Bowser"],"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport { parseCookie } from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport { parseGcl, parseUetMsclkid } from '../click-id/index';\nimport { keys } from '../constants/storage';\nimport { type Link, getLink } from '../link/index';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\nimport { getPageKey } from './page-key';\n\n// lib.dom types `crypto.randomUUID` as always present, but it is missing in insecure contexts\n// and older browsers, so probe it before use.\nfunction randomUUID(): string {\n return (crypto as Partial<Crypto>).randomUUID ? crypto.randomUUID() : uuidv4();\n}\n\nexport function getDeviceId() {\n const cached = config.storage.getItem(keys.device_id);\n if (cached) return cached;\n const id = randomUUID();\n config.storage.setItem(keys.device_id, id);\n return id;\n}\n\n/**\n * The current page load, keyed by the page it was loaded at. A module variable and nothing more\n * persistent: the id must die with the page (a reload is a new page load, and storage would\n * carry it over — or, shared across tabs, let two pages overwrite each other's).\n *\n * Keyed by `getPageKey` because that is what the SDK's own `page_view` fires on (see\n * `useWebAnalytics`): the id exists to link an event to the `page_view` of the page it happened\n * on, so it must rotate exactly when a `page_view` is sent — path or query change, yes; hash\n * change or tracking-parameter cleanup, no.\n */\nlet pageLoad: { page: string; id: string } | undefined;\n\nfunction getPageLoadId(page: string): string {\n if (pageLoad?.page !== page) pageLoad = { page, id: randomUUID() };\n return pageLoad.id;\n}\n\nconst links = new Map<string, Promise<Link | null>>();\n\n/**\n * `getTags` runs once per event now, and the link a `?s=` id points at cannot change while the\n * page is open, so an uncached lookup would put an identical request on the wire for every\n * event the page sends.\n */\nfunction getCachedLink(id: string) {\n const cached = links.get(id);\n if (cached) return cached;\n const link = getLink(id).then((result) => {\n // A lookup that came back empty must not stick for the lifetime of the page. `getLink`\n // answers null for a network failure as well as for a link that does not exist, and losing\n // the link's utm params for every later event costs more than repeating a rare request.\n if (!result) links.delete(id);\n return result;\n });\n links.set(id, link);\n return link;\n}\n\n/** The user agent cannot change while the page is open, so it is parsed once. */\nlet parser: ReturnType<typeof Bowser.getParser> | undefined;\n\nexport async function getTags() {\n // Read the page before the first await: `getTags` runs when the event happens, and a single\n // page app can navigate while the link lookup below is still in flight.\n const page_location = window.location.href;\n const page_load_id = getPageLoadId(getPageKey(window.location.pathname, window.location.search));\n const page_referrer = document.referrer || undefined;\n const page_title = document.title;\n\n parser ??= Bowser.getParser(window.navigator.userAgent);\n const params = new URLSearchParams(window.location.search);\n const os = parser.getOS();\n const browser = parser.getBrowser();\n const platform = parser.getPlatform();\n const parsed = parseCookie(document.cookie);\n\n const linkId = params.get('s');\n const link = linkId ? await getCachedLink(linkId) : null;\n\n const tags: TrackTags = {\n os: `${os.name} ${os.version}`,\n os_name: os.name,\n os_version: os.version,\n browser: `${browser.name} ${browser.version}`,\n browser_name: browser.name,\n browser_version: browser.version,\n device: platform.model,\n device_id: getDeviceId(),\n device_type: platform.type,\n device_vendor: platform.vendor,\n device_pixel_ratio: window.devicePixelRatio,\n screen_width: window.screen.width,\n screen_height: window.screen.height,\n screen_resolution: `${window.screen.width}x${window.screen.height}`,\n webdriver: navigator.webdriver || undefined,\n release: config.release,\n language: navigator.language,\n time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n page_location,\n page_referrer,\n page_title,\n page_load_id,\n // Meta Ads — _fbc is set server-side (see @shware/analytics/server resolveClickIdCookies)\n fbc: parsed._fbc ?? undefined,\n fbp: parsed._fbp,\n fbclid: params.get('fbclid') ?? undefined,\n ad_id: params.get('ad_id') ?? undefined,\n ad_name: params.get('ad_name') ?? undefined,\n adset_id: params.get('adset_id') ?? undefined,\n adset_name: params.get('adset_name') ?? undefined,\n campaign_id: params.get('campaign_id') ?? undefined,\n campaign_name: params.get('campaign_name') ?? undefined,\n placement: params.get('placement') ?? undefined,\n // Google Ads — _gcl_aw/_gcl_gb are written by gtag and kept alive server-side (see\n // @shware/analytics/server resolveClickIdCookies); the URL wins, the cookie carries the\n // click id to every later page of the visit and to returning visits.\n gclid: params.get('gclid') ?? parseGcl(parsed._gcl_aw)?.clickId,\n gclsrc: params.get('gclsrc') ?? undefined,\n gad_source: params.get('gad_source') ?? undefined,\n gad_campaignid: params.get('gad_campaignid') ?? undefined,\n // Reddit Ads — _rdt_cid is set server-side (see @shware/analytics/server resolveClickIdCookies)\n rdt_cid: params.get('rdt_cid') ?? parsed._rdt_cid ?? undefined,\n rdt_uuid: parsed._rdt_uuid,\n // LinkedIn Ads: get click id from url params or first-party cookie\n li_fat_id: params.get('li_fat_id') ?? parsed.li_fat_id ?? undefined,\n // click ids\n dclid: params.get('dclid') ?? undefined,\n ko_click_id: params.get('ko_click_id') ?? undefined,\n // Microsoft Ads — _uetmsclkid is written by the UET tag and kept alive server-side (see\n // @shware/analytics/server resolveClickIdCookies); the URL wins, the cookie carries the\n // click id to every later page of the visit and to returning visits.\n msclkid: params.get('msclkid') ?? parseUetMsclkid(parsed._uetmsclkid),\n // Snapchat appends `ScCid`, and URL parameters are case-sensitive.\n ScCid: params.get('ScCid') ?? undefined,\n ttclid: params.get('ttclid') ?? undefined,\n twclid: params.get('twclid') ?? undefined,\n wbraid: params.get('wbraid') ?? parseGcl(parsed._gcl_gb)?.clickId,\n gbraid: params.get('gbraid') ?? undefined,\n yclid: params.get('yclid') ?? undefined,\n // From the URL only, not the `__oppref` / `_epik` cookies the pixels keep: a cookie outlives\n // the click, and a click id here names the visit's channel (`CLICK_ID_CHANNELS`).\n oppref: params.get('oppref') ?? undefined,\n epik: params.get('epik') ?? undefined,\n // utm params\n utm_source: link?.utm_source ?? params.get('utm_source') ?? undefined,\n utm_medium: link?.utm_medium ?? params.get('utm_medium') ?? undefined,\n utm_campaign: link?.utm_campaign ?? params.get('utm_campaign') ?? undefined,\n utm_term: link?.utm_term ?? params.get('utm_term') ?? undefined,\n utm_content: link?.utm_content ?? params.get('utm_content') ?? undefined,\n utm_id: link?.utm_id ?? params.get('utm_id') ?? undefined,\n utm_source_platform:\n link?.utm_source_platform ?? params.get('utm_source_platform') ?? undefined,\n utm_creative_format:\n link?.utm_creative_format ?? params.get('utm_creative_format') ?? undefined,\n utm_marketing_tactic:\n link?.utm_marketing_tactic ?? params.get('utm_marketing_tactic') ?? undefined,\n };\n\n cache.tags = tags;\n return tags;\n}\n\nconst map = new Map<string, string>();\n\nexport const storage: Storage = {\n getItem: (key) => {\n try {\n return localStorage.getItem(key);\n } catch {\n console.error('localStorage is not available');\n return map.get(key) ?? null;\n }\n },\n setItem: (key, value) => {\n try {\n localStorage.setItem(key, value);\n } catch {\n console.error('localStorage is not available');\n map.set(key, value);\n }\n },\n};\n"],"mappings":";;;;;;;;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AA+B;GAC7C,OAAO,IAAI,IAAI,GAAG,KAAK;EACzB;CACF;CACA,UAAU,KAAK,UAAU;EACvB,IAAI;GACF,aAAa,QAAQ,KAAK,KAAK;EACjC,QAAQ;GACN,QAAQ,MAAM,+BAA+B;GAC7C,IAAI,IAAI,KAAK,KAAK;EACpB;CACF;AACF"}
|
package/dist/web/page-key.cjs
CHANGED
|
@@ -29,9 +29,11 @@ const TRACKING_PARAMS = /* @__PURE__ */ new Set([
|
|
|
29
29
|
"li_fat_id",
|
|
30
30
|
"ttclid",
|
|
31
31
|
"twclid",
|
|
32
|
-
"
|
|
32
|
+
"ScCid",
|
|
33
33
|
"ko_click_id",
|
|
34
|
-
"yclid"
|
|
34
|
+
"yclid",
|
|
35
|
+
"oppref",
|
|
36
|
+
"epik"
|
|
35
37
|
]);
|
|
36
38
|
function isTrackingParam(name) {
|
|
37
39
|
return name.startsWith("utm_") || TRACKING_PARAMS.has(name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-key.cjs","names":[],"sources":["../../src/web/page-key.ts"],"sourcesContent":["/**\n * What makes two URLs \"the same page\" for page views and the page load id.\n *\n * Path plus query, in line with GA4's enhanced measurement (a history change with a new path\n * or query is a page view), Next.js's documented pattern (`usePathname` + `useSearchParams`)\n * and PostHog's `history_change`: `?page=2` and `?q=shoes` are different pages to a funnel.\n * The hash is not part of it — an in-page anchor is not a navigation, and GA4 ignores\n * fragment-only changes by default too.\n *\n * Tracking parameters are stripped before comparing. A landing page commonly cleans `utm_*`\n * and the ad click ids out of its URL with `replaceState` once they are captured; keyed on the\n * raw query, that cleanup would count as a second page view of the landing page. (GA4 has this\n * quirk; the usual advice is to strip before comparing.) The parameters are the ones `getTags`\n * captures — nothing a page's own state lives in.\n */\n\nconst TRACKING_PARAMS = new Set([\n 'fbclid',\n 'gclid',\n 'gclsrc',\n 'gad_source',\n 'gad_campaignid',\n 'gbraid',\n 'wbraid',\n 'dclid',\n 'msclkid',\n 'rdt_cid',\n 'li_fat_id',\n 'ttclid',\n 'twclid',\n '
|
|
1
|
+
{"version":3,"file":"page-key.cjs","names":[],"sources":["../../src/web/page-key.ts"],"sourcesContent":["/**\n * What makes two URLs \"the same page\" for page views and the page load id.\n *\n * Path plus query, in line with GA4's enhanced measurement (a history change with a new path\n * or query is a page view), Next.js's documented pattern (`usePathname` + `useSearchParams`)\n * and PostHog's `history_change`: `?page=2` and `?q=shoes` are different pages to a funnel.\n * The hash is not part of it — an in-page anchor is not a navigation, and GA4 ignores\n * fragment-only changes by default too.\n *\n * Tracking parameters are stripped before comparing. A landing page commonly cleans `utm_*`\n * and the ad click ids out of its URL with `replaceState` once they are captured; keyed on the\n * raw query, that cleanup would count as a second page view of the landing page. (GA4 has this\n * quirk; the usual advice is to strip before comparing.) The parameters are the ones `getTags`\n * captures — nothing a page's own state lives in.\n */\n\nconst TRACKING_PARAMS = new Set([\n 'fbclid',\n 'gclid',\n 'gclsrc',\n 'gad_source',\n 'gad_campaignid',\n 'gbraid',\n 'wbraid',\n 'dclid',\n 'msclkid',\n 'rdt_cid',\n 'li_fat_id',\n 'ttclid',\n 'twclid',\n 'ScCid',\n 'ko_click_id',\n 'yclid',\n 'oppref',\n 'epik',\n]);\n\nfunction isTrackingParam(name: string): boolean {\n return name.startsWith('utm_') || TRACKING_PARAMS.has(name);\n}\n\n/**\n * `pathname` plus the query with tracking parameters removed and the rest sorted, so two URLs\n * that differ only in tracking decoration or parameter order map to one key.\n */\nexport function getPageKey(pathname: string, search = ''): string {\n const params = new URLSearchParams(search);\n for (const name of Array.from(params.keys())) {\n if (isTrackingParam(name)) params.delete(name);\n }\n params.sort();\n const query = params.toString();\n return query ? `${pathname}?${query}` : pathname;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,gBAAgB,MAAuB;CAC9C,OAAO,KAAK,WAAW,MAAM,KAAK,gBAAgB,IAAI,IAAI;AAC5D;;;;;AAMA,SAAgB,WAAW,UAAkB,SAAS,IAAY;CAChE,MAAM,SAAS,IAAI,gBAAgB,MAAM;CACzC,KAAK,MAAM,QAAQ,MAAM,KAAK,OAAO,KAAK,CAAC,GACzC,IAAI,gBAAgB,IAAI,GAAG,OAAO,OAAO,IAAI;CAE/C,OAAO,KAAK;CACZ,MAAM,QAAQ,OAAO,SAAS;CAC9B,OAAO,QAAQ,GAAG,SAAS,GAAG,UAAU;AAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-key.d.cts","names":[],"sources":["../../src/web/page-key.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"page-key.d.cts","names":[],"sources":["../../src/web/page-key.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;wBA6CgB,WAAW,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-key.d.mts","names":[],"sources":["../../src/web/page-key.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"page-key.d.mts","names":[],"sources":["../../src/web/page-key.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;wBA6CgB,WAAW,kBAAkB"}
|
package/dist/web/page-key.mjs
CHANGED
|
@@ -28,9 +28,11 @@ const TRACKING_PARAMS = /* @__PURE__ */ new Set([
|
|
|
28
28
|
"li_fat_id",
|
|
29
29
|
"ttclid",
|
|
30
30
|
"twclid",
|
|
31
|
-
"
|
|
31
|
+
"ScCid",
|
|
32
32
|
"ko_click_id",
|
|
33
|
-
"yclid"
|
|
33
|
+
"yclid",
|
|
34
|
+
"oppref",
|
|
35
|
+
"epik"
|
|
34
36
|
]);
|
|
35
37
|
function isTrackingParam(name) {
|
|
36
38
|
return name.startsWith("utm_") || TRACKING_PARAMS.has(name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-key.mjs","names":[],"sources":["../../src/web/page-key.ts"],"sourcesContent":["/**\n * What makes two URLs \"the same page\" for page views and the page load id.\n *\n * Path plus query, in line with GA4's enhanced measurement (a history change with a new path\n * or query is a page view), Next.js's documented pattern (`usePathname` + `useSearchParams`)\n * and PostHog's `history_change`: `?page=2` and `?q=shoes` are different pages to a funnel.\n * The hash is not part of it — an in-page anchor is not a navigation, and GA4 ignores\n * fragment-only changes by default too.\n *\n * Tracking parameters are stripped before comparing. A landing page commonly cleans `utm_*`\n * and the ad click ids out of its URL with `replaceState` once they are captured; keyed on the\n * raw query, that cleanup would count as a second page view of the landing page. (GA4 has this\n * quirk; the usual advice is to strip before comparing.) The parameters are the ones `getTags`\n * captures — nothing a page's own state lives in.\n */\n\nconst TRACKING_PARAMS = new Set([\n 'fbclid',\n 'gclid',\n 'gclsrc',\n 'gad_source',\n 'gad_campaignid',\n 'gbraid',\n 'wbraid',\n 'dclid',\n 'msclkid',\n 'rdt_cid',\n 'li_fat_id',\n 'ttclid',\n 'twclid',\n '
|
|
1
|
+
{"version":3,"file":"page-key.mjs","names":[],"sources":["../../src/web/page-key.ts"],"sourcesContent":["/**\n * What makes two URLs \"the same page\" for page views and the page load id.\n *\n * Path plus query, in line with GA4's enhanced measurement (a history change with a new path\n * or query is a page view), Next.js's documented pattern (`usePathname` + `useSearchParams`)\n * and PostHog's `history_change`: `?page=2` and `?q=shoes` are different pages to a funnel.\n * The hash is not part of it — an in-page anchor is not a navigation, and GA4 ignores\n * fragment-only changes by default too.\n *\n * Tracking parameters are stripped before comparing. A landing page commonly cleans `utm_*`\n * and the ad click ids out of its URL with `replaceState` once they are captured; keyed on the\n * raw query, that cleanup would count as a second page view of the landing page. (GA4 has this\n * quirk; the usual advice is to strip before comparing.) The parameters are the ones `getTags`\n * captures — nothing a page's own state lives in.\n */\n\nconst TRACKING_PARAMS = new Set([\n 'fbclid',\n 'gclid',\n 'gclsrc',\n 'gad_source',\n 'gad_campaignid',\n 'gbraid',\n 'wbraid',\n 'dclid',\n 'msclkid',\n 'rdt_cid',\n 'li_fat_id',\n 'ttclid',\n 'twclid',\n 'ScCid',\n 'ko_click_id',\n 'yclid',\n 'oppref',\n 'epik',\n]);\n\nfunction isTrackingParam(name: string): boolean {\n return name.startsWith('utm_') || TRACKING_PARAMS.has(name);\n}\n\n/**\n * `pathname` plus the query with tracking parameters removed and the rest sorted, so two URLs\n * that differ only in tracking decoration or parameter order map to one key.\n */\nexport function getPageKey(pathname: string, search = ''): string {\n const params = new URLSearchParams(search);\n for (const name of Array.from(params.keys())) {\n if (isTrackingParam(name)) params.delete(name);\n }\n params.sort();\n const query = params.toString();\n return query ? `${pathname}?${query}` : pathname;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,gBAAgB,MAAuB;CAC9C,OAAO,KAAK,WAAW,MAAM,KAAK,gBAAgB,IAAI,IAAI;AAC5D;;;;;AAMA,SAAgB,WAAW,UAAkB,SAAS,IAAY;CAChE,MAAM,SAAS,IAAI,gBAAgB,MAAM;CACzC,KAAK,MAAM,QAAQ,MAAM,KAAK,OAAO,KAAK,CAAC,GACzC,IAAI,gBAAgB,IAAI,GAAG,OAAO,OAAO,IAAI;CAE/C,OAAO,KAAK;CACZ,MAAM,QAAQ,OAAO,SAAS;CAC9B,OAAO,QAAQ,GAAG,SAAS,GAAG,UAAU;AAC1C"}
|