Skip to content

feat(solidjs): Add solidjs SDK basic package #12193

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

Merged
merged 4 commits into from
May 24, 2024
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
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 @@ -128,6 +128,12 @@ packages:
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

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

'@sentry/svelte':
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 @@ -69,6 +69,7 @@
"packages/replay-internal",
"packages/replay-canvas",
"packages/replay-worker",
"packages/solidjs",
"packages/svelte",
"packages/sveltekit",
"packages/types",
Expand Down
6 changes: 6 additions & 0 deletions packages/solidjs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
env: {
browser: true,
},
extends: ['../../.eslintrc.js'],
};
21 changes: 21 additions & 0 deletions packages/solidjs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 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.
9 changes: 9 additions & 0 deletions packages/solidjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<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 SolidJS

This SDK is work in progress, and should not be used before officially released.
81 changes: 81 additions & 0 deletions packages/solidjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"name": "@sentry/solidjs",
"version": "8.4.0",
"description": "Official Sentry SDK for SolidJS",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/solidjs",
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=14.18"
},
"files": [
"cjs",
"esm",
"types",
"types-ts3.8"
],
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
"build/types-ts3.8/index.d.ts"
]
}
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@sentry/browser": "8.4.0",
"@sentry/core": "8.4.0",
"@sentry/types": "8.4.0"
},
"peerDependencies": {
"solid-js": "1.8.x"
},
"devDependencies": {
"@solidjs/testing-library": "0.8.5",
"vite-plugin-solid": "^2.8.2",
"solid-js": "1.8.11"
},
"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": "rollup -c rollup.npm.config.mjs --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.ts",
"clean": "rimraf build coverage sentry-solidjs-*.tgz",
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"test": "vitest run",
"test:watch": "vitest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig"
},
"volta": {
"extends": "../../package.json"
},
"sideEffects": false
}
3 changes: 3 additions & 0 deletions packages/solidjs/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils';

export default makeNPMConfigVariants(makeBaseNPMConfig());
3 changes: 3 additions & 0 deletions packages/solidjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from '@sentry/browser';

export { init } from './sdk';
16 changes: 16 additions & 0 deletions packages/solidjs/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { BrowserOptions } from '@sentry/browser';
import { init as browserInit } from '@sentry/browser';
import { applySdkMetadata } from '@sentry/core';

/**
* Initializes the SolidJS SDK
*/
export function init(options: BrowserOptions): void {
const opts = {
...options,
};

applySdkMetadata(opts, 'solidjs');

browserInit(opts);
}
32 changes: 32 additions & 0 deletions packages/solidjs/test/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { SDK_VERSION } from '@sentry/browser';
import * as SentryBrowser from '@sentry/browser';

import { vi } from 'vitest';
import { init as solidInit } from '../src/sdk';

const browserInit = vi.spyOn(SentryBrowser, 'init');

describe('Initialize SolidJS SDk', () => {
beforeEach(() => {
vi.clearAllMocks();
});

it('has the correct metadata', () => {
solidInit({
dsn: 'https://[email protected]/1337',
});

const expectedMetadata = {
_metadata: {
sdk: {
name: 'sentry.javascript.solidjs',
packages: [{ name: 'npm:@sentry/solidjs', version: SDK_VERSION }],
version: SDK_VERSION,
},
},
};

expect(browserInit).toHaveBeenCalledTimes(1);
expect(browserInit).toHaveBeenLastCalledWith(expect.objectContaining(expectedMetadata));
});
});
7 changes: 7 additions & 0 deletions packages/solidjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",

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

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

"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["vitest/globals"]

// other package-specific, test-specific options
}
}
10 changes: 10 additions & 0 deletions packages/solidjs/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"
}
}
14 changes: 14 additions & 0 deletions packages/solidjs/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import solidPlugin from 'vite-plugin-solid';
import type { UserConfig } from 'vitest';
import baseConfig from '../../vite/vite.config';

export default {
...baseConfig,
plugins: [solidPlugin({ hot: !process.env.VITEST })],
test: {
// test exists, no idea why TS doesn't recognize it
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...(baseConfig as UserConfig & { test: any }).test,
environment: 'jsdom',
},
};
1 change: 1 addition & 0 deletions scripts/node-unit-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const DEFAULT_SKIP_TESTS_PACKAGES = [
'@sentry/vue',
'@sentry/react',
'@sentry/angular',
'@sentry/solidjs',
'@sentry/svelte',
'@sentry/profiling-node',
'@sentry-internal/browser-utils',
Expand Down
Loading
Loading