Skip to content

Commit 4dccffa

Browse files
authored
feat(tanstackstart): Add TanStack Start SDK (#15523)
1 parent 0a1b30f commit 4dccffa

20 files changed

+309
-0
lines changed

.craft.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ targets:
108108
- name: npm
109109
id: '@sentry/sveltekit'
110110
includeNames: /^sentry-sveltekit-\d.*\.tgz$/
111+
- name: npm
112+
id: '@sentry/tanstackstart'
113+
includeNames: /^sentry-tanstackstart-\d.*\.tgz$/
111114
- name: npm
112115
id: '@sentry/gatsby'
113116
includeNames: /^sentry-gatsby-\d.*\.tgz$/

dev-packages/e2e-tests/verdaccio-config/config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ packages:
170170
unpublish: $all
171171
# proxy: npmjs # Don't proxy for E2E tests!
172172

173+
'@sentry/tanstackstart':
174+
access: $all
175+
publish: $all
176+
unpublish: $all
177+
# proxy: npmjs # Don't proxy for E2E tests!
178+
173179
'@sentry/types':
174180
access: $all
175181
publish: $all

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"packages/solidstart",
8080
"packages/svelte",
8181
"packages/sveltekit",
82+
"packages/tanstackstart",
8283
"packages/types",
8384
"packages/typescript",
8485
"packages/vercel-edge",

packages/tanstackstart/.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
node: true,
5+
},
6+
parserOptions: {
7+
jsx: true,
8+
},
9+
extends: ['../../.eslintrc.js'],
10+
};

