Skip to content

Commit

Permalink
make dedicated package
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Dec 19, 2023
1 parent fc05c52 commit 3230bc7
Show file tree
Hide file tree
Showing 19 changed files with 183 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ jobs:
${{ github.workspace }}/packages/browser/build/bundles/**
${{ github.workspace }}/packages/integrations/build/bundles/**
${{ github.workspace }}/packages/replay/build/bundles/**
${{ github.workspace }}/packages/replay-canvas/build/bundles/**
${{ github.workspace }}/packages/**/*.tgz
${{ github.workspace }}/packages/serverless/build/aws/dist-serverless/*.zip
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/remix",
"packages/replay",
"packages/replay-worker",
"packages/replay-canvas",
"packages/serverless",
"packages/svelte",
"packages/sveltekit",
Expand Down
1 change: 1 addition & 0 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"dependencies": {
"@sentry-internal/feedback": "7.88.0",
"@sentry-internal/replay-canvas": "7.88.0",
"@sentry-internal/tracing": "7.88.0",
"@sentry/core": "7.88.0",
"@sentry/replay": "7.88.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const INTEGRATIONS = {

export { INTEGRATIONS as Integrations };

export { Replay, ReplayCanvas } from '@sentry/replay';
export { Replay } from '@sentry/replay';
export { ReplayCanvas } from '@sentry-internal/replay-canvas';
export type {
ReplayEventType,
ReplayEventWithTime,
Expand Down
1 change: 1 addition & 0 deletions packages/replay-canvas/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor
8 changes: 8 additions & 0 deletions packages/replay-canvas/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Note: All paths are relative to the directory in which eslint is being run, rather than the directory where this file
// lives

// ESLint config docs: https://eslint.org/docs/user-guide/configuring/

module.exports = {
extends: ['../../.eslintrc.js'],
};
5 changes: 5 additions & 0 deletions packages/replay-canvas/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
/*.tgz
.eslintcache
build
!vendor/*.d.ts
14 changes: 14 additions & 0 deletions packages/replay-canvas/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.
18 changes: 18 additions & 0 deletions packages/replay-canvas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<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>

# Sentry Session Replay Worker

This is an internal package that is used by @sentry/replay.
It generates a web worker and converts it to a string, so that we can process it easier in replay.

By extracting this into a dedicated (private, internal) package, we can streamline the build of replay.

## Example Worker

You can find an example worker for if you want to self-host the compression worker in [/examples](./examples/).

This is generated from the actual soure via `yarn build:examples`, which should be run manually whenever replay-worker is updated.
1 change: 1 addition & 0 deletions packages/replay-canvas/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../jest/jest.config.js');
60 changes: 60 additions & 0 deletions packages/replay-canvas/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "@sentry-internal/replay-canvas",
"version": "7.88.0",
"description": "Canvas capturing for @sentry/replay",
"main": "build/npm/esm/index.js",
"module": "build/npm/esm/index.js",
"types": "build/npm/types/index.d.ts",
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
"build/npm/types-ts3.8/index.d.ts"
]
}
},
"sideEffects": false,
"private": true,
"scripts": {
"build": "run-p build:transpile build:types build:bundle",
"build:transpile": "rollup -c rollup.npm.config.js",
"build:bundle": "rollup -c rollup.bundle.config.js",
"build:dev": "run-p build:transpile build:types",
"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/npm/types build/npm/types-ts3.8 --to ts3.8",
"build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch",
"build:dev:watch": "run-p build:transpile:watch build:types:watch",
"build:transpile:watch": "yarn build:transpile --watch",
"build:bundle:watch": "yarn build:bundle --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm",
"circularDepCheck": "madge --circular src/index.ts",
"clean": "rimraf build sentry-replay-*.tgz",
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"test": "jest",
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig"
},
"repository": {
"type": "git",
"url": "git+https://github.com/getsentry/sentry-javascript.git"
},
"author": "Sentry",
"license": "MIT",
"bugs": {
"url": "https://github.com/getsentry/sentry-javascript/issues"
},
"homepage": "https://docs.sentry.io/platforms/javascript/session-replay/",
"dependencies": {},
"devDependencies": {
"@sentry/types": "7.88.0",
"@sentry-internal/rrweb": "2.6.0"
},
"engines": {
"node": ">=12"
},
"volta": {
"extends": "../../package.json"
}
}
13 changes: 13 additions & 0 deletions packages/replay-canvas/rollup.bundle.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/index.js';

const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'addon',
entrypoints: ['src/index.ts'],
jsVersion: 'es6',
licenseTitle: '@sentry/replaycanvas',
outputFileBase: () => 'bundles/replaycanvas',
});

const builds = makeBundleConfigVariants(baseBundleConfig);

export default builds;
16 changes: 16 additions & 0 deletions packages/replay-canvas/rollup.npm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index';

export default makeNPMConfigVariants(
makeBaseNPMConfig({
hasBundles: true,
packageSpecificConfig: {
output: {
// set exports to 'named' or 'auto' so that rollup doesn't warn
exports: 'named',
// set preserveModules to false because for Replay we actually want
// to bundle everything into one file.
preserveModules: false,
},
},
}),
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getCanvasManager } from '@sentry-internal/rrweb';
import type { Integration } from '@sentry/types';
import type { ReplayConfiguration } from './types';

interface ReplayCanvasOptions {
fps: number;
Expand Down Expand Up @@ -41,7 +40,15 @@ export class ReplayCanvas implements Integration {
* Get the options that should be merged into replay options.
* This is what is actually called by the Replay integration to setup canvas.
*/
public getOptions(): Partial<ReplayConfiguration> {
public getOptions(): Partial<{
_experiments: {
canvas?: {
fps: number;
quality: number;
manager: typeof getCanvasManager;
};
};
}> {
return {
_experiments: {
canvas: {
Expand Down
1 change: 1 addition & 0 deletions packages/replay-canvas/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ReplayCanvas } from './ReplayCanvas';
7 changes: 7 additions & 0 deletions packages/replay-canvas/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "esnext"
},
"include": ["src/**/*.ts"]
}
15 changes: 15 additions & 0 deletions packages/replay-canvas/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",

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

"compilerOptions": {
"types": ["node", "jest"],
"esModuleInterop": true,
"allowJs": true,
"noImplicitAny": true,
"noImplicitThis": false,
"strictNullChecks": true,
"strictPropertyInitialization": false
}
}
10 changes: 10 additions & 0 deletions packages/replay-canvas/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/npm/types"
}
}
1 change: 0 additions & 1 deletion packages/replay/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { Replay } from './integration';
export { ReplayCanvas } from './canvas';

export type {
ReplayEventType,
Expand Down

0 comments on commit 3230bc7

Please sign in to comment.