@activescott/analytics 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lazy.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code-split-safe entry point. Nothing in this module graph statically
|
|
3
|
+
* imports posthog-js — the initialized tree (and posthog-js with it) loads
|
|
4
|
+
* behind React.lazy inside LazyPostHogProvider — so consumers bundling from
|
|
5
|
+
* here never pay for the library until it is enabled. Import the static
|
|
6
|
+
* PostHogProvider from the package root instead when tree-shaking the barrel
|
|
7
|
+
* is acceptable.
|
|
8
|
+
*/
|
|
9
|
+
export { LazyPostHogProvider, type LazyPostHogProviderProps, } from "./post-hog-lazy-provider.js";
|
|
10
|
+
export { captureAnalyticsEvent, type AnalyticsCapture, } from "./capture-client.js";
|
|
11
|
+
export { useAnalyticsCapture } from "./use-analytics-capture.js";
|
|
12
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../src/lazy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,qBAAqB,EACrB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA"}
|
package/dist/lazy.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code-split-safe entry point. Nothing in this module graph statically
|
|
3
|
+
* imports posthog-js — the initialized tree (and posthog-js with it) loads
|
|
4
|
+
* behind React.lazy inside LazyPostHogProvider — so consumers bundling from
|
|
5
|
+
* here never pay for the library until it is enabled. Import the static
|
|
6
|
+
* PostHogProvider from the package root instead when tree-shaking the barrel
|
|
7
|
+
* is acceptable.
|
|
8
|
+
*/
|
|
9
|
+
export { LazyPostHogProvider, } from "./post-hog-lazy-provider.js";
|
|
10
|
+
export { captureAnalyticsEvent, } from "./capture-client.js";
|
|
11
|
+
export { useAnalyticsCapture } from "./use-analytics-capture.js";
|
|
12
|
+
//# sourceMappingURL=lazy.js.map
|
package/dist/lazy.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.js","sourceRoot":"","sources":["../src/lazy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,mBAAmB,GAEpB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,qBAAqB,GAEtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-hog-lazy-provider.d.ts","sourceRoot":"","sources":["../src/post-hog-lazy-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAQ/C,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAA;CACpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,MAAM,EACN,OAAO,EACP,IAAI,GACL,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"post-hog-lazy-provider.d.ts","sourceRoot":"","sources":["../src/post-hog-lazy-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAQ/C,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAA;CACpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,MAAM,EACN,OAAO,EACP,IAAI,GACL,EAAE,wBAAwB,sCAmB1B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Suspense, lazy } from "react";
|
|
2
|
+
import { Suspense, lazy, useEffect, useState } from "react";
|
|
3
3
|
const PostHogInit = lazy(() => import("./post-hog-init.js").then((module) => ({
|
|
4
4
|
default: module.PostHogInit,
|
|
5
5
|
})));
|
|
@@ -15,7 +15,17 @@ const PostHogInit = lazy(() => import("./post-hog-init.js").then((module) => ({
|
|
|
15
15
|
* needed.
|
|
16
16
|
*/
|
|
17
17
|
export function LazyPostHogProvider({ enabled, apiKey, options, user, }) {
|
|
18
|
-
|
|
18
|
+
// Client-only: the initialized tree pulls in posthog-js, whose react entry
|
|
19
|
+
// point Node's ESM resolver refuses (UMD-only subpath) and which assumes
|
|
20
|
+
// browser globals. Rendering it during SSR throws inside the Suspense
|
|
21
|
+
// boundary — the shell still streams, but the response status flips to 500
|
|
22
|
+
// with no log. Gating on mount keeps SSR output identical (null either
|
|
23
|
+
// way), so hydration stays clean.
|
|
24
|
+
const [mounted, setMounted] = useState(false);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setMounted(true);
|
|
27
|
+
}, []);
|
|
28
|
+
if (!enabled || !apiKey || !mounted) {
|
|
19
29
|
return null;
|
|
20
30
|
}
|
|
21
31
|
return (_jsx(Suspense, { fallback: null, children: _jsx(PostHogInit, { apiKey: apiKey, options: options, user: user }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-hog-lazy-provider.js","sourceRoot":"","sources":["../src/post-hog-lazy-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"post-hog-lazy-provider.js","sourceRoot":"","sources":["../src/post-hog-lazy-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAG3D,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAC5B,MAAM,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC,WAAW;CAC5B,CAAC,CAAC,CACJ,CAAA;AAeD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,OAAO,EACP,MAAM,EACN,OAAO,EACP,IAAI,GACqB;IACzB,2EAA2E;IAC3E,yEAAyE;IACzE,sEAAsE;IACtE,2EAA2E;IAC3E,uEAAuE;IACvE,kCAAkC;IAClC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC7C,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,IAAI,CAAC,CAAA;IAClB,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACpC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,CACL,KAAC,QAAQ,IAAC,QAAQ,EAAE,IAAI,YACtB,KAAC,WAAW,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAI,GACpD,CACZ,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activescott/analytics",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"types": "./dist/proxy.d.ts",
|
|
15
15
|
"import": "./dist/proxy.js"
|
|
16
16
|
},
|
|
17
|
+
"./lazy": {
|
|
18
|
+
"types": "./dist/lazy.d.ts",
|
|
19
|
+
"import": "./dist/lazy.js"
|
|
20
|
+
},
|
|
17
21
|
"./hosts": {
|
|
18
22
|
"types": "./dist/hosts.d.ts",
|
|
19
23
|
"import": "./dist/hosts.js"
|
|
@@ -22,6 +26,7 @@
|
|
|
22
26
|
"files": [
|
|
23
27
|
"dist"
|
|
24
28
|
],
|
|
29
|
+
"sideEffects": false,
|
|
25
30
|
"scripts": {
|
|
26
31
|
"build": "tsc -p tsconfig.build.json",
|
|
27
32
|
"typecheck": "tsc --noEmit",
|