packages/tanstackstart/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Functional Software, Inc. dba Sentry
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
of the Software, and to permit persons to whom the Software is furnished to do
10+
so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/tanstackstart/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<p align="center">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4+
</a>
5+
</p>
6+
7+
# Official Sentry SDK for TanStack Start (Alpha)
8+
9+
[![npm version](https://img.shields.io/npm/v/@sentry/tanstackstart.svg)](https://www.npmjs.com/package/@sentry/tanstackstart)
10+
[![npm dm](https://img.shields.io/npm/dm/@sentry/tanstackstart.svg)](https://www.npmjs.com/package/@sentry/tanstackstart)
11+
[![npm dt](https://img.shields.io/npm/dt/@sentry/tanstackstart.svg)](https://www.npmjs.com/package/@sentry/tanstackstart)
12+
13+
> NOTICE: This package is in alpha state and may be subject to breaking changes.
14+
15+
## Getting Started
16+
17+
This SDK does not have docs yet. Stay tuned.
18+
19+
## Compatibility
20+
21+
The minimum supported version of TanStack Start is `1.111.12`.
22+
23+
## Custom Usage
24+
25+
To set context information or to send manual events, you can use `@sentry/tanstackstart` as follows:
26+
27+
```ts
28+
import * as Sentry from '@sentry/tanstackstart';
29+
30+
// Set user information, as well as tags and further extras
31+
Sentry.setTag('user_mode', 'admin');
32+
Sentry.setUser({ id: '4711' });
33+
Sentry.setContext('application_area', { location: 'checkout' });
34+
35+
// Add a breadcrumb for future events
36+
Sentry.addBreadcrumb({
37+
message: '"Add to cart" clicked',
38+
// ...
39+
});
40+
41+
// Capture exceptions or messages
42+
Sentry.captureException(new Error('Oh no.'));
43+
Sentry.captureMessage('Hello, world!');
44+
```
45+
46+
## Links
47+
48+
<!-- - [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/tanstackstart/) -->
49+
50+
- [Sentry.io](https://sentry.io/?utm_source=github&utm_medium=npm_tanstackstart)
51+
- [Sentry Discord Server](https://discord.gg/Ww9hbqr)
52+
- [Stack Overflow](https://stackoverflow.com/questions/tagged/sentry)

packages/tanstackstart/package.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"name": "@sentry/tanstackstart",
3+
"version": "9.2.0",
4+
"description": "Official Sentry SDK for TanStack Start",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/tanstackstart",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">=18"
11+
},
12+
"main": "build/cjs/index.server.js",
13+
"module": "build/esm/index.server.js",
14+
"types": "build/types/index.types.d.ts",
15+
"files": [
16+
"/build"
17+
],
18+
"exports": {
19+
"./package.json": "./package.json",
20+
".": {
21+
"types": "./build/types/index.types.d.ts",
22+
"browser": {
23+
"import": "./build/esm/index.client.js",
24+
"require": "./build/cjs/index.client.js"
25+
},
26+
"node": "./build/cjs/index.server.js",
27+
"import": "./build/esm/index.server.js"
28+
},
29+
"./import": {
30+
"import": {
31+
"default": "./build/import-hook.mjs"
32+
}
33+
},
34+
"./loader": {
35+
"import": {
36+
"default": "./build/loader-hook.mjs"
37+
}
38+
}
39+
},
40+
"typesVersions": {
41+
"<5.0": {
42+
"build/npm/types/index.d.ts": [
43+
"build/npm/types-ts3.8/index.d.ts"
44+
]
45+
}
46+
},
47+
"publishConfig": {
48+
"access": "public"
49+
},
50+
"dependencies": {
51+
"@opentelemetry/api": "^1.9.0",
52+
"@opentelemetry/semantic-conventions": "^1.30.0",
53+
"@sentry-internal/browser-utils": "9.2.0",
54+
"@sentry/core": "9.2.0",
55+
"@sentry/node": "9.2.0",
56+
"@sentry/opentelemetry": "9.2.0",
57+
"@sentry/react": "9.2.0"
58+
},
59+
"scripts": {
60+
"build": "run-p build:transpile build:types",
61+
"build:dev": "yarn build",
62+
"build:transpile": "rollup -c rollup.npm.config.mjs",
63+
"build:types": "run-s build:types:core build:types:downlevel",
64+
"build:types:core": "tsc -p tsconfig.types.json",
65+
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
66+
"build:watch": "run-p build:transpile:watch build:types:watch",
67+
"build:dev:watch": "yarn build:watch",
68+
"build:transpile:watch": "nodemon --ext ts --watch src scripts/buildRollup.ts",
69+
"build:types:watch": "tsc -p tsconfig.types.json --watch",
70+
"build:tarball": "npm pack",
71+
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts",
72+
"clean": "rimraf build coverage sentry-tanstackstart-*.tgz",
73+
"fix": "eslint . --format stylish --fix",
74+
"lint": "eslint . --format stylish",
75+
"test": "yarn test:unit",
76+
"test:unit": "vitest run",
77+
"test:watch": "vitest --watch",
78+
"yalc:publish": "yalc publish --push --sig"
79+
},
80+
"volta": {
81+
"extends": "../../package.json"
82+
},
83+
"sideEffects": false
84+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sentry-internal/rollup-utils';
2+
3+
export default [
4+
...makeNPMConfigVariants(
5+
makeBaseNPMConfig({
6+
entrypoints: [
7+
'src/index.server.ts',
8+
'src/index.client.ts',
9+
'src/client/index.ts',
10+
'src/server/index.ts',
11+
'src/config/index.ts',
12+
],
13+
}),
14+
),
15+
...makeOtelLoaders('./build', 'sentry-node'),
16+
];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '@sentry/react';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './client';
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export * from './config';
2+
export * from './server';
3+
4+
/**
5+
* A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors
6+
* so they should simply be a passthrough.
7+
*/
8+
export const ErrorBoundary = (props: React.PropsWithChildren<unknown>): React.ReactNode => {
9+
if (!props.children) {
10+
return null;
11+
}
12+
13+
if (typeof props.children === 'function') {
14+
return (props.children as () => React.ReactNode)();
15+
}
16+
17+
return props.children;
18+
};
19+
20+
/**
21+
* A passthrough redux enhancer for the server that doesn't depend on anything from the `@sentry/react` package.
22+
*/
23+
export function createReduxEnhancer() {
24+
return (createStore: unknown) => createStore;
25+
}
26+
27+
/**
28+
* A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch
29+
* SSR errors so they should simply be a passthrough.
30+
*/
31+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
32+
export function withErrorBoundary<P extends Record<string, any>>(
33+
WrappedComponent: React.ComponentType<P>,
34+
): React.FC<P> {
35+
return WrappedComponent as React.FC<P>;
36+
}
37+
38+
/**
39+
* Just a passthrough since we're on the server and showing the report dialog on the server doesn't make any sense.
40+
*/
41+
export function showReportDialog(): void {
42+
return;
43+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// We export everything from both the client part of the SDK and from the server part. Some of the exports collide,
2+
// which is not allowed, unless we redefine the colliding exports in this file - which we do below.
3+
export * from './config';
4+
export * from './client';
5+
export * from './server';
6+
7+
import type { Client, Integration, Options, StackParser } from '@sentry/core';
8+
9+
import type * as clientSdk from './client';
10+
import type * as serverSdk from './server';
11+
12+
/** Initializes Sentry TanStack Start SDK */
13+
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): Client | undefined;
14+
15+
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
16+
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
17+
18+
export declare const getDefaultIntegrations: (options: Options) => Integration[];
19+
export declare const defaultStackParser: StackParser;
20+
21+
export declare function getSentryRelease(fallback?: string): string | undefined;
22+
23+
export declare const ErrorBoundary: typeof clientSdk.ErrorBoundary;
24+
export declare const createReduxEnhancer: typeof clientSdk.createReduxEnhancer;
25+
export declare const showReportDialog: typeof clientSdk.showReportDialog;
26+
export declare const withErrorBoundary: typeof clientSdk.withErrorBoundary;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '@sentry/node';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { describe, it, expect } from 'vitest';
2+
3+
describe('Basic test suite', () => {
4+
it('should pass', () => {
5+
expect(true).toBe(true);
6+
});
7+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../tsconfig.test.json"
3+
}

packages/tanstackstart/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["src/**/*"],
4+
"compilerOptions": {
5+
"lib": ["es2018", "es2020.string"],
6+
"module": "Node16"
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["test/**/*", "vite.config.ts"],
4+
"compilerOptions": {
5+
"types": ["node"],
6+
"lib": ["DOM", "ESNext"]
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"declaration": true,
5+
"declarationMap": true,
6+
"emitDeclarationOnly": true,
7+
"outDir": "build/types"
8+
}
9+
}

packages/tanstackstart/vite.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import baseConfig from '../../vite/vite.config';
2+
3+
export default {
4+
...baseConfig,
5+
test: {
6+
...baseConfig.test,
7+
},
8+
};

0 commit comments

Comments
 (0)