-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom headers to track web frameworks usage
- Loading branch information
1 parent
dafae52
commit cdf7b39
Showing
5 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,27 @@ function getGoogApiClientValue(_isUsingGen: boolean): string { | |
} | ||
return str; | ||
} | ||
function getWebFrameworkValue( | ||
This comment has been minimized.
Sorry, something went wrong.
stephenarosaj
Author
Contributor
|
||
_isUsingTanStack: boolean, | ||
_isUsingReact: boolean, | ||
_isUsingAngularFire: boolean | ||
): string { | ||
let str = ''; | ||
if (_isUsingTanStack) { | ||
str += ' tanstack/'; | ||
} | ||
if (_isUsingReact) { | ||
str += ' react/'; | ||
} | ||
if (_isUsingAngularFire) { | ||
str += ' angularfire/'; | ||
} | ||
// no framework SDK used | ||
if (str === '') { | ||
str = 'vanilla/'; | ||
} | ||
return str.trim(); | ||
} | ||
export interface DataConnectFetchBody<T> { | ||
name: string; | ||
operationName: string; | ||
|
@@ -42,14 +63,22 @@ export function dcFetch<T, U>( | |
appId: string | null, | ||
accessToken: string | null, | ||
appCheckToken: string | null, | ||
_isUsingGen: boolean | ||
_isUsingGen: boolean, | ||
_isUsingTanStack: boolean, | ||
_isUsingReact: boolean, | ||
_isUsingAngularFire: boolean | ||
): Promise<{ data: T; errors: Error[] }> { | ||
if (!connectFetch) { | ||
throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!'); | ||
} | ||
const headers: HeadersInit = { | ||
'Content-Type': 'application/json', | ||
'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen) | ||
'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen), | ||
'X-Firebase-DataConnect-Web-Frameworks': getWebFrameworkValue( | ||
This comment has been minimized.
Sorry, something went wrong.
stephenarosaj
Author
Contributor
|
||
_isUsingTanStack, | ||
_isUsingReact, | ||
_isUsingAngularFire | ||
) | ||
}; | ||
if (accessToken) { | ||
headers['X-Firebase-Auth-Token'] = accessToken; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i split TanStack from the frameworks because i was trying to follow the bug's description closely, but based on conversation with Maneesh, it seems like when using the AngularFire SDK, users will pretty much always be using the TanStack bindings - that's already the case with the React SDK, so maybe this shouldn't be tracked separately?