Skip to content

Commit b621c92

Browse files
authored
Merge pull request #42 from Hashnode/stellate-client-tracking
set stellate client headers
2 parents 8ac78da + 00cd780 commit b621c92

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/webembeds-core/src/utils/graphql.ts

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ if (!HASHNODE_GRAPHQL_USER_ACCESS_TOKEN) {
1010
throw new Error("HASHNODE_GRAPHQL_USER_ACCESS_TOKEN is not defined");
1111
}
1212

13+
// client tracking (https://dev.stellate.co/docs/graphql-metrics/clients)
14+
const STELLATE_CLIENT_NAME_HEADER = "x-graphql-client-name";
15+
const STELLATE_CLIENT_VERSION_HEADER = "x-graphql-client-version";
16+
17+
const isServer = typeof window === "undefined";
18+
1319
/**
1420
* Executes a GraphQL query and returns the data and errors.
1521
*/
@@ -25,6 +31,8 @@ export const fetchGraphQL = async (options: {
2531
headers: {
2632
"Content-Type": "application/json",
2733
"hn-trace-app": "Embeds",
34+
[STELLATE_CLIENT_NAME_HEADER]: "webembeds",
35+
[STELLATE_CLIENT_VERSION_HEADER]: isServer ? "server" : "browser",
2836
Authorization: HASHNODE_GRAPHQL_USER_ACCESS_TOKEN,
2937
},
3038
body: JSON.stringify({

0 commit comments

Comments
 (0)