-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add autocapture in configs (#207)
* feat: add autocapture options and deprecate default tracking * feat: track target hierarchy * fix: fix lint * fix: fix a bug that occurs when default tracking options are set after configuration is created * fix: refactor default tracking deprecation * fix: handle changes to defaultTrackingOptions after being assigned to Configuration * fix: fix lint * fix: attach autocapture option to defaultTracking to monitor changes to defaultTracking * fix: remove redundant code * refactor: refactor code to reduce object creation * feat: set autocapture configs as a mutable set of options * fix: fix lint * refactor: refactor to use simple remove and add instead of augmented assignment * refactor: remove redundant code * feat: add experimental annotation to element interactions option * fix: fix failing test * fix: fix failing test * fix: fix failing test * feat: make autocapture options immutable and discard changes to defaultTracking options * fix: fix lint * test: add test for deprecated parameter. * Revert "fix: fix lint" This reverts commit afad034. * feat: make changes to defaultTracking and trackingSessionEvents effective for autocapture * fix: add a secondary constructor for Configuration to deprecate defaultTracking * fix: fix the bug when a new DefaultTrackingOptions is passed to the Configuration * test: add test for deprecation logic * test: add test for deprecation logic * fix: changes to the default tracking options replace the recent autocapture options entirely. * fix: fix lint
- Loading branch information
1 parent
4b834bd
commit dcb9393
Showing
20 changed files
with
524 additions
and
104 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
android/src/main/java/com/amplitude/android/AutocaptureOptions.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,66 @@ | ||
package com.amplitude.android | ||
|
||
/** | ||
* Autocapture options to enable or disable specific types of autocapture events. | ||
*/ | ||
enum class AutocaptureOption { | ||
/** | ||
* Enable session tracking. | ||
*/ | ||
SESSIONS, | ||
/** | ||
* Enable app lifecycle tracking. | ||
*/ | ||
APP_LIFECYCLES, | ||
/** | ||
* Enable deep link tracking. | ||
*/ | ||
DEEP_LINKS, | ||
/** | ||
* Enable screen view tracking. | ||
*/ | ||
SCREEN_VIEWS, | ||
/** | ||
* Enable element interaction tracking. | ||
*/ | ||
@ExperimentalAmplitudeFeature | ||
ELEMENT_INTERACTIONS | ||
} | ||
|
||
class AutocaptureOptionsBuilder { | ||
private val options = mutableSetOf<AutocaptureOption>() | ||
|
||
operator fun AutocaptureOption.unaryPlus() { | ||
options.add(this) | ||
} | ||
|
||
val sessions = AutocaptureOption.SESSIONS | ||
val appLifecycles = AutocaptureOption.APP_LIFECYCLES | ||
val deepLinks = AutocaptureOption.DEEP_LINKS | ||
val screenViews = AutocaptureOption.SCREEN_VIEWS | ||
@ExperimentalAmplitudeFeature | ||
val elementInteractions = AutocaptureOption.ELEMENT_INTERACTIONS | ||
|
||
fun build(): Set<AutocaptureOption> = options.toSet() | ||
} | ||
|
||
/** | ||
* Helper function to create a set of autocapture options. | ||
* | ||
* Example usage: | ||
* ``` | ||
* val options = autocaptureOptions { | ||
* +sessions | ||
* +appLifecycles | ||
* +deepLinks | ||
* +screenViews | ||
* +elementInteractions | ||
* } | ||
* ``` | ||
* | ||
* @param init Function to build the set of autocapture options. | ||
* @return Set of autocapture options. | ||
*/ | ||
fun autocaptureOptions(init: AutocaptureOptionsBuilder.() -> Unit): Set<AutocaptureOption> { | ||
return AutocaptureOptionsBuilder().apply(init).build() | ||
} |
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
Oops, something went wrong.