-
Notifications
You must be signed in to change notification settings - Fork 935
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync: Usage Pixels and Monitoring (#4018)
<!-- Note: This checklist is a reminder of our shared engineering expectations. The items in Bold are required If your PR involves UI changes: 1. Upload screenshots or screencasts that illustrate the changes before / after 2. Add them under the UI changes section (feel free to add more columns if needed) If your PR does not involve UI changes, you can remove the **UI changes** section At a minimum, make sure your changes are tested in API 23 and one of the more recent API levels available. --> Task/Issue URL: https://app.asana.com/0/488551667048375/1206193954622385/f ### Description This PR adds the usage pixels for Sync ### Steps to test this PR _Signup Direct_ Fired when user sets up a sync account directly. - [x] Create a new sync account - [x] Verify “m.sync.signup.direct” pixel is sent _Signup Connect_ Fired when user sets up a sync account from connect flow. You’ll need two devices for this one. - [x] Device A - Open Sync Setup screen - [x] Tap on Sync with another device - [x] Device B- Open Sync Setup screen - [x] Tap on Sync with another device - [x] Device A - Read QR code present in Device B - [x] Verify “m.sync.signup.connect” pixel is sent in Device B - [x] Verify “m.sync.login” pixel is sent in Device A _Login - Entering Code_ Fired when adding new device to existing account. You’ll need two devices for this one. - [x] Device A - Create a new sync account - [x] Copy the recovery code - [x] Device B- Open Sync Setup screen - [x] Tap on Sync with another device - [x] Tap on Manually Enter Code - [x] Paste code from Device A - [x] Verify “m.sync.login” pixel is sent in Device B _Login - Scan QR_ Fired when adding new device to existing account. You’ll need two devices for this one. - [x] Device A - Create a new sync account - [x] Navigate to Sync Settings - [x] Device B- Open Sync Setup screen - [x] Tap on Sync with another device - [x] Scan QR Code from Device A - [x] Verify “m.sync.login” pixel is sent in Device B _Login - Recover Account with Code_ Fired when adding new device to existing account. You’ll need two devices for this one. - [x] Device A - Create a new sync account - [x] Copy the recovery code - [x] Device B- Open Sync Setup screen - [x] Tap on Recover Synced Data - [x] Tap on Manually Enter Code - [x] Paste code from Device A - [x] Verify “m.sync.login” pixel is sent in Device B _Login - Recover Account with QR_ Fired when adding new device to existing account. You’ll need two devices for this one. - [x] Device A - Create a new sync account - [x] Navigate to Sync Settings - [x] Device B- Open Sync Setup screen - [x] Tap on Recover Synced Data - [x] Scan QR Code from Device A - [x] Verify “m.sync.login” pixel is sent in Device B _Daily pixel_ Fired for first sync on a given day. - [x] Create a new sync account - [x] Verify “m.sync.daily” pixel is sent - [x] Close app - [x] Open app again - [x] Verify “m.sync.daily” pixel is NOT sent
- Loading branch information
Showing
15 changed files
with
236 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
sync/sync-impl/src/test/java/com/duckduckgo/sync/impl/pixels/SyncPixelsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright (c) 2023 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.sync.impl.pixels | ||
|
||
import com.duckduckgo.app.statistics.pixels.Pixel | ||
import com.duckduckgo.common.test.api.InMemorySharedPreferences | ||
import com.duckduckgo.sync.impl.stats.SyncStatsRepository | ||
import com.duckduckgo.sync.store.SharedPrefsProvider | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.mockito.kotlin.eq | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.times | ||
import org.mockito.kotlin.verify | ||
import org.mockito.kotlin.whenever | ||
|
||
class SyncPixelsTest { | ||
|
||
private var pixel: Pixel = mock() | ||
private var syncStatsRepository: SyncStatsRepository = mock() | ||
private var sharedPrefsProv: SharedPrefsProvider = mock() | ||
|
||
private lateinit var testee: RealSyncPixels | ||
|
||
@Before | ||
fun setUp() { | ||
val prefs = InMemorySharedPreferences() | ||
whenever( | ||
sharedPrefsProv.getSharedPrefs(eq("com.duckduckgo.sync.pixels.v1")), | ||
).thenReturn(prefs) | ||
|
||
testee = RealSyncPixels( | ||
pixel, | ||
syncStatsRepository, | ||
sharedPrefsProv, | ||
) | ||
} | ||
|
||
@Test | ||
fun whenDailyPixelCalledThenPixelFired() { | ||
testee.fireDailyPixel() | ||
|
||
verify(pixel).fire(SyncPixelName.SYNC_DAILY_PIXEL) | ||
} | ||
|
||
@Test | ||
fun whenDailyPixelCalledTwiceThenPixelFiredOnce() { | ||
testee.fireDailyPixel() | ||
testee.fireDailyPixel() | ||
|
||
verify(pixel).fire(SyncPixelName.SYNC_DAILY_PIXEL) | ||
} | ||
|
||
@Test | ||
fun whenLoginPixelCalledThenPixelFired() { | ||
testee.fireLoginPixel() | ||
|
||
verify(pixel).fire(SyncPixelName.SYNC_LOGIN) | ||
} | ||
|
||
@Test | ||
fun whenSignupDirectPixelCalledThenPixelFired() { | ||
testee.fireSignupDirectPixel() | ||
|
||
verify(pixel).fire(SyncPixelName.SYNC_SIGNUP_DIRECT) | ||
} | ||
|
||
@Test | ||
fun whenSignupConnectPixelCalledThenPixelFired() { | ||
testee.fireSignupConnectPixel() | ||
|
||
verify(pixel).fire(SyncPixelName.SYNC_SIGNUP_CONNECT) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.