@faststats/react 0.0.4 → 0.0.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/index.d.ts CHANGED
@@ -1,11 +1,6 @@
1
- import { ConsentMode, WebAnalytics, WebAnalyticsOptions } from "@faststats/web";
1
+ import { ConsentMode, WebAnalyticsOptions } from "@faststats/web";
2
2
 
3
3
  //#region src/analytics.d.ts
4
- declare global {
5
- interface Window {
6
- __FA_reactAnalyticsInstance?: WebAnalytics;
7
- }
8
- }
9
4
  type AnalyticsProps = WebAnalyticsOptions;
10
5
  declare function Analytics(props: AnalyticsProps): null;
11
6
  //#endregion
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { WebAnalytics } from "@faststats/web";
3
+ import { WebAnalytics, getInstance } from "@faststats/web";
4
4
  import { useEffect, useRef } from "react";
5
5
 
6
6
  //#region src/instance.ts
@@ -16,12 +16,11 @@ function Analytics(props) {
16
16
  configRef.current = props;
17
17
  useEffect(() => {
18
18
  if (typeof window === "undefined") return;
19
- const wa = window.__FA_reactAnalyticsInstance ?? new WebAnalytics(configRef.current);
19
+ const wa = getInstance() ?? new WebAnalytics(configRef.current);
20
20
  const consentMode = configRef.current.consent?.mode;
21
21
  if (consentMode !== void 0) wa.setConsentMode(consentMode);
22
- window.__FA_reactAnalyticsInstance = wa;
23
22
  setInstance(wa);
24
- return () => setInstance(window.__FA_reactAnalyticsInstance ?? null);
23
+ return () => setInstance(null);
25
24
  }, []);
26
25
  return null;
27
26
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@faststats/react",
3
3
  "repository": "https://github.com/faststats-dev/web-analytics",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "react": ">=18"
28
28
  },
29
29
  "dependencies": {
30
- "@faststats/web": "^0.0.4"
30
+ "@faststats/web": "^0.1.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/react": "^19.0.0",