Skip to content

Commit c68ae04

Browse files
authored
re-implement fix for hidden input (#4)
Co-authored-by: Jakub Grzegorzewski <[email protected]>
1 parent 0e38da5 commit c68ae04

File tree

6 files changed

+142
-29
lines changed

6 files changed

+142
-29
lines changed

packages/rrweb-snapshot/src/snapshot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ function snapshot(
12831283
textarea: true,
12841284
select: true,
12851285
password: true,
1286+
hidden: true,
12861287
}
12871288
: maskAllInputs === false
12881289
? {

packages/rrweb-snapshot/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type MaskInputOptions = Partial<{
4747
textarea: boolean;
4848
select: boolean;
4949
password: boolean;
50+
hidden: boolean;
5051
}>;
5152

5253
export type SlimDOMOptions = Partial<{

packages/rrweb/src/record/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ function record<T = eventWithTime>(
155155
textarea: true,
156156
select: true,
157157
password: true,
158+
hidden: true,
158159
}
159160
: _maskInputOptions !== undefined
160161
? _maskInputOptions

packages/rrweb/test/__snapshots__/integration.test.ts.snap

Lines changed: 100 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,16 +2952,31 @@ exports[`record integration tests > can record form interactions 1`] = `
29522952
},
29532953
{
29542954
\\"type\\": 3,
2955-
\\"textContent\\": \\"\\\\n \\",
2955+
\\"textContent\\": \\"\\\\n \\",
29562956
\\"id\\": 63
2957+
},
2958+
{
2959+
\\"type\\": 2,
2960+
\\"tagName\\": \\"input\\",
2961+
\\"attributes\\": {
2962+
\\"type\\": \\"hidden\\",
2963+
\\"value\\": \\"123456\\"
2964+
},
2965+
\\"childNodes\\": [],
2966+
\\"id\\": 64
2967+
},
2968+
{
2969+
\\"type\\": 3,
2970+
\\"textContent\\": \\"\\\\n \\",
2971+
\\"id\\": 65
29572972
}
29582973
],
29592974
\\"id\\": 18
29602975
},
29612976
{
29622977
\\"type\\": 3,
29632978
\\"textContent\\": \\"\\\\n \\\\n \\",
2964-
\\"id\\": 64
2979+
\\"id\\": 66
29652980
},
29662981
{
29672982
\\"type\\": 2,
@@ -2971,15 +2986,15 @@ exports[`record integration tests > can record form interactions 1`] = `
29712986
{
29722987
\\"type\\": 3,
29732988
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
2974-
\\"id\\": 66
2989+
\\"id\\": 68
29752990
}
29762991
],
2977-
\\"id\\": 65
2992+
\\"id\\": 67
29782993
},
29792994
{
29802995
\\"type\\": 3,
29812996
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
2982-
\\"id\\": 67
2997+
\\"id\\": 69
29832998
}
29842999
],
29853000
\\"id\\": 16
@@ -4936,16 +4951,31 @@ exports[`record integration tests > can use maskInputOptions to configure which
49364951
},
49374952
{
49384953
\\"type\\": 3,
4939-
\\"textContent\\": \\"\\\\n \\",
4954+
\\"textContent\\": \\"\\\\n \\",
49404955
\\"id\\": 63
4956+
},
4957+
{
4958+
\\"type\\": 2,
4959+
\\"tagName\\": \\"input\\",
4960+
\\"attributes\\": {
4961+
\\"type\\": \\"hidden\\",
4962+
\\"value\\": \\"123456\\"
4963+
},
4964+
\\"childNodes\\": [],
4965+
\\"id\\": 64
4966+
},
4967+
{
4968+
\\"type\\": 3,
4969+
\\"textContent\\": \\"\\\\n \\",
4970+
\\"id\\": 65
49414971
}
49424972
],
49434973
\\"id\\": 18
49444974
},
49454975
{
49464976
\\"type\\": 3,
49474977
\\"textContent\\": \\"\\\\n \\\\n \\",
4948-
\\"id\\": 64
4978+
\\"id\\": 66
49494979
},
49504980
{
49514981
\\"type\\": 2,
@@ -4955,15 +4985,15 @@ exports[`record integration tests > can use maskInputOptions to configure which
49554985
{
49564986
\\"type\\": 3,
49574987
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
4958-
\\"id\\": 66
4988+
\\"id\\": 68
49594989
}
49604990
],
4961-
\\"id\\": 65
4991+
\\"id\\": 67
49624992
},
49634993
{
49644994
\\"type\\": 3,
49654995
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
4966-
\\"id\\": 67
4996+
\\"id\\": 69
49674997
}
49684998
],
49694999
\\"id\\": 16
@@ -6763,16 +6793,31 @@ exports[`record integration tests > should mask inputs via function call 1`] = `
67636793
},
67646794
{
67656795
\\"type\\": 3,
6766-
\\"textContent\\": \\"\\\\n \\",
6796+
\\"textContent\\": \\"\\\\n \\",
67676797
\\"id\\": 63
6798+
},
6799+
{
6800+
\\"type\\": 2,
6801+
\\"tagName\\": \\"input\\",
6802+
\\"attributes\\": {
6803+
\\"type\\": \\"hidden\\",
6804+
\\"value\\": \\"******\\"
6805+
},
6806+
\\"childNodes\\": [],
6807+
\\"id\\": 64
6808+
},
6809+
{
6810+
\\"type\\": 3,
6811+
\\"textContent\\": \\"\\\\n \\",
6812+
\\"id\\": 65
67686813
}
67696814
],
67706815
\\"id\\": 18
67716816
},
67726817
{
67736818
\\"type\\": 3,
67746819
\\"textContent\\": \\"\\\\n \\\\n \\",
6775-
\\"id\\": 64
6820+
\\"id\\": 66
67766821
},
67776822
{
67786823
\\"type\\": 2,
@@ -6782,15 +6827,15 @@ exports[`record integration tests > should mask inputs via function call 1`] = `
67826827
{
67836828
\\"type\\": 3,
67846829
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
6785-
\\"id\\": 66
6830+
\\"id\\": 68
67866831
}
67876832
],
6788-
\\"id\\": 65
6833+
\\"id\\": 67
67896834
},
67906835
{
67916836
\\"type\\": 3,
67926837
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
6793-
\\"id\\": 67
6838+
\\"id\\": 69
67946839
}
67956840
],
67966841
\\"id\\": 16
@@ -10591,16 +10636,31 @@ exports[`record integration tests > should not record input values if maskAllInp
1059110636
},
1059210637
{
1059310638
\\"type\\": 3,
10594-
\\"textContent\\": \\"\\\\n \\",
10639+
\\"textContent\\": \\"\\\\n \\",
1059510640
\\"id\\": 63
10641+
},
10642+
{
10643+
\\"type\\": 2,
10644+
\\"tagName\\": \\"input\\",
10645+
\\"attributes\\": {
10646+
\\"type\\": \\"hidden\\",
10647+
\\"value\\": \\"******\\"
10648+
},
10649+
\\"childNodes\\": [],
10650+
\\"id\\": 64
10651+
},
10652+
{
10653+
\\"type\\": 3,
10654+
\\"textContent\\": \\"\\\\n \\",
10655+
\\"id\\": 65
1059610656
}
1059710657
],
1059810658
\\"id\\": 18
1059910659
},
1060010660
{
1060110661
\\"type\\": 3,
1060210662
\\"textContent\\": \\"\\\\n \\\\n \\",
10603-
\\"id\\": 64
10663+
\\"id\\": 66
1060410664
},
1060510665
{
1060610666
\\"type\\": 2,
@@ -10610,15 +10670,15 @@ exports[`record integration tests > should not record input values if maskAllInp
1061010670
{
1061110671
\\"type\\": 3,
1061210672
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
10613-
\\"id\\": 66
10673+
\\"id\\": 68
1061410674
}
1061510675
],
10616-
\\"id\\": 65
10676+
\\"id\\": 67
1061710677
},
1061810678
{
1061910679
\\"type\\": 3,
1062010680
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
10621-
\\"id\\": 67
10681+
\\"id\\": 69
1062210682
}
1062310683
],
1062410684
\\"id\\": 16
@@ -13705,16 +13765,31 @@ exports[`record integration tests > should record input userTriggered values if
1370513765
},
1370613766
{
1370713767
\\"type\\": 3,
13708-
\\"textContent\\": \\"\\\\n \\",
13768+
\\"textContent\\": \\"\\\\n \\",
1370913769
\\"id\\": 63
13770+
},
13771+
{
13772+
\\"type\\": 2,
13773+
\\"tagName\\": \\"input\\",
13774+
\\"attributes\\": {
13775+
\\"type\\": \\"hidden\\",
13776+
\\"value\\": \\"123456\\"
13777+
},
13778+
\\"childNodes\\": [],
13779+
\\"id\\": 64
13780+
},
13781+
{
13782+
\\"type\\": 3,
13783+
\\"textContent\\": \\"\\\\n \\",
13784+
\\"id\\": 65
1371013785
}
1371113786
],
1371213787
\\"id\\": 18
1371313788
},
1371413789
{
1371513790
\\"type\\": 3,
1371613791
\\"textContent\\": \\"\\\\n \\\\n \\",
13717-
\\"id\\": 64
13792+
\\"id\\": 66
1371813793
},
1371913794
{
1372013795
\\"type\\": 2,
@@ -13724,15 +13799,15 @@ exports[`record integration tests > should record input userTriggered values if
1372413799
{
1372513800
\\"type\\": 3,
1372613801
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
13727-
\\"id\\": 66
13802+
\\"id\\": 68
1372813803
}
1372913804
],
13730-
\\"id\\": 65
13805+
\\"id\\": 67
1373113806
},
1373213807
{
1373313808
\\"type\\": 3,
1373413809
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
13735-
\\"id\\": 67
13810+
\\"id\\": 69
1373613811
}
1373713812
],
1373813813
\\"id\\": 16

