Skip to content

Commit a6df172

Browse files
committed
Fix lint issues
1 parent 967ef07 commit a6df172

File tree

6 files changed

+51
-14
lines changed

6 files changed

+51
-14
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
- **feat(vue): Add TanStack Router integration ([#18359](https://github.com/getsentry/sentry-javascript/pull/18359))**
8+
9+
The `@sentry/vue` package now includes support for TanStack Router. Use `tanstackRouterBrowserTracingIntegration` to automatically instrument pageload and navigation transactions with parameterized routes:
10+
11+
```javascript
12+
import { createApp } from 'vue';
13+
import { createRouter } from '@tanstack/vue-router';
14+
import * as Sentry from '@sentry/vue';
15+
import { tanstackRouterBrowserTracingIntegration } from '@sentry/vue/tanstackrouter';
16+
17+
const router = createRouter({
18+
// your router config
19+
});
20+
21+
Sentry.init({
22+
app,
23+
dsn: '__PUBLIC_DSN__',
24+
integrations: [tanstackRouterBrowserTracingIntegration(router)],
25+
tracesSampleRate: 1.0,
26+
});
27+
```
28+
729
- **feat(nextjs): Add tree-shaking configuration to `webpack` build config ([#18359](https://github.com/getsentry/sentry-javascript/pull/18359))**
830

931
- **feat(replay): Add Request body with `attachRawBodyFromRequest` option ([#18501](https://github.com/getsentry/sentry-javascript/pull/18501))**

dev-packages/e2e-tests/test-applications/vue-tanstack-router/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ This project uses [TanStack Router](https://tanstack.com/router) for Vue.js. The
4040
### Sentry Integration
4141

4242
The app demonstrates:
43+
4344
- TanStack Router browser tracing integration
4445
- Pageload transaction tracking with parameterized routes
4546
- Navigation transaction tracking
@@ -48,6 +49,7 @@ The app demonstrates:
4849
## Testing
4950

5051
The E2E tests verify:
52+
5153
1. Pageload transactions are created with correct route parameters
5254
2. Navigation transactions are properly instrumented
5355
3. Route parameters are captured in transaction data

dev-packages/e2e-tests/test-applications/vue-tanstack-router/src/App.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
<Link to="/posts/$postId" :params="{ postId: '1' }">Post 1</Link>
1010
</li>
1111
<li>
12-
<Link to="/posts/$postId" :params="{ postId: '2' }" id="nav-link">
13-
Post 2
14-
</Link>
12+
<Link to="/posts/$postId" :params="{ postId: '2' }" id="nav-link"> Post 2 </Link>
1513
</li>
1614
</ul>
1715
</nav>

packages/vue/src/pinia.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { addBreadcrumb, addNonEnumerableProperty, getClient, getCurrentScope, ge
22
import type { Ref } from 'vue';
33

44
// Inline Pinia types
5-
type StateTree = Record<string | number | symbol, any>;
5+
type StateTree = Record<string | number | symbol, unknown>;
66
type PiniaPlugin = (context: {
77
store: {
88
$id: string;
@@ -15,8 +15,8 @@ type PiniaPlugin = (context: {
1515
type SentryPiniaPluginOptions = {
1616
attachPiniaState: boolean;
1717
addBreadcrumbs: boolean;
18-
actionTransformer: (action: string) => any;
19-
stateTransformer: (state: Record<string, unknown>) => any;
18+
actionTransformer: (action: string) => unknown;
19+
stateTransformer: (state: Record<string, unknown>) => unknown;
2020
};
2121

2222
const DEFAULT_PINIA_PLUGIN_OPTIONS: SentryPiniaPluginOptions = {

packages/vue/src/tanstackrouter.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ export function tanstackRouterBrowserTracingIntegration<R extends AnyRouter>(
4343
if (instrumentPageLoad && initialWindowLocation) {
4444
const matchedRoutes = router.matchRoutes(
4545
initialWindowLocation.pathname,
46+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
4647
router.options.parseSearch(initialWindowLocation.search),
4748
{ preload: false, throwOnError: false },
4849
);
4950

51+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5052
const lastMatch = matchedRoutes[matchedRoutes.length - 1];
5153

5254
startBrowserTracingPageLoadSpan(client, {
55+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5356
name: lastMatch ? lastMatch.routeId : initialWindowLocation.pathname,
5457
attributes: {
5558
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
@@ -66,23 +69,30 @@ export function tanstackRouterBrowserTracingIntegration<R extends AnyRouter>(
6669
// onBeforeNavigate is called during pageloads. We can avoid creating navigation spans by:
6770
// 1. Checking if there's no fromLocation (initial pageload)
6871
// 2. Comparing the states of the to and from arguments
72+
6973
if (
74+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
7075
!onBeforeNavigateArgs.fromLocation ||
76+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
7177
onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state
7278
) {
7379
return;
7480
}
7581

7682
const onResolvedMatchedRoutes = router.matchRoutes(
83+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
7784
onBeforeNavigateArgs.toLocation.pathname,
85+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
7886
onBeforeNavigateArgs.toLocation.search,
7987
{ preload: false, throwOnError: false },
8088
);
8189

90+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
8291
const onBeforeNavigateLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];
8392

8493
const navigationLocation = WINDOW.location;
8594
const navigationSpan = startBrowserTracingNavigationSpan(client, {
95+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
8696
name: onBeforeNavigateLastMatch ? onBeforeNavigateLastMatch.routeId : navigationLocation.pathname,
8797
attributes: {
8898
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
@@ -96,14 +106,18 @@ export function tanstackRouterBrowserTracingIntegration<R extends AnyRouter>(
96106
unsubscribeOnResolved();
97107
if (navigationSpan) {
98108
const onResolvedMatchedRoutes = router.matchRoutes(
109+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
99110
onResolvedArgs.toLocation.pathname,
111+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
100112
onResolvedArgs.toLocation.search,
101113
{ preload: false, throwOnError: false },
102114
);
103115

116+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
104117
const onResolvedLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];
105118

106119
if (onResolvedLastMatch) {
120+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
107121
navigationSpan.updateName(onResolvedLastMatch.routeId);
108122
navigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
109123
navigationSpan.setAttributes(routeMatchToParamSpanAttributes(onResolvedLastMatch));
@@ -122,6 +136,7 @@ function routeMatchToParamSpanAttributes(match: RouteMatch | undefined): Record<
122136
}
123137

124138
const paramAttributes: Record<string, string> = {};
139+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
125140
Object.entries(match.params as Record<string, string>).forEach(([key, value]) => {
126141
paramAttributes[`url.path.parameter.${key}`] = value;
127142
paramAttributes[`params.${key}`] = value; // params.[key] is an alias

packages/vue/test/tanstackrouter.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ describe('tanstackRouterBrowserTracingIntegration', () => {
7676
});
7777

7878
it('creates an integration with the correct name', () => {
79-
const integration = tanstackRouterBrowserTracingIntegration(mockRouter as AnyRouter);
79+
const integration = tanstackRouterBrowserTracingIntegration(mockRouter );
8080
expect(integration.name).toBe('BrowserTracing');
8181
});
8282

8383
it('instruments pageload on setup', () => {
84-
const integration = tanstackRouterBrowserTracingIntegration(mockRouter as AnyRouter, {
84+
const integration = tanstackRouterBrowserTracingIntegration(mockRouter , {
8585
instrumentPageLoad: true,
8686
});
8787

@@ -109,7 +109,7 @@ describe('tanstackRouterBrowserTracingIntegration', () => {
109109
});
110110

111111
it('does not instrument pageload when instrumentPageLoad is false', () => {
112-
const integration = tanstackRouterBrowserTracingIntegration(mockRouter as AnyRouter, {
112+
const integration = tanstackRouterBrowserTracingIntegration(mockRouter , {
113113
instrumentPageLoad: false,
114114
});
115115

@@ -119,7 +119,7 @@ describe('tanstackRouterBrowserTracingIntegration', () => {
119119
});
120120

121121
it('subscribes to router navigation events when instrumentNavigation is true', () => {
122-
const integration = tanstackRouterBrowserTracingIntegration(mockRouter as AnyRouter, {
122+
const integration = tanstackRouterBrowserTracingIntegration(mockRouter , {
123123
instrumentNavigation: true,
124124
});
125125

@@ -129,7 +129,7 @@ describe('tanstackRouterBrowserTracingIntegration', () => {
129129
});
130130

131131
it('does not subscribe to navigation events when instrumentNavigation is false', () => {
132-
const integration = tanstackRouterBrowserTracingIntegration(mockRouter as AnyRouter, {
132+
const integration = tanstackRouterBrowserTracingIntegration(mockRouter , {
133133
instrumentNavigation: false,
134134
});
135135

@@ -140,7 +140,7 @@ describe('tanstackRouterBrowserTracingIntegration', () => {
140140
});
141141

142142
it('creates navigation spans with correct attributes', () => {
143-
const integration = tanstackRouterBrowserTracingIntegration(mockRouter as AnyRouter, {
143+
const integration = tanstackRouterBrowserTracingIntegration(mockRouter , {
144144
instrumentNavigation: true,
145145
instrumentPageLoad: false, // Disable pageload to isolate navigation test
146146
});
@@ -179,7 +179,7 @@ describe('tanstackRouterBrowserTracingIntegration', () => {
179179
});
180180

181181
it('skips navigation span creation when state is the same', () => {
182-
const integration = tanstackRouterBrowserTracingIntegration(mockRouter as AnyRouter, {
182+
const integration = tanstackRouterBrowserTracingIntegration(mockRouter , {
183183
instrumentNavigation: true,
184184
instrumentPageLoad: false,
185185
});
@@ -208,7 +208,7 @@ describe('tanstackRouterBrowserTracingIntegration', () => {
208208
});
209209

210210
it('updates navigation span on redirect using onResolved', () => {
211-
const integration = tanstackRouterBrowserTracingIntegration(mockRouter as AnyRouter, {
211+
const integration = tanstackRouterBrowserTracingIntegration(mockRouter , {
212212
instrumentNavigation: true,
213213
instrumentPageLoad: false,
214214
});

0 commit comments

Comments
 (0)