@shware/analytics 13.0.4 → 13.1.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/README.md +3 -1
- package/dist/native/index.cjs +1 -1
- package/dist/native/index.mjs +1 -1
- package/dist/react-router/index.cjs +1 -1
- package/dist/react-router/index.mjs +1 -1
- package/dist/tanstack/analytics.cjs +1 -1
- package/dist/tanstack/analytics.mjs +1 -1
- package/dist/third-parties/google-analytics.cjs +1 -1
- package/dist/third-parties/google-analytics.cjs.map +1 -1
- package/dist/third-parties/google-analytics.mjs +1 -1
- package/dist/third-parties/google-analytics.mjs.map +1 -1
- package/dist/third-parties/meta-pixel.cjs +1 -1
- package/dist/third-parties/meta-pixel.mjs +1 -1
- package/dist/third-parties/posthog.cjs +7 -2
- package/dist/third-parties/posthog.cjs.map +1 -1
- package/dist/third-parties/posthog.d.cts +3 -0
- package/dist/third-parties/posthog.d.cts.map +1 -1
- package/dist/third-parties/posthog.d.mts +3 -0
- package/dist/third-parties/posthog.d.mts.map +1 -1
- package/dist/third-parties/posthog.mjs +7 -2
- package/dist/third-parties/posthog.mjs.map +1 -1
- package/dist/track/gtag.cjs.map +1 -1
- package/dist/track/gtag.d.cts +2 -2
- package/dist/track/gtag.d.mts +2 -2
- package/dist/track/gtag.mjs.map +1 -1
- package/dist/track/index.cjs +4 -1
- package/dist/track/index.cjs.map +1 -1
- package/dist/track/index.d.cts +6 -2
- package/dist/track/index.d.cts.map +1 -1
- package/dist/track/index.d.mts +6 -2
- package/dist/track/index.d.mts.map +1 -1
- package/dist/track/index.mjs +4 -1
- package/dist/track/index.mjs.map +1 -1
- package/dist/track/once.cjs +11 -1
- package/dist/track/once.cjs.map +1 -1
- package/dist/track/once.d.cts +7 -1
- package/dist/track/once.d.cts.map +1 -1
- package/dist/track/once.d.mts +7 -1
- package/dist/track/once.d.mts.map +1 -1
- package/dist/track/once.mjs +11 -1
- package/dist/track/once.mjs.map +1 -1
- package/dist/visitor/id.cjs.map +1 -1
- package/dist/visitor/id.mjs.map +1 -1
- package/dist/visitor/index.cjs +13 -4
- package/dist/visitor/index.cjs.map +1 -1
- package/dist/visitor/index.d.cts +6 -1
- package/dist/visitor/index.d.cts.map +1 -1
- package/dist/visitor/index.d.mts +6 -1
- package/dist/visitor/index.d.mts.map +1 -1
- package/dist/visitor/index.mjs +13 -4
- package/dist/visitor/index.mjs.map +1 -1
- package/dist/web/index.cjs +1 -1
- package/dist/web/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/visitor/index.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { config } from '../setup/index';\nimport { track } from '../track/index';\n\nexport { visitorId } from './id';\n\n/**\n * The event that binds the visitor to the user who signed in on it: the server sets the visitor's\n * `user_id` and `distinct_id` from its `user_id` property, in the transaction that stores the\n * batch — which also creates the visitor when it is new, so the binding can never arrive before it.\n */\nexport const IDENTIFY_EVENT = 'identify';\n\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/visitor/index.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { config } from '../setup/index';\nimport { track } from '../track/index';\n\nexport { visitorId } from './id';\n\n/**\n * The event that binds the visitor to the user who signed in on it: the server sets the visitor's\n * `user_id` and `distinct_id` from its `user_id` property, in the transaction that stores the\n * batch — which also creates the visitor when it is new, so the binding can never arrive before it.\n */\nexport const IDENTIFY_EVENT = 'identify';\n\n/**\n * The user this page has identified the visitor as: identify once per user, not per call. Cleared\n * on sign-out, so the same user signing back in on this page is identified again.\n */\nlet identified: string | undefined;\n\n/**\n * Hands the signed-in user to the analytics: the third-party user setters (gtag, the pixels) now,\n * and the server through an `identify` event, sent when the user differs from the one this page\n * last identified — a host calls this on every page load once someone is signed in. Like any\n * event it goes with the next batch or the page-hide beacon; `user_data` is handed to the setters\n * only, never stored with the event.\n *\n * Without a `user_id` (missing, or `''`) it signs the visitor out: `setVisitor({})` is\n * sign-out. Nothing goes to the server, the setters get `distinct_id: null` (PostHog resets its\n * identity on it), and the next sign-in is identified again even if it is the same user. Still\n * `track('logout')` as usual — that is an ordinary event, and resets nothing.\n *\n * Synchronous and never throws: sign-in and sign-out must not fail on analytics.\n */\nexport function setVisitor(dto: Omit<UpdateVisitorDTO, 'tags'>) {\n if (!dto.user_id) {\n identified = undefined;\n } else if (dto.user_id !== identified) {\n identified = dto.user_id;\n track(IDENTIFY_EVENT, { user_id: dto.user_id }, { enableThirdPartyTracking: false });\n }\n\n // Once bound, the server's person key for the visitor is the user's id, so the setters are told\n // that rather than waiting for the server to say it.\n const identity = { ...dto, distinct_id: dto.user_id || null };\n config.thirdPartyUserSetters.forEach((setter) => {\n try {\n setter(identity);\n } catch (e: unknown) {\n // One third-party script does not get to stop the others.\n if (e instanceof Error) console.log(e.message);\n }\n });\n}\n"],"mappings":";;;;;;;;;AAWA,MAAa,iBAAiB;;;;;AAM9B,IAAI;;;;;;;;;;;;;;;AAgBJ,SAAgB,WAAW,KAAqC;CAC9D,IAAI,CAAC,IAAI,SACP,aAAa,KAAA;MACR,IAAI,IAAI,YAAY,YAAY;EACrC,aAAa,IAAI;EACjB,MAAM,gBAAgB,EAAE,SAAS,IAAI,QAAQ,GAAG,EAAE,0BAA0B,MAAM,CAAC;CACrF;CAIA,MAAM,WAAW;EAAE,GAAG;EAAK,aAAa,IAAI,WAAW;CAAK;CAC5D,OAAO,sBAAsB,SAAS,WAAW;EAC/C,IAAI;GACF,OAAO,QAAQ;EACjB,SAAS,GAAY;GAEnB,IAAI,aAAa,OAAO,QAAQ,IAAI,EAAE,OAAO;EAC/C;CACF,CAAC;AACH"}
|
package/dist/web/index.cjs
CHANGED
|
@@ -3,8 +3,8 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
|
3
3
|
const require_setup_index = require("../setup/index.cjs");
|
|
4
4
|
const require_constants_storage = require("../constants/storage.cjs");
|
|
5
5
|
const require_link_index = require("../link/index.cjs");
|
|
6
|
-
const require_es5$1 = require("../node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.cjs");
|
|
7
6
|
const require_utils_redact_url = require("../utils/redact-url.cjs");
|
|
7
|
+
const require_es5$1 = require("../node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.cjs");
|
|
8
8
|
const require_web_page_key = require("./page-key.cjs");
|
|
9
9
|
let uuid = require("uuid");
|
|
10
10
|
let cookie = require("cookie");
|
package/dist/web/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { __toESM } from "../_virtual/_rolldown/runtime.mjs";
|
|
|
2
2
|
import { cache, config } from "../setup/index.mjs";
|
|
3
3
|
import { keys } from "../constants/storage.mjs";
|
|
4
4
|
import { getLink } from "../link/index.mjs";
|
|
5
|
-
import { require_es5 } from "../node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.mjs";
|
|
6
5
|
import { redactUrl } from "../utils/redact-url.mjs";
|
|
6
|
+
import { require_es5 } from "../node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.mjs";
|
|
7
7
|
import { getPageKey } from "./page-key.mjs";
|
|
8
8
|
import { v4 } from "uuid";
|
|
9
9
|
import { parseCookie } from "cookie";
|