Skip to content

Commit 9cd7269

Browse files
committed
Added shouldSendSiteProperties var to WooAnalyticsStat
1 parent 0348739 commit 9cd7269

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

WooCommerce/Classes/Analytics/WooAnalyticsStat.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import WordPressShared
44
/// This enum contains all of the events we track in the app. Please reference the "Woo Mobile Events Draft i2"
55
/// spreadsheet for more details.
66
///
7+
/// Note: if you would like to exclude site properties (e.g. `blog_id`) for a given event, please
8+
/// add the event to the `shouldSendSiteProperties` var.
9+
///
710
public enum WooAnalyticsStat: String {
811

912
// Application Events
@@ -124,6 +127,35 @@ public enum WooAnalyticsStat: String {
124127

125128
public extension WooAnalyticsStat {
126129

130+
131+
/// Indicates if site information should be included with this event when it's sent to the tracks server.
132+
/// Returns `true` if it should be included, `false` otherwise.
133+
///
134+
/// Note: Currently all application-level and authentication events will return false. If you wish
135+
/// to include additional no-site-info events, please add them here.
136+
///
137+
var shouldSendSiteProperties: Bool {
138+
switch self {
139+
// Application events
140+
case .applicationClosed, .applicationOpened, .applicationUpgraded, .applicationInstalled:
141+
return false
142+
// Authentication Events
143+
case .signedIn, .logout, .openedLogin, .loginFailed,
144+
.loginAutoFillCredentialsFilled, .loginAutoFillCredentialsUpdated, .loginEmailFormViewed, .loginMagicLinkOpenEmailClientViewed,
145+
.loginMagicLinkRequestFormViewed, .loginMagicLinkExited, .loginMagicLinkFailed, .loginMagicLinkOpened,
146+
.loginMagicLinkRequested, .loginMagicLinkSucceeded, .loginPasswordFormViewed, .loginURLFormViewed,
147+
.loginURLHelpScreenViewed, .loginUsernamePasswordFormViewed, .loginTwoFactorFormViewed, .loginEpilogueViewed,
148+
.loginEpilogueStoresShown, .loginEpilogueContinueTapped, .loginProloguePaged, .loginPrologueViewed,
149+
.loginPrologueContinueTapped, .loginPrologueJetpackInstructions, .loginForgotPasswordClicked, .loginSocialButtonClick,
150+
.loginSocialButtonFailure, .loginSocialConnectSuccess, .loginSocialConnectFailure, .loginSocialSuccess,
151+
.loginSocialFailure, .loginSocial2faNeeded, .loginSocialAccountsNeedConnecting, .loginSocialErrorUnknownUser,
152+
.onePasswordFailed, .onePasswordLogin, .onePasswordSignup, .twoFactorCodeRequested, .twoFactorSentSMS:
153+
return false
154+
default:
155+
return true
156+
}
157+
}
158+
127159
/// Converts the provided WPAnalyticsStat into a WooAnalyticsStat.
128160
/// This whole process kinda stinks, but we need this for the `WordPressAuthenticatorDelegate`
129161
/// implementation. ☹️ Feel free to refactor later on!

0 commit comments

Comments
 (0)