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

chore(sveltekit): Add boilerplate SvelteKit SDK package #7365

Merged
merged 6 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ targets:
- name: github
includeNames: /^sentry-.*$/
- name: npm
excludeNames: /^sentry-sveltekit-.*$/
- name: registry
sdks:
'npm:@sentry/browser':
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"packages/replay-worker",
"packages/serverless",
"packages/svelte",
"packages/sveltekit",
"packages/tracing",
"packages/types",
"packages/typescript",
Expand Down
6 changes: 6 additions & 0 deletions packages/e2e-tests/verdaccio-config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ packages:
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

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

'@sentry/tracing':
access: $all
publish: $all
Expand Down
7 changes: 7 additions & 0 deletions packages/sveltekit/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
env: {
browser: true,
node: true,
},
extends: ['../../.eslintrc.js'],
};
14 changes: 14 additions & 0 deletions packages/sveltekit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2023 Sentry (https://sentry.io) and individual contributors. All rights reserved.

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.
32 changes: 32 additions & 0 deletions packages/sveltekit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<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 SvelteKit

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

<!--
TODO: No docs yet, comment back in once we have docs
## Links

- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/sveltekit/)
- [TypeDoc](http://getsentry.github.io/sentry-javascript/) -->

## SDK Status

This SDK is currently in **Alpha state** and we're still experimenting with APIs and functionality. We therefore make no guarantees in terms of semver or breaking changes. If you want to try this SDK and come across a problem, please open a [GitHub Issue](https://github.com/getsentry/sentry-javascript/issues/new/choose).

## Compatibility

Currently, the minimum supported version of SvelteKit is `1.0.0`.

## General

This package is a wrapper around `@sentry/node` for the server and `@sentry/svelte` for the client, with added functionality related to SvelteKit.

TODO: Add usage instructions
3 changes: 3 additions & 0 deletions packages/sveltekit/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const baseConfig = require('../../jest/jest.config.js');

module.exports = baseConfig;
59 changes: 59 additions & 0 deletions packages/sveltekit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@sentry/sveltekit",
"version": "7.41.0",
"description": "Official Sentry SDK for SvelteKit",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/sveltekit",
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=16"
},
"main": "build/cjs/index.server.js",
"module": "build/esm/index.server.js",
"browser": "build/esm/index.client.js",
"types": "build/types/index.types.d.ts",
"private": true,
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"@sveltejs/kit": "1.x"
},
"dependencies": {
"@sentry/core": "7.41.0",
"@sentry/node": "7.41.0",
"@sentry/svelte": "7.41.0",
"@sentry/types": "7.41.0",
"@sentry/utils": "7.41.0"
},
"devDependencies": {
"@sveltejs/kit": "^1.10.0",
"vite": "^4.0.0"
},
"scripts": {
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "rollup -c rollup.npm.config.js",
"build:types": "tsc -p tsconfig.types.json",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "yarn build:watch",
"build:transpile:watch": "rollup -c rollup.npm.config.js --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts",
"clean": "rimraf build coverage sentry-sveltekit-*.tgz",
"fix": "run-s fix:eslint fix:prettier",
"fix:eslint": "eslint . --format stylish --fix",
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
"lint": "run-s lint:prettier lint:eslint",
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "yarn test:unit",
"test:unit": "jest",
"test:watch": "jest --watch"
},
"volta": {
"extends": "../../package.json"
}
}
14 changes: 14 additions & 0 deletions packages/sveltekit/rollup.npm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js';

export default
makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: [
'src/index.server.ts',
'src/index.client.ts',
'src/client/index.ts',
'src/server/index.ts',
],
}),
)
;
4 changes: 4 additions & 0 deletions packages/sveltekit/src/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from '@sentry/svelte';

// Just here so that eslint is happy until we export more stuff here
export const PLACEHOLDER_CLIENT = 'PLACEHOLDER';
7 changes: 7 additions & 0 deletions packages/sveltekit/src/index.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from './client';

/**
* This const serves no purpose besides being an identifier for this file that the SDK multiplexer loader can use to
* determine that this is in fact a file that wants to be multiplexed.
*/
export const _SENTRY_SDK_MULTIPLEXER = true;
9 changes: 9 additions & 0 deletions packages/sveltekit/src/index.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from './server';

// This file is the main entrypoint on the server and/or when the package is `require`d

/**
* This const serves no purpose besides being an identifier for this file that the SDK multiplexer loader can use to
* determine that this is in fact a file that wants to be multiplexed.
*/
export const _SENTRY_SDK_MULTIPLEXER = true;
25 changes: 25 additions & 0 deletions packages/sveltekit/src/index.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable import/export */

// 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 redifine the colliding
// exports in this file - which we do below.
export * from './client';
export * from './server';

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

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

/** Initializes Sentry SvelteKit SDK */
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): void;

// We export a merged Integrations object so that users can (at least typing-wise) use all integrations everywhere.
export declare const Integrations: typeof clientSdk.Integrations & typeof serverSdk.Integrations;

export declare const defaultIntegrations: Integration[];
export declare const defaultStackParser: StackParser;

export declare function close(timeout?: number | undefined): PromiseLike<boolean>;
export declare function flush(timeout?: number | undefined): PromiseLike<boolean>;
export declare function lastEventId(): string | undefined;
4 changes: 4 additions & 0 deletions packages/sveltekit/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from '@sentry/node';

// Just here so that eslint is happy until we export more stuff here
export const PLACEHOLDER_SERVER = 'PLACEHOLDER';
12 changes: 12 additions & 0 deletions packages/sveltekit/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as SentryClient from '../src/client';
import * as SentryServer from '../src/server';

describe('SvelteKit SDK', () => {
// This is a place holder test at best to satisfy the test runner
it('exports client and server SDKs', () => {
expect(SentryClient).toBeDefined();
expect(SentryServer).toBeDefined();
expect(SentryClient.init).toBeDefined();
expect(SentryServer.init).toBeDefined()
})
})
9 changes: 9 additions & 0 deletions packages/sveltekit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",

"include": ["src/**/*"],

"compilerOptions": {
// package-specific options
}
}
10 changes: 10 additions & 0 deletions packages/sveltekit/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",

"include": ["test/**/*"],

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "jest"]
}
}
10 changes: 10 additions & 0 deletions packages/sveltekit/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",

"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "build/types"
}
}
Loading