packages/rrweb/test/html/form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<input type="password" />
3535
</label>
3636
<textarea>pre value</textarea>
37+
<input type="hidden" value="123456">
3738
</form>
3839
</body>
3940
</html>

packages/rrweb/test/record/__snapshots__/cross-origin-iframes.test.ts.snap

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,9 +1438,26 @@ exports[`cross origin iframes > form.html > should map input events correctly 1`
14381438
},
14391439
{
14401440
\\"type\\": 3,
1441-
\\"textContent\\": \\"\\\\n \\",
1441+
\\"textContent\\": \\"\\\\n \\",
14421442
\\"rootId\\": 11,
14431443
\\"id\\": 75
1444+
},
1445+
{
1446+
\\"type\\": 2,
1447+
\\"tagName\\": \\"input\\",
1448+
\\"attributes\\": {
1449+
\\"type\\": \\"hidden\\",
1450+
\\"value\\": \\"123456\\"
1451+
},
1452+
\\"childNodes\\": [],
1453+
\\"rootId\\": 11,
1454+
\\"id\\": 76
1455+
},
1456+
{
1457+
\\"type\\": 3,
1458+
\\"textContent\\": \\"\\\\n \\",
1459+
\\"rootId\\": 11,
1460+
\\"id\\": 77
14441461
}
14451462
],
14461463
\\"rootId\\": 11,
@@ -1450,7 +1467,7 @@ exports[`cross origin iframes > form.html > should map input events correctly 1`
14501467
\\"type\\": 3,
14511468
\\"textContent\\": \\"\\\\n \\\\n\\\\n\\",
14521469
\\"rootId\\": 11,
1453-
\\"id\\": 76
1470+
\\"id\\": 78
14541471
}
14551472
],
14561473
\\"rootId\\": 11,
@@ -2451,9 +2468,26 @@ exports[`cross origin iframes > form.html > should map scroll events correctly 1
24512468
},
24522469
{
24532470
\\"type\\": 3,
2454-
\\"textContent\\": \\"\\\\n \\",
2471+
\\"textContent\\": \\"\\\\n \\",
24552472
\\"rootId\\": 11,
24562473
\\"id\\": 75
2474+
},
2475+
{
2476+
\\"type\\": 2,
2477+
\\"tagName\\": \\"input\\",
2478+
\\"attributes\\": {
2479+
\\"type\\": \\"hidden\\",
2480+
\\"value\\": \\"123456\\"
2481+
},
2482+
\\"childNodes\\": [],
2483+
\\"rootId\\": 11,
2484+
\\"id\\": 76
2485+
},
2486+
{
2487+
\\"type\\": 3,
2488+
\\"textContent\\": \\"\\\\n \\",
2489+
\\"rootId\\": 11,
2490+
\\"id\\": 77
24572491
}
24582492
],
24592493
\\"rootId\\": 11,
@@ -2463,7 +2497,7 @@ exports[`cross origin iframes > form.html > should map scroll events correctly 1
24632497
\\"type\\": 3,
24642498
\\"textContent\\": \\"\\\\n \\\\n\\\\n\\",
24652499
\\"rootId\\": 11,
2466-
\\"id\\": 76
2500+
\\"id\\": 78
24672501
}
24682502
],
24692503
\\"rootId\\": 11,

0 commit comments

Comments
 (0)