Skip to content

Commit b7050ef

Browse files
authored
feat(fdc): Add User Agent Tracking to FDC (#164)
* Fixed autocomplete * Added tracking to fdc * Removed angular changes * Upped the required version of firebase * updated to use 11.3.0 * Used correct enums * reverted prelude changes * Removed only
1 parent e588977 commit b7050ef

File tree

7 files changed

+257
-242
lines changed

7 files changed

+257
-242
lines changed

dataconnect-sdk/js/default-connector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"./package.json": "./package.json"
2121
},
2222
"peerDependencies": {
23-
"firebase": "^10.14.0 || ^11.0.0"
23+
"firebase": "^10.14.0 || ^11.3.0"
2424
}
2525
}

examples/react-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@tanstack/react-query": "^5.55.4",
1313
"@tanstack-query-firebase/react": "link:../../packages/react",
1414
"@dataconnect/default-connector": "workspace:*",
15-
"firebase": "^11.0.0",
15+
"firebase": "^11.3.0",
1616
"next": "15.1.0",
1717
"react": "^19.0.0",
1818
"react-dom": "^19.0.0"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@tanstack/react-query": "^5.55.4",
1414
"@types/jsonwebtoken": "^9.0.7",
1515
"@vitest/coverage-istanbul": "^2.0.5",
16-
"firebase": "^11.1.0",
16+
"firebase": "^11.3.0",
1717
"happy-dom": "^15.7.3",
1818
"jsonwebtoken": "^9.0.2",
1919
"react": "^19.0.0",

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@dataconnect/default-connector": "workspace:*"
4343
},
4444
"peerDependencies": {
45-
"firebase": "^11",
45+
"firebase": "^11.3.0",
4646
"@tanstack/react-query": "^5"
4747
}
4848
}

packages/react/src/data-connect/useDataConnectMutation.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import {
55
} from "@tanstack/react-query";
66
import type { FirebaseError } from "firebase/app";
77
import {
8+
CallerSdkType,
9+
CallerSdkTypeEnum,
810
type DataConnect,
911
type MutationRef,
1012
type QueryRef,
1113
executeMutation,
1214
} from "firebase/data-connect";
13-
import type { FlattenedMutationResult } from "./types";
15+
import { type FlattenedMutationResult } from "./types";
1416

1517
export type useDataConnectMutationOptions<
1618
TData = unknown,
@@ -48,10 +50,10 @@ export function useDataConnectMutation<
4850
FlattenedMutationResult<Data, Variables>,
4951
FirebaseError,
5052
Variables
51-
>
53+
>,
54+
_callerSdkType: CallerSdkType = CallerSdkTypeEnum.TanstackReactCore
5255
) {
5356
const queryClient = useQueryClient();
54-
5557
return useMutation<
5658
FlattenedMutationResult<Data, Variables>,
5759
FirebaseError,
@@ -78,6 +80,9 @@ export function useDataConnectMutation<
7880
},
7981
mutationFn: async (variables) => {
8082
const mutationRef = typeof ref === "function" ? ref(variables) : ref;
83+
84+
// @ts-expect-error function is hidden under `DataConnect`.
85+
mutationRef.dataConnect._setCallerSdkType(_callerSdkType);
8186
const response = await executeMutation<Data, Variables>(mutationRef);
8287

8388
return {

packages/react/src/data-connect/useDataConnectQuery.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import {
44
type QueryRef,
55
type QueryResult,
66
executeQuery,
7+
CallerSdkType,
8+
CallerSdkTypeEnum
79
} from "firebase/data-connect";
810
import type { PartialBy } from "../../utils";
9-
import type { FlattenedQueryResult } from "./types";
11+
import { FlattenedQueryResult } from "./types";
1012

1113
export type useDataConnectQueryOptions<
1214
TData = unknown,
@@ -19,6 +21,7 @@ export function useDataConnectQuery<Data = unknown, Variables = unknown>(
1921
FlattenedQueryResult<Data, Variables>,
2022
FirebaseError
2123
>,
24+
_callerSdkType: CallerSdkType = CallerSdkTypeEnum.TanstackReactCore
2225
) {
2326
let queryRef: QueryRef<Data, Variables>;
2427
let initialData: FlattenedQueryResult<Data, Variables> | undefined;
@@ -34,7 +37,8 @@ export function useDataConnectQuery<Data = unknown, Variables = unknown>(
3437
} else {
3538
queryRef = refOrResult;
3639
}
37-
40+
// @ts-expect-error function is hidden under `DataConnect`.
41+
queryRef.dataConnect._setCallerSdkType(_callerSdkType);
3842
return useQuery<FlattenedQueryResult<Data, Variables>, FirebaseError>({
3943
...options,
4044
initialData,

0 commit comments

Comments
 (0)