Skip to content

Commit 186e982

Browse files
authored
feat(solidjs): Add solidjs SDK basic package (#12193)
1 parent 93c467d commit 186e982

16 files changed

+751
-61
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ packages:
128128
unpublish: $all
129129
# proxy: npmjs # Don't proxy for E2E tests!
130130

131+
'@sentry/solidjs':
132+
access: $all
133+
publish: $all
134+
unpublish: $all
135+
# proxy: npmjs # Don't proxy for E2E tests!
136+
131137
'@sentry/svelte':
132138
access: $all
133139
publish: $all

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"packages/replay-internal",
7070
"packages/replay-canvas",
7171
"packages/replay-worker",
72+
"packages/solidjs",
7273
"packages/svelte",
7374
"packages/sveltekit",
7475
"packages/types",

packages/solidjs/.eslintrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
},
5+
extends: ['../../.eslintrc.js'],
6+
};

packages/solidjs/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 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/solidjs/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 SolidJS
8+
9+
This SDK is work in progress, and should not be used before officially released.

packages/solidjs/package.json

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"name": "@sentry/solidjs",
3+
"version": "8.4.0",
4+
"description": "Official Sentry SDK for SolidJS",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/solidjs",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">=14.18"
11+
},
12+
"files": [
13+
"cjs",
14+
"esm",
15+
"types",
16+
"types-ts3.8"
17+
],
18+
"main": "build/cjs/index.js",
19+
"module": "build/esm/index.js",
20+
"types": "build/types/index.d.ts",
21+
"exports": {
22+
"./package.json": "./package.json",
23+
".": {
24+
"import": {
25+
"types": "./build/types/index.d.ts",
26+
"default": "./build/esm/index.js"
27+
},
28+
"require": {
29+
"types": "./build/types/index.d.ts",
30+
"default": "./build/cjs/index.js"
31+
}
32+
}
33+
},
34+
"typesVersions": {
35+
"<4.9": {
36+
"build/types/index.d.ts": [
37+
"build/types-ts3.8/index.d.ts"
38+
]
39+
}
40+
},
41+
"publishConfig": {
42+
"access": "public"
43+
},
44+
"dependencies": {
45+
"@sentry/browser": "8.4.0",
46+
"@sentry/core": "8.4.0",
47+
"@sentry/types": "8.4.0"
48+
},
49+
"peerDependencies": {
50+
"solid-js": "1.8.x"
51+
},
52+
"devDependencies": {
53+
"@solidjs/testing-library": "0.8.5",
54+
"vite-plugin-solid": "^2.8.2",
55+
"solid-js": "1.8.11"
56+
},
57+
"scripts": {
58+
"build": "run-p build:transpile build:types",
59+
"build:dev": "yarn build",
60+
"build:transpile": "rollup -c rollup.npm.config.mjs",
61+
"build:types": "run-s build:types:core build:types:downlevel",
62+
"build:types:core": "tsc -p tsconfig.types.json",
63+
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
64+
"build:watch": "run-p build:transpile:watch build:types:watch",
65+
"build:dev:watch": "yarn build:watch",
66+
"build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch",
67+
"build:types:watch": "tsc -p tsconfig.types.json --watch",
68+
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
69+
"circularDepCheck": "madge --circular src/index.ts",
70+
"clean": "rimraf build coverage sentry-solidjs-*.tgz",
71+
"fix": "eslint . --format stylish --fix",
72+
"lint": "eslint . --format stylish",
73+
"test": "vitest run",
74+
"test:watch": "vitest --watch",
75+
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig"
76+
},
77+
"volta": {
78+
"extends": "../../package.json"
79+
},
80+
"sideEffects": false
81+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils';
2+
3+
export default makeNPMConfigVariants(makeBaseNPMConfig());

packages/solidjs/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from '@sentry/browser';
2+
3+
export { init } from './sdk';

packages/solidjs/src/sdk.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { BrowserOptions } from '@sentry/browser';
2+
import { init as browserInit } from '@sentry/browser';
3+
import { applySdkMetadata } from '@sentry/core';
4+
5+
/**
6+
* Initializes the SolidJS SDK
7+
*/
8+
export function init(options: BrowserOptions): void {
9+
const opts = {
10+
...options,
11+
};
12+
13+
applySdkMetadata(opts, 'solidjs');
14+
15+
browserInit(opts);
16+
}

packages/solidjs/test/sdk.test.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { SDK_VERSION } from '@sentry/browser';
2+
import * as SentryBrowser from '@sentry/browser';
3+
4+
import { vi } from 'vitest';
5+
import { init as solidInit } from '../src/sdk';
6+
7+
const browserInit = vi.spyOn(SentryBrowser, 'init');
8+
9+
describe('Initialize SolidJS SDk', () => {
10+
beforeEach(() => {
11+
vi.clearAllMocks();
12+
});
13+
14+
it('has the correct metadata', () => {
15+
solidInit({
16+
dsn: 'https://[email protected]/1337',
17+
});
18+
19+
const expectedMetadata = {
20+
_metadata: {
21+
sdk: {
22+
name: 'sentry.javascript.solidjs',
23+
packages: [{ name: 'npm:@sentry/solidjs', version: SDK_VERSION }],
24+
version: SDK_VERSION,
25+
},
26+
},
27+
};
28+
29+
expect(browserInit).toHaveBeenCalledTimes(1);
30+
expect(browserInit).toHaveBeenLastCalledWith(expect.objectContaining(expectedMetadata));
31+
});
32+
});

packages/solidjs/tsconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
4+
"include": ["src/**/*"],
5+
6+
"compilerOptions": {}
7+
}

packages/solidjs/tsconfig.test.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
4+
"include": ["test/**/*", "vite.config.ts"],
5+
6+
"compilerOptions": {
7+
// should include all types from `./tsconfig.json` plus types for all test frameworks used
8+
"types": ["vitest/globals"]
9+
10+
// other package-specific, test-specific options
11+
}
12+
}

packages/solidjs/tsconfig.types.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
4+
"compilerOptions": {
5+
"declaration": true,
6+
"declarationMap": true,
7+
"emitDeclarationOnly": true,
8+
"outDir": "build/types"
9+
}
10+
}

packages/solidjs/vite.config.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import solidPlugin from 'vite-plugin-solid';
2+
import type { UserConfig } from 'vitest';
3+
import baseConfig from '../../vite/vite.config';
4+
5+
export default {
6+
...baseConfig,
7+
plugins: [solidPlugin({ hot: !process.env.VITEST })],
8+
test: {
9+
// test exists, no idea why TS doesn't recognize it
10+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
11+
...(baseConfig as UserConfig & { test: any }).test,
12+
environment: 'jsdom',
13+
},
14+
};

scripts/node-unit-tests.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const DEFAULT_SKIP_TESTS_PACKAGES = [
1515
'@sentry/vue',
1616
'@sentry/react',
1717
'@sentry/angular',
18+
'@sentry/solidjs',
1819
'@sentry/svelte',
1920
'@sentry/profiling-node',
2021
'@sentry-internal/browser-utils',

0 commit comments

Comments
 (0)