File tree Expand file tree Collapse file tree 6 files changed +87
-0
lines changed
packages/integration-tests/suites/public-api/setUser Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ import * as Sentry from '@sentry/browser' ;
2
+
3
+ window . Sentry = Sentry ;
4
+
5
+ Sentry . init ( {
6
+ dsn :
'https://[email protected] /1337' ,
7
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ <html >
3
+ <head >
4
+ <meta charset =" utf-8" />
5
+ <title ></title >
6
+ <script src =" {{ htmlWebpackPlugin.options.initialization }} " ></script >
7
+ </head >
8
+ <body >
9
+ <script src =" {{ htmlWebpackPlugin.options.subject }} " ></script >
10
+ </body >
11
+ </html >
Original file line number Diff line number Diff line change
1
+ Sentry . captureMessage ( 'no_user' ) ;
2
+
3
+ Sentry . setUser ( {
4
+ id : 'foo' ,
5
+ ip_address : 'bar' ,
6
+ other_key : 'baz' ,
7
+ } ) ;
8
+
9
+ Sentry . captureMessage ( 'user' ) ;
10
+
11
+ Sentry . setUser ( null ) ;
12
+
13
+ Sentry . captureMessage ( 'unset_user' ) ;
Original file line number Diff line number Diff line change
1
+ import { expect } from '@playwright/test' ;
2
+
3
+ import { sentryTest } from '../../../../utils/fixtures' ;
4
+ import { getMultipleSentryRequests } from '../../../../utils/helpers' ;
5
+
6
+ sentryTest ( 'should unset user' , async ( { getLocalTestPath, page } ) => {
7
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
8
+
9
+ const eventData = await getMultipleSentryRequests ( page , 3 , url ) ;
10
+
11
+ expect ( eventData [ 0 ] . message ) . toBe ( 'no_user' ) ;
12
+ expect ( eventData [ 0 ] . user ) . toBeUndefined ( ) ;
13
+
14
+ expect ( eventData [ 1 ] . message ) . toBe ( 'user' ) ;
15
+ expect ( eventData [ 1 ] . user ) . toMatchObject ( {
16
+ id : 'foo' ,
17
+ ip_address : 'bar' ,
18
+ other_key : 'baz' ,
19
+ } ) ;
20
+
21
+ expect ( eventData [ 2 ] . message ) . toBe ( 'unset_user' ) ;
22
+ expect ( eventData [ 2 ] . user ) . toBeUndefined ( ) ;
23
+ } ) ;
Original file line number Diff line number Diff line change
1
+ Sentry . setUser ( {
2
+ id : 'foo' ,
3
+ ip_address : 'bar' ,
4
+ } ) ;
5
+
6
+ Sentry . captureMessage ( 'first_user' ) ;
7
+
8
+ Sentry . setUser ( {
9
+ id : 'baz' ,
10
+ } ) ;
11
+
12
+ Sentry . captureMessage ( 'second_user' ) ;
Original file line number Diff line number Diff line change
1
+ import { expect } from '@playwright/test' ;
2
+
3
+ import { sentryTest } from '../../../../utils/fixtures' ;
4
+ import { getMultipleSentryRequests } from '../../../../utils/helpers' ;
5
+
6
+ sentryTest ( 'should update user' , async ( { getLocalTestPath, page } ) => {
7
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
8
+
9
+ const eventData = await getMultipleSentryRequests ( page , 2 , url ) ;
10
+
11
+ expect ( eventData [ 0 ] . message ) . toBe ( 'first_user' ) ;
12
+ expect ( eventData [ 0 ] . user ) . toMatchObject ( {
13
+ id : 'foo' ,
14
+ ip_address : 'bar' ,
15
+ } ) ;
16
+
17
+ expect ( eventData [ 1 ] . message ) . toBe ( 'second_user' ) ;
18
+ expect ( eventData [ 1 ] . user ) . toMatchObject ( {
19
+ id : 'baz' ,
20
+ } ) ;
21
+ } ) ;
You can’t perform that action at this time.
0 commit comments