-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Correlation headers are not always set in vue.js SPA #1668
Comments
Hi @JnsSo , |
@Karlie-777 thank you for your response. Unfortunately manually supplying the domains in devServer: {
compress: true,
disableHostCheck: true,
proxy: {
"^/api/serviceA": {
ws: true,
target: "http://localhost:23006",
pathRewrite: {"^/api/serviceA": ""},
},
....
} Meanwhile we tried the approach (mentioned here: microsoft/applicationinsights-react-native#9) to manually call |
Hi @JnsSo and I used sdk 2.7.0 here is my services/UserService.js
and here is my vue.config
|
@Karlie-777 Thank you for your efforts. I updated the sdk to 2.7.0 but in our case it still does not work. Based on your answer the issue seems to be related to Apollo, because we are facing this problem only with some GraphQL requests (as mentioned in the initial description). This is how we create our apollo client reduced to the essential: ...
const httpLink = createHttpLink({
uri: ...,
credentials: "include",
fetchOptions: {
credentials: "include"
}
});
...
const link = new ApolloLink((operation, forward) => {
// already tried to set headers manually as described here:
// https://www.apollographql.com/docs/react/networking/advanced-http-networking/
return forward(operation);
});
const apolloLink = split(
({query}: any) => {
const {kind, operation}: IDefinintion = getMainDefinition(query);
return kind === "OperationDefinition" && operation === "subscription";
},
from([link, wsLink]),
from([link, httpLink])
);
const apolloClient = new ApolloClient({
link: apolloLink,
cache: new InMemoryCache({fragmentMatcher}),
...options
});
... I do not really understand why some graphql requests are getting tracked correctly while others are missing. By our implementation there is no difference between correctly tracked requests and not-tracked requests. |
@JnsSo Or do you mind providing us with a fiddler trace/network screenshots so that we can better target problems? thanks! |
Sorry for the delay. I will provide the requested information within the next days. |
@Karlie-777 Thank you for pointing that out. The issue is related to our own apollo client cache. If we create a new apollo client instance for every single request then all headers are set and the correlation is working. ApplicationInsights-JS/extensions/applicationinsights-dependencies-js/src/ajax.ts Line 636 in a0e573e
|
@JnsSo Please let us know if this works! |
@Karlie-777 Hi, thank you. That solved our issue. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi,
we have noticed that in our vue.js SPA the correlation headers are not always set. It seems to be quite similar to microsoft/applicationinsights-react-native#9 but not identical. In our case the page changes are tracked correctly but single GraphQL requests are not linked with the corresponding GraphQL API endpoint in our backend services. By analysing the requests we discovered that sometimes the headers
Request-Id
,Traceparent
orRequest-Context
are missing.We have ensured that all requests are build and getting executed the same way. Of course the graphql requests normally are executed to different times during the vue component lifecycle hooks but even if change this to a consistent approach e.g. mounted or beforeRouteEnter the headers are missing for some requests.
Could this issue nevertheless be related to the SPA structure?
Due this issue our end-to-end-transactions are not working correctly because now the transactions are starting inside our backend services without any relation to our frontend.
Steps to Reproduce
OS/Browser: -
SDK Version [e.g. 22]:
"@microsoft/applicationinsights-web": "^2.6.5",
How you initialized the SDK:
Expected behavior
Additional context
Frontend: vue 2.6.12
Backend services: ASP.NET Core 5.0
So far we could not find any workaround for this problem.
The text was updated successfully, but these errors were encountered: