Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add scroll and swipe autocapture #201

Merged
merged 33 commits into from
Jun 13, 2024

Conversation

PouriaAmini
Copy link
Contributor

Summary

This PR adds support for scroll and swipe autocapture. The functionality is enabled by default when userInteractions is set to true in DefaultTrackingOptions.

@OptIn(ExperimentalAmplitudeFeature::class)
Amplitude(
    Configuration(
        apiKey = AMPLITUDE_API_KEY,
        context = applicationContext,
        defaultTracking = DefaultTrackingOptions(
            userInteractions = true
        )
    )
)

New automatically captured event

[Amplitude] Element Scrolled: Emitted when a user scrolls on a scrollable element in the legacy Android View system or a tagged scrollable @Composable functions in Compose.

[Amplitude] Element Swiped: Emitted when a user flings on a UI element that was previously scrolled/moved.

Note: To capture the event in Compose, the scrollable @Composable functions must include a Modifier.testTag, otherwise the event will not be captured. Scrollable @Composable functions have an ScrollBy lambda or a Modifier.scrollable modifier (for Jetpack Compose > 1.5).

New automatically captured properties

[Amplitude] Direction: (Android Views and Compose) The direction of the scroll or swipe (Up, Right, Down, Left).

Optimizations around Autocapture implementations

  1. Resource name has a fallback now in case a resourceEntryName does not exist.
  2. Reflection is done lazily for Compose internals.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: no

PouriaAmini and others added 30 commits June 3, 2024 14:29
# Conflicts:
#	android/src/main/java/com/amplitude/android/internal/gestures/AutocaptureGestureListener.kt
#	android/src/main/java/com/amplitude/android/utilities/DefaultEventUtils.kt
#	android/src/test/java/com/amplitude/android/internal/gestures/AutocaptureGestureListenerClickTest.kt
# Conflicts:
#	android/src/main/java/com/amplitude/android/internal/gestures/AutocaptureGestureListener.kt
#	android/src/main/java/com/amplitude/android/internal/locators/AndroidViewTargetLocator.kt
# Conflicts:
#	android/build.gradle
#	android/src/main/java/com/amplitude/android/DefaultTrackingOptions.kt
#	android/src/main/java/com/amplitude/android/internal/ViewHierarchyScanner.kt
#	android/src/main/java/com/amplitude/android/internal/ViewTarget.kt
#	android/src/main/java/com/amplitude/android/internal/gestures/AutocaptureGestureListener.kt
#	android/src/main/java/com/amplitude/android/internal/gestures/AutocaptureWindowCallback.kt
#	android/src/main/java/com/amplitude/android/internal/locators/AndroidViewTargetLocator.kt
#	android/src/main/java/com/amplitude/android/internal/locators/ComposeLayoutNodeBoundsHelper.java
#	android/src/main/java/com/amplitude/android/internal/locators/ComposeViewTargetLocator.java
#	android/src/main/java/com/amplitude/android/internal/locators/ViewTargetLocator.kt
#	android/src/main/java/com/amplitude/android/internal/locators/ViewTargetLocators.kt
#	android/src/main/java/com/amplitude/android/utilities/DefaultEventUtils.kt
#	android/src/test/java/com/amplitude/android/internal/gestures/AutocaptureGestureListenerClickTest.kt
#	android/src/test/java/com/amplitude/android/internal/gestures/AutocaptureWindowCallbackTest.kt
@PouriaAmini PouriaAmini requested a review from a team June 12, 2024 17:49
@PouriaAmini PouriaAmini self-assigned this Jun 12, 2024
Copy link
Contributor

@justin-fiedler justin-fiedler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @PouriaAmini. LGTM. See nits.

@PouriaAmini PouriaAmini merged commit 1a5a392 into amplitude:main Jun 13, 2024
4 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 8, 2024
# [1.17.0](v1.16.8...v1.17.0) (2024-08-08)

### Bug Fixes

* extract ComposeUtils to share with plugins ([#202](#202)) ([c239bba](c239bba))
* fix release pipeline ([#211](#211)) ([816599f](816599f))
* revert autocapture scroll and swipe ([#206](#206)) ([4b834bd](4b834bd))

### Features

* add autocapture for element clicks ([#199](#199)) ([7f0a500](7f0a500))
* add autocapture in configs ([#207](#207)) ([dcb9393](dcb9393))
* add screen name to elementInteractions properties for autocapture ([#209](#209)) ([8044122](8044122))
* add scroll and swipe autocapture ([#201](#201)) ([1a5a392](1a5a392))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants