Skip to content
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

feat(tanstackstart): Add TanStack Start SDK #15523

Merged
merged 3 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ targets:
- name: npm
id: '@sentry/sveltekit'
includeNames: /^sentry-sveltekit-\d.*\.tgz$/
- name: npm
id: '@sentry/tanstackstart'
includeNames: /^sentry-tanstackstart-\d.*\.tgz$/
- name: npm
id: '@sentry/gatsby'
includeNames: /^sentry-gatsby-\d.*\.tgz$/
Expand Down
6 changes: 6 additions & 0 deletions dev-packages/e2e-tests/verdaccio-config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ packages:
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

'@sentry/tanstackstart':
access: $all
publish: $all
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

'@sentry/types':
access: $all
publish: $all
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"packages/solidstart",
"packages/svelte",
"packages/sveltekit",
"packages/tanstackstart",
"packages/types",
"packages/typescript",
"packages/vercel-edge",
Expand Down
10 changes: 10 additions & 0 deletions packages/tanstackstart/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
env: {
browser: true,
node: true,
},
parserOptions: {
jsx: true,
},
extends: ['../../.eslintrc.js'],
};
21 changes: 21 additions & 0 deletions packages/tanstackstart/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Functional Software, Inc. dba Sentry

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 52 additions & 0 deletions packages/tanstackstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<p align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
</a>
</p>

# Official Sentry SDK for TanStack Start (Alpha)

[![npm version](https://img.shields.io/npm/v/@sentry/tanstackstart.svg)](https://www.npmjs.com/package/@sentry/tanstackstart)
[![npm dm](https://img.shields.io/npm/dm/@sentry/tanstackstart.svg)](https://www.npmjs.com/package/@sentry/tanstackstart)
[![npm dt](https://img.shields.io/npm/dt/@sentry/tanstackstart.svg)](https://www.npmjs.com/package/@sentry/tanstackstart)

> NOTICE: This package is in alpha state and may be subject to breaking changes.

## Getting Started

This SDK does not have docs yet. Stay tuned.

## Compatibility

The minimum supported version of TanStack Start is `1.111.12`.

## Custom Usage

To set context information or to send manual events, you can use `@sentry/tanstackstart` as follows:

```ts
import * as Sentry from '@sentry/tanstackstart';

// Set user information, as well as tags and further extras
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });
Sentry.setContext('application_area', { location: 'checkout' });

// Add a breadcrumb for future events
Sentry.addBreadcrumb({
message: '"Add to cart" clicked',
// ...
});

// Capture exceptions or messages
Sentry.captureException(new Error('Oh no.'));
Sentry.captureMessage('Hello, world!');
```

## Links

<!-- - [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/tanstackstart/) -->

- [Sentry.io](https://sentry.io/?utm_source=github&utm_medium=npm_tanstackstart)
- [Sentry Discord Server](https://discord.gg/Ww9hbqr)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/sentry)
84 changes: 84 additions & 0 deletions packages/tanstackstart/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"name": "@sentry/tanstackstart",
"version": "9.2.0",
"description": "Official Sentry SDK for TanStack Start",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/tanstackstart",
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=18"
},
"main": "build/cjs/index.server.js",
"module": "build/esm/index.server.js",
"types": "build/types/index.types.d.ts",
"files": [
"/build"
],
"exports": {
"./package.json": "./package.json",
".": {
"types": "./build/types/index.types.d.ts",
"browser": {
"import": "./build/esm/index.client.js",
"require": "./build/cjs/index.client.js"
},
"node": "./build/cjs/index.server.js",
"import": "./build/esm/index.server.js"
},
"./import": {
"import": {
"default": "./build/import-hook.mjs"
}
},
"./loader": {
"import": {
"default": "./build/loader-hook.mjs"
}
}
},
"typesVersions": {
"<5.0": {
"build/npm/types/index.d.ts": [
"build/npm/types-ts3.8/index.d.ts"
]
}
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/semantic-conventions": "^1.30.0",
"@sentry-internal/browser-utils": "9.2.0",
"@sentry/core": "9.2.0",
"@sentry/node": "9.2.0",
"@sentry/opentelemetry": "9.2.0",
"@sentry/react": "9.2.0"
},
"scripts": {
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "rollup -c rollup.npm.config.mjs",
"build:types": "run-s build:types:core build:types:downlevel",
"build:types:core": "tsc -p tsconfig.types.json",
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "yarn build:watch",
"build:transpile:watch": "nodemon --ext ts --watch src scripts/buildRollup.ts",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "npm pack",
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts",
"clean": "rimraf build coverage sentry-tanstackstart-*.tgz",
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"test": "yarn test:unit",
"test:unit": "vitest run",
"test:watch": "vitest --watch",
"yalc:publish": "yalc publish --push --sig"
},
"volta": {
"extends": "../../package.json"
},
"sideEffects": false
}
16 changes: 16 additions & 0 deletions packages/tanstackstart/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sentry-internal/rollup-utils';

export default [
...makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: [
'src/index.server.ts',
'src/index.client.ts',
'src/client/index.ts',
'src/server/index.ts',
'src/config/index.ts',
],
}),
),
...makeOtelLoaders('./build', 'sentry-node'),
];
1 change: 1 addition & 0 deletions packages/tanstackstart/src/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@sentry/react';
1 change: 1 addition & 0 deletions packages/tanstackstart/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions packages/tanstackstart/src/index.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './client';
43 changes: 43 additions & 0 deletions packages/tanstackstart/src/index.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export * from './config';
export * from './server';

/**
* A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors
* so they should simply be a passthrough.
*/
export const ErrorBoundary = (props: React.PropsWithChildren<unknown>): React.ReactNode => {
if (!props.children) {
return null;
}

if (typeof props.children === 'function') {
return (props.children as () => React.ReactNode)();
}

return props.children;
};

/**
* A passthrough redux enhancer for the server that doesn't depend on anything from the `@sentry/react` package.
*/
export function createReduxEnhancer() {
return (createStore: unknown) => createStore;
}

/**
* A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch
* SSR errors so they should simply be a passthrough.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function withErrorBoundary<P extends Record<string, any>>(
WrappedComponent: React.ComponentType<P>,
): React.FC<P> {
return WrappedComponent as React.FC<P>;
}

/**
* Just a passthrough since we're on the server and showing the report dialog on the server doesn't make any sense.
*/
export function showReportDialog(): void {
return;
}
26 changes: 26 additions & 0 deletions packages/tanstackstart/src/index.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// We export everything from both the client part of the SDK and from the server part. Some of the exports collide,
// which is not allowed, unless we redefine the colliding exports in this file - which we do below.
export * from './config';
export * from './client';
export * from './server';

import type { Client, Integration, Options, StackParser } from '@sentry/core';

import type * as clientSdk from './client';
import type * as serverSdk from './server';

/** Initializes Sentry TanStack Start SDK */
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): Client | undefined;

export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;

export declare const getDefaultIntegrations: (options: Options) => Integration[];
export declare const defaultStackParser: StackParser;

export declare function getSentryRelease(fallback?: string): string | undefined;

export declare const ErrorBoundary: typeof clientSdk.ErrorBoundary;
export declare const createReduxEnhancer: typeof clientSdk.createReduxEnhancer;
export declare const showReportDialog: typeof clientSdk.showReportDialog;
export declare const withErrorBoundary: typeof clientSdk.withErrorBoundary;
1 change: 1 addition & 0 deletions packages/tanstackstart/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@sentry/node';
7 changes: 7 additions & 0 deletions packages/tanstackstart/test/temp.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, it, expect } from 'vitest';

describe('Basic test suite', () => {
it('should pass', () => {
expect(true).toBe(true);
});
});
3 changes: 3 additions & 0 deletions packages/tanstackstart/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../tsconfig.test.json"
}
8 changes: 8 additions & 0 deletions packages/tanstackstart/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"compilerOptions": {
"lib": ["es2018", "es2020.string"],
"module": "Node16"
}
}
8 changes: 8 additions & 0 deletions packages/tanstackstart/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"include": ["test/**/*", "vite.config.ts"],
"compilerOptions": {
"types": ["node"],
"lib": ["DOM", "ESNext"]
}
}
9 changes: 9 additions & 0 deletions packages/tanstackstart/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "build/types"
}
}
8 changes: 8 additions & 0 deletions packages/tanstackstart/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import baseConfig from '../../vite/vite.config';

export default {
...baseConfig,
test: {
...baseConfig.test,
},
};
Loading