@@ -233,6 +233,26 @@ class ApplicationExitInfoEventProcessorTest {
233233 assertEquals(SentryBaseEvent .DEFAULT_PLATFORM , processed.platform)
234234 }
235235
236+ @Test
237+ fun `when user info is disabled, does not set device id` () {
238+ fixture.options.dataCollection.setUserInfo(false )
239+ val hint = HintUtils .createWithTypeCheckHint(AbnormalExitHint ())
240+
241+ val processed = processEvent(hint)
242+
243+ assertNull(processed.contexts.device!! .id)
244+ }
245+
246+ @Test
247+ fun `when user info is enabled, sets device id` () {
248+ fixture.options.dataCollection.setUserInfo(true )
249+ val hint = HintUtils .createWithTypeCheckHint(AbnormalExitHint ())
250+
251+ val processed = processEvent(hint, isSendDefaultPii = false )
252+
253+ assertNotNull(processed.contexts.device!! .id)
254+ }
255+
236256 @Test
237257 fun `when backfillable event is not enrichable, sets OS` () {
238258 val hint = HintUtils .createWithTypeCheckHint(BackfillableHint (shouldEnrich = false ))
@@ -356,6 +376,28 @@ class ApplicationExitInfoEventProcessorTest {
356376 assertNull(processed.user!! .ipAddress)
357377 }
358378
379+ @Test
380+ fun `when user info is disabled, does not backfill automatic user data` () {
381+ fixture.options.dataCollection.setUserInfo(false )
382+ val hint = HintUtils .createWithTypeCheckHint(BackfillableHint ())
383+ val processed = processEvent(hint, isSendDefaultPii = true , populateScopeCache = true )
384+
385+ assertEquals(" bot" , processed.user!! .username)
386+ assertEquals(" bot@me.com" , processed.user!! .id)
387+ assertNull(processed.user!! .ipAddress)
388+ }
389+
390+ @Test
391+ fun `when user info is enabled, backfills automatic user data` () {
392+ fixture.options.dataCollection.setUserInfo(true )
393+ val hint = HintUtils .createWithTypeCheckHint(BackfillableHint ())
394+ val processed = processEvent(hint, isSendDefaultPii = false , populateScopeCache = true )
395+
396+ assertEquals(" bot" , processed.user!! .username)
397+ assertEquals(" bot@me.com" , processed.user!! .id)
398+ assertEquals(" {{auto}}" , processed.user!! .ipAddress)
399+ }
400+
359401 @Test
360402 fun `when backfillable event is enrichable, backfills serialized options data` () {
361403 val hint = HintUtils .createWithTypeCheckHint(BackfillableHint ())
@@ -640,6 +682,19 @@ class ApplicationExitInfoEventProcessorTest {
640682 assertEquals(Installation .deviceId, processed!! .user!! .id)
641683 }
642684
685+ @Test
686+ fun `when user info is disabled, does not set installation id for missing user id` () {
687+ fixture.options.dataCollection.setUserInfo(false )
688+ val hint = HintUtils .createWithTypeCheckHint(BackfillableHint ())
689+ val original = SentryEvent ()
690+ val processor = fixture.getSut(tmpDir)
691+ fixture.persistOptions(USER_FILENAME , User ())
692+
693+ val processed = processor.process(original, hint)
694+
695+ assertNull(processed!! .user!! .id)
696+ }
697+
643698 @Test
644699 fun `when event has some fields set, does not override them` () {
645700 val hint = HintUtils .createWithTypeCheckHint(BackfillableHint ())
0 commit comments