Skip to content

Commit 3230bc7

Browse files
committed
make dedicated package
1 parent fc05c52 commit 3230bc7

19 files changed

+183
-4
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ jobs:
369369
${{ github.workspace }}/packages/browser/build/bundles/**
370370
${{ github.workspace }}/packages/integrations/build/bundles/**
371371
${{ github.workspace }}/packages/replay/build/bundles/**
372+
${{ github.workspace }}/packages/replay-canvas/build/bundles/**
372373
${{ github.workspace }}/packages/**/*.tgz
373374
${{ github.workspace }}/packages/serverless/build/aws/dist-serverless/*.zip
374375

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"packages/remix",
7070
"packages/replay",
7171
"packages/replay-worker",
72+
"packages/replay-canvas",
7273
"packages/serverless",
7374
"packages/svelte",
7475
"packages/sveltekit",

packages/browser/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
},
2525
"dependencies": {
2626
"@sentry-internal/feedback": "7.88.0",
27+
"@sentry-internal/replay-canvas": "7.88.0",
2728
"@sentry-internal/tracing": "7.88.0",
2829
"@sentry/core": "7.88.0",
2930
"@sentry/replay": "7.88.0",

packages/browser/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const INTEGRATIONS = {
2020

2121
export { INTEGRATIONS as Integrations };
2222

23-
export { Replay, ReplayCanvas } from '@sentry/replay';
23+
export { Replay } from '@sentry/replay';
24+
export { ReplayCanvas } from '@sentry-internal/replay-canvas';
2425
export type {
2526
ReplayEventType,
2627
ReplayEventWithTime,

packages/replay-canvas/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor

packages/replay-canvas/.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Note: All paths are relative to the directory in which eslint is being run, rather than the directory where this file
2+
// lives
3+
4+
// ESLint config docs: https://eslint.org/docs/user-guide/configuring/
5+
6+
module.exports = {
7+
extends: ['../../.eslintrc.js'],
8+
};

packages/replay-canvas/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
/*.tgz
3+
.eslintcache
4+
build
5+
!vendor/*.d.ts

packages/replay-canvas/LICENSE

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

packages/replay-canvas/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
# Sentry Session Replay Worker
8+
9+
This is an internal package that is used by @sentry/replay.
10+
It generates a web worker and converts it to a string, so that we can process it easier in replay.
11+
12+
By extracting this into a dedicated (private, internal) package, we can streamline the build of replay.
13+
14+
## Example Worker
15+
16+
You can find an example worker for if you want to self-host the compression worker in [/examples](./examples/).
17+
18+
This is generated from the actual soure via `yarn build:examples`, which should be run manually whenever replay-worker is updated.

packages/replay-canvas/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../jest/jest.config.js');

packages/replay-canvas/package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "@sentry-internal/replay-canvas",
3+
"version": "7.88.0",
4+
"description": "Canvas capturing for @sentry/replay",
5+
"main": "build/npm/esm/index.js",
6+
"module": "build/npm/esm/index.js",
7+
"types": "build/npm/types/index.d.ts",
8+
"typesVersions": {
9+
"<4.9": {
10+
"build/npm/types/index.d.ts": [
11+
"build/npm/types-ts3.8/index.d.ts"
12+
]
13+
}
14+
},
15+
"sideEffects": false,
16+
"private": true,
17+
"scripts": {
18+
"build": "run-p build:transpile build:types build:bundle",
19+
"build:transpile": "rollup -c rollup.npm.config.js",
20+
"build:bundle": "rollup -c rollup.bundle.config.js",
21+
"build:dev": "run-p build:transpile build:types",
22+
"build:types": "run-s build:types:core build:types:downlevel",
23+
"build:types:core": "tsc -p tsconfig.types.json",
24+
"build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8",
25+
"build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch",
26+
"build:dev:watch": "run-p build:transpile:watch build:types:watch",
27+
"build:transpile:watch": "yarn build:transpile --watch",
28+
"build:bundle:watch": "yarn build:bundle --watch",
29+
"build:types:watch": "tsc -p tsconfig.types.json --watch",
30+
"build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm",
31+
"circularDepCheck": "madge --circular src/index.ts",
32+
"clean": "rimraf build sentry-replay-*.tgz",
33+
"fix": "eslint . --format stylish --fix",
34+
"lint": "eslint . --format stylish",
35+
"test": "jest",
36+
"test:watch": "jest --watch",
37+
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig"
38+
},
39+
"repository": {
40+
"type": "git",
41+
"url": "git+https://github.com/getsentry/sentry-javascript.git"
42+
},
43+
"author": "Sentry",
44+
"license": "MIT",
45+
"bugs": {
46+
"url": "https://github.com/getsentry/sentry-javascript/issues"
47+
},
48+
"homepage": "https://docs.sentry.io/platforms/javascript/session-replay/",
49+
"dependencies": {},
50+
"devDependencies": {
51+
"@sentry/types": "7.88.0",
52+
"@sentry-internal/rrweb": "2.6.0"
53+
},
54+
"engines": {
55+
"node": ">=12"
56+
},
57+
"volta": {
58+
"extends": "../../package.json"
59+
}
60+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/index.js';
2+
3+
const baseBundleConfig = makeBaseBundleConfig({
4+
bundleType: 'addon',
5+
entrypoints: ['src/index.ts'],
6+
jsVersion: 'es6',
7+
licenseTitle: '@sentry/replaycanvas',
8+
outputFileBase: () => 'bundles/replaycanvas',
9+
});
10+
11+
const builds = makeBundleConfigVariants(baseBundleConfig);
12+
13+
export default builds;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index';
2+
3+
export default makeNPMConfigVariants(
4+
makeBaseNPMConfig({
5+
hasBundles: true,
6+
packageSpecificConfig: {
7+
output: {
8+
// set exports to 'named' or 'auto' so that rollup doesn't warn
9+
exports: 'named',
10+
// set preserveModules to false because for Replay we actually want
11+
// to bundle everything into one file.
12+
preserveModules: false,
13+
},
14+
},
15+
}),
16+
);

packages/replay/src/canvas.ts renamed to packages/replay-canvas/src/ReplayCanvas.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getCanvasManager } from '@sentry-internal/rrweb';
22
import type { Integration } from '@sentry/types';
3-
import type { ReplayConfiguration } from './types';
43

54
interface ReplayCanvasOptions {
65
fps: number;
@@ -41,7 +40,15 @@ export class ReplayCanvas implements Integration {
4140
* Get the options that should be merged into replay options.
4241
* This is what is actually called by the Replay integration to setup canvas.
4342
*/
44-
public getOptions(): Partial<ReplayConfiguration> {
43+
public getOptions(): Partial<{
44+
_experiments: {
45+
canvas?: {
46+
fps: number;
47+
quality: number;
48+
manager: typeof getCanvasManager;
49+
};
50+
};
51+
}> {
4552
return {
4653
_experiments: {
4754
canvas: {

packages/replay-canvas/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ReplayCanvas } from './ReplayCanvas';

packages/replay-canvas/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"module": "esnext"
5+
},
6+
"include": ["src/**/*.ts"]
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
4+
"include": ["test/**/*.ts", "jest.config.ts", "jest.setup.ts"],
5+
6+
"compilerOptions": {
7+
"types": ["node", "jest"],
8+
"esModuleInterop": true,
9+
"allowJs": true,
10+
"noImplicitAny": true,
11+
"noImplicitThis": false,
12+
"strictNullChecks": true,
13+
"strictPropertyInitialization": false
14+
}
15+
}
Lines changed: 10 additions & 0 deletions
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/npm/types"
9+
}
10+
}

packages/replay/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export { Replay } from './integration';
2-
export { ReplayCanvas } from './canvas';
32

43
export type {
54
ReplayEventType,

0 commit comments

Comments
 (0)