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

feat: Upgrade to rrweb2 #107

Merged
merged 60 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
894051f
support for mask all and unmask by selector and class #1096
mdellanoce Jan 6, 2023
5309566
apply text mask settings to inputs #1096
mdellanoce Jan 12, 2023
70dbf1e
remove default for unmaskTextClass #1096
mdellanoce Feb 10, 2023
f9807ad
skip mask distance if unmask is not found and maskAllText is true #1096
mdellanoce Feb 10, 2023
ec3767e
optimize mask/unmask rule matching #1096
mdellanoce Feb 13, 2023
3b1a859
optimization for when maskAllText is false #1096
mdellanoce Apr 6, 2023
8239b53
add benchmarks for text masking #1096
mdellanoce Apr 10, 2023
0ce76f2
Apply formatting changes
mdellanoce Apr 10, 2023
7385536
add tests for different maskAllInput configurations on dynamically ad…
billyvg Jul 13, 2023
8e85d45
Feat: Add support for replaying :defined pseudo-class of custom elements
YunFeng0817 Feb 27, 2023
eff0cc5
add isCustom flag to serialized elements
YunFeng0817 Mar 2, 2023
be9ef6a
add custom element event
YunFeng0817 Mar 5, 2023
7d8f7ab
feat: Better masking of option/radio/checkbox values
mydea Jul 7, 2023
b31f312
feat: Allow for masking of attributes via `maskAttributesFn`
billyvg Jul 12, 2023
f01b5ab
publish(repo): Publish forked rrweb packages to NPM (#20)
Lms24 Jan 24, 2023
b19ef49
fix types
billyvg Jul 18, 2023
51ab5c3
update test snapshots
billyvg Jul 19, 2023
db40ec9
feat: Add `onMutation` option to `record` (#70)
mydea Feb 28, 2023
3e05ca8
!!! ref(sentry): custom masking of input logic
billyvg Jul 21, 2023
faaff48
remove test debug logging
billyvg Jul 21, 2023
388b799
feat(sentry): Export some types for sentry
billyvg Jul 21, 2023
c2e4f39
update snapshots for properly unmasked fields
billyvg Jul 24, 2023
07576cc
ignore scroll events
billyvg Jul 24, 2023
aef48b4
feat: Add `unblockSelector` option
billyvg Jul 25, 2023
8d43725
fix tests with maskAllText, add textarea to mask-text.html since it h…
billyvg Jul 27, 2023
6c29ea0
feat: Ensure password is always masked by default
billyvg Jul 29, 2023
dc182d1
add textarea tests, add maskAllInputs test
billyvg Jul 29, 2023
2010643
fix test name
billyvg Aug 2, 2023
15f252e
export eventWithTime
billyvg Aug 2, 2023
92f8858
feat: Add `unblockSelector` option
billyvg Jul 25, 2023
32bc1cf
add textarea tests, add maskAllInputs test
billyvg Jul 29, 2023
86118d4
remove isNotScroll filter
billyvg Aug 7, 2023
3210bce
Apply formatting changes
billyvg Aug 8, 2023
aec67eb
separate type imports
billyvg Aug 8, 2023
e6e922a
review fixes
billyvg Aug 8, 2023
93650da
Apply formatting changes
billyvg Aug 8, 2023
5b63a59
add temp changelog entry for sentry release
billyvg Aug 8, 2023
05c8788
update package names
billyvg Aug 8, 2023
a933f60
Apply formatting changes
billyvg Aug 8, 2023
8990929
add lerna for sentry deploys
billyvg Aug 8, 2023
02816ee
fix typings
billyvg Aug 8, 2023
11a561f
fix lint
billyvg Aug 8, 2023
2c12d83
fix textarea masking some more
billyvg Aug 8, 2023
c38ecf6
update snaps again
billyvg Aug 8, 2023
2dfd210
feat(test): Remove scrolling from snapshots
billyvg Aug 8, 2023
5e7a5fa
forgot await
billyvg Aug 8, 2023
baca4ea
add build:tarball for sentry publish
billyvg Aug 8, 2023
afca963
update buildsteps of snapshot and types as well
billyvg Aug 8, 2023
2cde750
and rrvideo
billyvg Aug 8, 2023
d7997da
add typings for snapshot
billyvg Aug 8, 2023
e3d2353
typings for rrdom
billyvg Aug 8, 2023
5184e65
tweak upload artifacts job
billyvg Aug 9, 2023
3256f95
update changelog
billyvg Aug 9, 2023
870b7b3
prepublish -> prepare, remove prepack
billyvg Aug 9, 2023
8041635
remove @sentry-internal, bad pasta
billyvg Aug 9, 2023
5525735
remove ts-expect-error, was only local?
billyvg Aug 9, 2023
ed3a340
temp remove changelog policy from craft
billyvg Aug 9, 2023
4895c75
lint?
billyvg Aug 30, 2023
a31696b
update changelog
billyvg Aug 30, 2023
a5b873f
fixes JAVASCRIPT-2NN5 https://github.com/getsentry/sentry-javascript/…
billyvg Sep 7, 2023
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
5 changes: 5 additions & 0 deletions .changeset/fluffy-planes-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

Feat: Add support for replaying :defined pseudo-class of custom elements
6 changes: 6 additions & 0 deletions .changeset/little-moons-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'rrweb-snapshot': minor
'rrweb': minor
---

feat: Better masking of option/radio/checkbox values
7 changes: 7 additions & 0 deletions .changeset/smart-ears-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'rrweb-snapshot': patch
---

Feat: Add 'isCustom' flag to serialized elements.

This flag is used to indicate whether the element is a custom element or not. This is useful for replaying the :defined pseudo-class of custom elements.
6 changes: 6 additions & 0 deletions .changeset/twenty-tables-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'rrweb-snapshot': patch
'rrweb': patch
---

Add `maskAttributesFn` to be called when transforming an attribute. This is typically used to determine if an attribute should be masked or not.
15 changes: 15 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github:
owner: getsentry
repo: rrweb
changelogPolicy: none
preReleaseCommand: bash scripts/craft-pre-release.sh
requireNames:
- /^sentry-internal-rrweb-snapshot-.*\.tgz$/
- /^sentry-internal-rrweb-player-.*\.tgz$/
- /^sentry-internal-rrweb-.*\.tgz$/
- /^sentry-internal-rrdom-.*\.tgz$/
targets:
- name: github
includeNames: /^sentry-.*.tgz$/
- name: npm
includeNames: /^sentry-.*.tgz$/
43 changes: 40 additions & 3 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Tests
name: Build & Tests

on: [push, pull_request]
on:
push:
branches:
- master
- release/**
pull_request:

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
job_test:
name: Tests
runs-on: ubuntu-latest
steps:
Expand All @@ -19,6 +24,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: 'yarn'

- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand All @@ -39,3 +45,34 @@ jobs:
name: image-diff
path: packages/rrweb/test/*/__image_snapshots__/__diff_output__/*.png
if-no-files-found: ignore

job_artifacts:
needs: job_test
name: Upload Artifacts
runs-on: ubuntu-latest
# Build artifacts are only needed for releasing workflow.
if: startsWith(github.ref, 'refs/heads/release/')
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js lts/*
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: 'yarn'

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build Tarballs
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: yarn build:tarball

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
path: |
${{ github.workspace }}/packages/**/*.tgz
55 changes: 23 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
name: Release

name: Prepare Release
on:
push:
branches:
- master

concurrency: ${{ github.workflow }}-${{ github.ref }}

workflow_dispatch:
inputs:
version:
description: Version to release
required: true
force:
description: Force a release even when there are release-blockers (optional)
required: false
merge_target:
description: Target branch to merge into. Uses the default branch, sentry-v1, as a fallback (optional)
required: false
jobs:
release:
name: Release
runs-on: ubuntu-latest
name: 'Release a new version'
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js lts/*
uses: actions/setup-node@v3
- uses: actions/checkout@v3
with:
node-version: lts/*

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: yarn run release
token: ${{ secrets.GH_RELEASE_PAT }}
fetch-depth: 0
- name: Prepare release
uses: getsentry/action-prepare-release@v1
env:
NODE_OPTIONS: '--max-old-space-size=4096'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Send a Slack notification if a publish happens
# if: steps.changesets.outputs.published == 'true'
# # You can do something when a publish happens.
# run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!"
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
with:
version: ${{ github.event.inputs.version }}
force: ${{ github.event.inputs.force }}
merge_target: ${{ github.event.inputs.merge_target }}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 2.0.0-beta11.0

- Sentry fork of rrweb@2.0.0-alpha.11 with additional masking features

## v1.0.0

### Featrues & Improvements
### Features & Improvements

- Support record same-origin non-sandboxed iframe.
- Support record open-mode shadow DOM.
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
This project is forked from rrweb-io/rrweb (https://github.com/rrweb-io/rrweb) under the MIT license:

MIT License

Copyright (c) 2018 Contributors (https://github.com/rrweb-io/rrweb/graphs/contributors) and SmartX Inc.
Expand All @@ -19,3 +21,22 @@ 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.

Our modifications to this project are also released under the MIT license:

Copyright (c) 2023 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.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<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 rrweb Fork

This repo is a fork of [rrweb](https://github.com/rrweb-io/rrweb). The purpose is to apply patches and bugfixes to rrweb and release Sentry-internal packages with our patches included. All credits and attribution for rrweb go to the original creators of the library and all its contributors.

From this monorepo, Sentry maintains and publishes the following NPM packages:

- `@sentry-internal/rrweb` (corresponds to the [original `rrweb` package](https://www.npmjs.com/package/rrweb))
- `@sentry-internal/rrdom` (corresponds to the [original `rrdom` package](https://www.npmjs.com/package/rrdom))
- `@sentry-internal/rrweb-player` (corresponds to the [original `rrweb-player` package](https://www.npmjs.com/package/rrweb-player))
- `@sentry-internal/rrweb-snapshot` (corresponds to the [original `rrweb-snapshot` package](https://www.npmjs.com/package/rrweb-snapshot))

# rrweb

<p align="center">
<img width="100px" height="100px" src="https://www.rrweb.io/favicon.png">
</p>
<p align="center">
<a href="https://www.rrweb.io/" style="font-weight: bold">Try rrweb</a>
<a href="https://github.com/rrweb-io/rrweb" style="font-weight: bold">Check out the original rrweb Repo</a>
</p>
<p align="center">
<a href="https://rrweb.io" style="font-weight: bold">rrweb.io</a>
</p>

# rrweb
Expand Down
6 changes: 6 additions & 0 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,18 @@ The parameter of `rrweb.record` accepts the following options.
| checkoutEveryNms | - | take a full snapshot after every N ms<br />refer to the [checkout](#checkout) chapter |
| blockClass | 'rr-block' | Use a string or RegExp to configure which elements should be blocked, refer to the [privacy](#privacy) chapter |
| blockSelector | null | Use a string to configure which selector should be blocked, refer to the [privacy](#privacy) chapter |
| unblockSelector | null | Use a string to configure which selector should not be blocked, refer to the [privacy](#privacy) chapter |
| ignoreClass | 'rr-ignore' | Use a string or RegExp to configure which elements should be ignored, refer to the [privacy](#privacy) chapter |
| ignoreSelector | null | Use a string to configure which selector should be ignored, refer to the [privacy](#privacy) chapter |
| ignoreCSSAttributes | null | array of CSS attributes that should be ignored |
| maskAllText | false | mask all text content as \* |
| maskTextClass | 'rr-mask' | Use a string or RegExp to configure which elements should be masked, refer to the [privacy](#privacy) chapter |
| unmaskTextClass | null | Use a string or RegExp to configure which elements should be unmasked, refer to the [privacy](#privacy) chapter |
| maskTextSelector | null | Use a string to configure which selector should be masked, refer to the [privacy](#privacy) chapter |
| unmaskTextSelector | null | Use a string to configure which selector should be unmasked, refer to the [privacy](#privacy) chapter |
| maskAllInputs | false | mask all input content as \* |
| maskInputOptions | { password: true } | mask some kinds of input \*<br />refer to the [list](https://github.com/rrweb-io/rrweb/blob/588164aa12f1d94576f89ae0210b98f6e971c895/packages/rrweb-snapshot/src/types.ts#L77-L95) |
| maskAttributeFn | - | callback before transforming attribute. can be used to mask specific attributes |
| maskInputFn | - | customize mask input content recording logic |
| maskTextFn | - | customize mask text content recording logic |
| slimDOMOptions | {} | remove unnecessary parts of the DOM <br />refer to the [list](https://github.com/rrweb-io/rrweb/blob/588164aa12f1d94576f89ae0210b98f6e971c895/packages/rrweb-snapshot/src/types.ts#L97-L108) |
Expand All @@ -173,6 +178,7 @@ You may find some contents on the webpage which are not willing to be recorded,
- An element with the class name `.rr-block` will not be recorded. Instead, it will replay as a placeholder with the same dimension.
- An element with the class name `.rr-ignore` will not record its input events.
- All text of elements with the class name `.rr-mask` and their children will be masked.
- All text of elements with the optional unmasking class name `unmaskTextClass` and their children will be unmasked, unless any child is marked with `.rr-mask`.
- `input[type="password"]` will be masked by default.
- Mask options to mask the content in input elements.

Expand Down
1 change: 0 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"publish": {
"message": "chore(release): publish new version"
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"@monorepo-utils/workspaces-to-typescript-project-references": "^2.8.2",
"@monorepo-utils/workspaces-to-typescript-project-references": "^2.10.2",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"browserslist": "^4.21.4",
Expand All @@ -29,14 +29,16 @@
"eslint-plugin-compat": "^4.0.2",
"eslint-plugin-jest": "^27.1.3",
"eslint-plugin-tsdoc": "^0.2.16",
"lerna": "^7.1.4",
"markdownlint": "^0.25.1",
"markdownlint-cli": "^0.31.1",
"prettier": "2.8.4",
"turbo": "^1.2.4",
"typescript": "^4.9.5"
},
"scripts": {
"build:all": "NODE_OPTIONS='--max-old-space-size=4096' yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references' 'yarn turbo run prepublish'",
"build:all": "NODE_OPTIONS='--max-old-space-size=4096' yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references' 'yarn turbo run prepare'",
"build:tarball": "yarn lerna run build:tarball",
"test": "yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references --check' 'yarn turbo run test'",
"test:watch": "yarn turbo run test:watch",
"test:update": "yarn turbo run test:update",
Expand Down
8 changes: 4 additions & 4 deletions packages/rrdom-nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "rrdom-nodejs",
"name": "@sentry-internal/rrdom-nodejs",
"version": "2.0.0-alpha.11",
"scripts": {
"dev": "rollup -c -w",
"bundle": "rollup --config",
"bundle:es-only": "cross-env ES_ONLY=true rollup --config",
"check-types": "tsc -noEmit",
"test": "jest",
"prepublish": "npm run bundle",
"prepare": "npm run bundle",
"lint": "yarn eslint src/**/*.ts"
},
"keywords": [
Expand Down Expand Up @@ -48,8 +48,8 @@
"cssom": "^0.5.0",
"cssstyle": "^2.3.0",
"nwsapi": "^2.2.0",
"rrdom": "^2.0.0-alpha.11",
"rrweb-snapshot": "^2.0.0-alpha.11"
"@sentry-internal/rrdom": "^2.0.0-alpha.11",
"@sentry-internal/rrweb-snapshot": "^2.0.0-alpha.11"
},
"browserslist": [
"supports es6-class"
Expand Down
4 changes: 2 additions & 2 deletions packages/rrdom-nodejs/src/document-nodejs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { NodeType as RRNodeType } from 'rrweb-snapshot';
import { NodeType as RRNodeType } from '@sentry-internal/rrweb-snapshot';
import type { NWSAPI } from 'nwsapi';
import type { CSSStyleDeclaration as CSSStyleDeclarationType } from 'cssstyle';
import {
Expand All @@ -14,7 +14,7 @@ import {
ClassList,
IRRDocument,
CSSStyleDeclaration,
} from 'rrdom';
} from '@sentry-internal/rrdom';
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const nwsapi = require('nwsapi');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
Expand Down
4 changes: 2 additions & 2 deletions packages/rrdom-nodejs/test/document-nodejs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import * as fs from 'fs';
import * as path from 'path';
import { NodeType as RRNodeType } from 'rrweb-snapshot';
import { NodeType as RRNodeType } from '@sentry-internal/rrweb-snapshot';
import {
RRCanvasElement,
RRCDATASection,
Expand All @@ -16,7 +16,7 @@ import {
RRStyleElement,
RRText,
} from '../src/document-nodejs';
import { buildFromDom } from 'rrdom';
import { buildFromDom } from '@sentry-internal/rrdom';

describe('RRDocument for nodejs environment', () => {
describe('RRDocument API', () => {
Expand Down
9 changes: 7 additions & 2 deletions packages/rrdom-nodejs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
"sourceMap": true,
"rootDir": "src",
"outDir": "build",
"lib": ["es6", "dom"],
"lib": [
"es6",
"dom"
],
"skipLibCheck": true,
"declaration": true,
"importsNotUsedAsValues": "error"
},
"compileOnSave": true,
"exclude": ["test"],
"exclude": [
"test"
],
"include": [
"src",
"test.d.ts",
Expand Down
Loading
Loading