6
6
7
7
from sentry import onboarding_tasks
8
8
from sentry .analytics import record
9
+ from sentry .analytics .events .onboarding_complete import OnboardingCompleteEvent
10
+ from sentry .integrations .analytics import IntegrationAddedEvent
9
11
from sentry .models .options .organization_option import OrganizationOption
10
12
from sentry .models .organizationonboardingtask import (
11
13
OnboardingTask ,
30
32
)
31
33
from sentry .silo .base import SiloMode
32
34
from sentry .testutils .cases import TestCase
35
+ from sentry .testutils .helpers .analytics import assert_last_analytics_event
33
36
from sentry .testutils .helpers .datetime import before_now
34
37
from sentry .testutils .helpers .features import with_feature
35
38
from sentry .testutils .silo import assume_test_silo_mode
@@ -745,13 +748,15 @@ def test_real_time_notifications_added(self, record_analytics):
745
748
)
746
749
assert task is not None
747
750
748
- record_analytics .assert_called_with (
749
- "integration.added" ,
750
- user_id = self .user .id ,
751
- default_user_id = self .organization .default_owner_id ,
752
- organization_id = self .organization .id ,
753
- id = integration_id ,
754
- provider = "slack" ,
751
+ assert_last_analytics_event (
752
+ record_analytics ,
753
+ IntegrationAddedEvent (
754
+ user_id = self .user .id ,
755
+ default_user_id = self .organization .default_owner_id ,
756
+ organization_id = self .organization .id ,
757
+ id = integration_id ,
758
+ provider = "slack" ,
759
+ ),
755
760
)
756
761
757
762
@patch ("sentry.analytics.record" , wraps = record )
@@ -770,13 +775,15 @@ def test_source_code_management_added(self, record_analytics):
770
775
)
771
776
assert task is not None
772
777
773
- record_analytics .assert_called_with (
774
- "integration.added" ,
775
- user_id = self .user .id ,
776
- default_user_id = self .organization .default_owner_id ,
777
- organization_id = self .organization .id ,
778
- id = integration_id ,
779
- provider = "github" ,
778
+ assert_last_analytics_event (
779
+ record_analytics ,
780
+ IntegrationAddedEvent (
781
+ user_id = self .user .id ,
782
+ default_user_id = self .organization .default_owner_id ,
783
+ organization_id = self .organization .id ,
784
+ id = integration_id ,
785
+ provider = "github" ,
786
+ ),
780
787
)
781
788
782
789
def test_second_platform_complete (self ):
@@ -985,13 +992,15 @@ def test_new_onboarding_complete(self, record_analytics):
985
992
)
986
993
is not None
987
994
)
988
- record_analytics .assert_called_with (
989
- "integration.added" ,
990
- user_id = self .user .id ,
991
- default_user_id = self .organization .default_owner_id ,
992
- organization_id = self .organization .id ,
993
- provider = github_integration .provider ,
994
- id = github_integration .id ,
995
+ assert_last_analytics_event (
996
+ record_analytics ,
997
+ IntegrationAddedEvent (
998
+ user_id = self .user .id ,
999
+ default_user_id = self .organization .default_owner_id ,
1000
+ organization_id = self .organization .id ,
1001
+ provider = github_integration .provider ,
1002
+ id = github_integration .id ,
1003
+ ),
995
1004
)
996
1005
997
1006
# Invite your team
@@ -1064,13 +1073,15 @@ def test_new_onboarding_complete(self, record_analytics):
1064
1073
)
1065
1074
is not None
1066
1075
)
1067
- record_analytics .assert_called_with (
1068
- "integration.added" ,
1069
- user_id = self .user .id ,
1070
- default_user_id = self .organization .default_owner_id ,
1071
- organization_id = self .organization .id ,
1072
- provider = slack_integration .provider ,
1073
- id = slack_integration .id ,
1076
+ assert_last_analytics_event (
1077
+ record_analytics ,
1078
+ IntegrationAddedEvent (
1079
+ user_id = self .user .id ,
1080
+ default_user_id = self .organization .default_owner_id ,
1081
+ organization_id = self .organization .id ,
1082
+ provider = slack_integration .provider ,
1083
+ id = slack_integration .id ,
1084
+ ),
1074
1085
)
1075
1086
1076
1087
# Add Sentry to other parts app
@@ -1113,11 +1124,13 @@ def test_new_onboarding_complete(self, record_analytics):
1113
1124
).count ()
1114
1125
== 1
1115
1126
)
1116
- record_analytics .assert_called_with (
1117
- "onboarding.complete" ,
1118
- user_id = self .user .id ,
1119
- organization_id = self .organization .id ,
1120
- referrer = "onboarding_tasks" ,
1127
+ assert_last_analytics_event (
1128
+ record_analytics ,
1129
+ OnboardingCompleteEvent (
1130
+ user_id = self .user .id ,
1131
+ organization_id = self .organization .id ,
1132
+ referrer = "onboarding_tasks" ,
1133
+ ),
1121
1134
)
1122
1135
1123
1136
@patch ("sentry.analytics.record" , wraps = record )
0 commit comments