react-query-firebase 1.1.0 → 1.2.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.
@@ -1,2 +1,3 @@
1
1
  export * from "./useLogEvent";
2
2
  export * from "./useAnalytics";
3
+ export * from "./useSetAnalyticsCollectionEnabled";
@@ -1,2 +1,3 @@
1
1
  export * from "./useLogEvent";
2
2
  export * from "./useAnalytics";
3
+ export * from "./useSetAnalyticsCollectionEnabled";
@@ -0,0 +1,10 @@
1
+ type UseSetAnalyticsCollectionEnabledOptions = {
2
+ enabled?: boolean;
3
+ };
4
+ /**
5
+ * Custom hook to enable or disable analytics collection
6
+ * @param {Object} options - The options for hook.
7
+ * @param {string} options.enabled - Flag that identifies if analytics collection is enabled.
8
+ */
9
+ export declare const useSetAnalyticsCollectionEnabled: ({ enabled }: UseSetAnalyticsCollectionEnabledOptions) => void;
10
+ export {};
@@ -0,0 +1,16 @@
1
+ import { setAnalyticsCollectionEnabled } from "firebase/analytics";
2
+ import { useAnalytics } from "./useAnalytics";
3
+ import { useEffect } from "react";
4
+ /**
5
+ * Custom hook to enable or disable analytics collection
6
+ * @param {Object} options - The options for hook.
7
+ * @param {string} options.enabled - Flag that identifies if analytics collection is enabled.
8
+ */
9
+ export const useSetAnalyticsCollectionEnabled = ({ enabled = false }) => {
10
+ const analytics = useAnalytics();
11
+ useEffect(() => {
12
+ if (analytics) {
13
+ setAnalyticsCollectionEnabled(analytics, enabled);
14
+ }
15
+ }, [analytics]);
16
+ };
package/package.json CHANGED
@@ -60,5 +60,5 @@
60
60
  "docs:build": "vitepress build docs",
61
61
  "docs:preview": "vitepress preview docs"
62
62
  },
63
- "version": "1.1.0"
63
+ "version": "1.2.0"
64
64
  }
@@ -1,2 +1,3 @@
1
1
  export * from "./useLogEvent";
2
2
  export * from "./useAnalytics";
3
+ export * from "./useSetAnalyticsCollectionEnabled";
@@ -0,0 +1,22 @@
1
+ import { setAnalyticsCollectionEnabled } from "firebase/analytics";
2
+ import { useAnalytics } from "./useAnalytics";
3
+ import { useEffect } from "react";
4
+
5
+ type UseSetAnalyticsCollectionEnabledOptions = {
6
+ enabled?: boolean;
7
+ };
8
+
9
+ /**
10
+ * Custom hook to enable or disable analytics collection
11
+ * @param {Object} options - The options for hook.
12
+ * @param {string} options.enabled - Flag that identifies if analytics collection is enabled.
13
+ */
14
+ export const useSetAnalyticsCollectionEnabled = ({ enabled = false }: UseSetAnalyticsCollectionEnabledOptions) => {
15
+ const analytics = useAnalytics();
16
+
17
+ useEffect(() => {
18
+ if (analytics) {
19
+ setAnalyticsCollectionEnabled(analytics, enabled);
20
+ }
21
+ }, [analytics]);
22
+ };