Skip to content

Commit

Permalink
Add pixel for process creation, for both main and VPN processes (#4208)
Browse files Browse the repository at this point in the history
<!--
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/1206681496516579/f

### Description

Adds process creation pixels, for both main app and VPN process.

### Steps to test this PR

- [x] Add logcat filter `message~:"m_process_created"`

**Main app process**
- [x] Launch the app; verify you see `m_process_created_main`
- [x] Background and restore the app; verify you do **not** see it again
- [x] Kill the app and relaunch it; verify you **do** see it again

**VPN process**
- [x] onboard through AppTP
- [x] verify you see `m_process_created_vpn` in the logs
  • Loading branch information
CDRussell authored Feb 26, 2024
1 parent cd000f1 commit e818301
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/duckduckgo/app/pixels/AppPixelName.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import com.duckduckgo.app.statistics.pixels.Pixel

enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
APP_LAUNCH("ml"),
PROCESS_CREATED_MAIN("m_process_created_main"),
PROCESS_CREATED_VPN("m_process_created_vpn"),

FORGET_ALL_PRESSED_BROWSING("mf_bp"),
FORGET_ALL_PRESSED_TABSWITCHING("mf_tp"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2024 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.app.pixels

import androidx.lifecycle.LifecycleOwner
import com.duckduckgo.app.lifecycle.MainProcessLifecycleObserver
import com.duckduckgo.app.lifecycle.VpnProcessLifecycleObserver
import com.duckduckgo.app.statistics.pixels.Pixel
import com.duckduckgo.di.scopes.AppScope
import com.squareup.anvil.annotations.ContributesMultibinding
import dagger.SingleInstanceIn
import javax.inject.Inject

@ContributesMultibinding(
scope = AppScope::class,
boundType = MainProcessLifecycleObserver::class,
)
@SingleInstanceIn(AppScope::class)
class ProcessCreationMainPixelSender @Inject constructor(
private val pixel: Pixel,
) : MainProcessLifecycleObserver {

override fun onCreate(owner: LifecycleOwner) {
pixel.fire(AppPixelName.PROCESS_CREATED_MAIN)
}
}

@ContributesMultibinding(
scope = AppScope::class,
boundType = VpnProcessLifecycleObserver::class,
)
@SingleInstanceIn(AppScope::class)
class ProcessCreationVpnPixelSender @Inject constructor(
private val pixel: Pixel,
) : VpnProcessLifecycleObserver {

override fun onVpnProcessCreated() {
pixel.fire(AppPixelName.PROCESS_CREATED_VPN)
}
}

0 comments on commit e818301

Please sign in to comment.