Erste Schritte für die Datenerfassung mit Android

Available for the following Plan types:

Fullstory Enterprise*

Fullstory Advanced*

Fullstory Business*

Fullstory Free

*with the following add-on:

Fullstory for Mobile Apps

Available to the following User roles:

Admin

Architekt:in

Standard

 

Für moderne Android-Apps

In der Architektur moderner Android-Anwendungen gibt es normalerweise zwei build.gradle-Dateien, die geändert werden müssen, wenn Gradle-Plug-ins hinzugefügt werden. Diese Dateien sind:

  • Das Root-Projekt build.gradle (standardmäßig im Root-Ordner) und
  • Die App/das Modul build.gradle (standardmäßig im Ordner app/).

The Root build.gradle declares script plugin locations and classpaths. You’ll modify this file to point to the Fullstory repository and add the Fullstory plugin’s classpath (similar to how the Android Gradle plugin is declared).

Im App-spezifischen build.gradle wendest du das Plug-in an und deklarierst dann einen fullstory-Skriptblock, um einige zusätzliche Eigenschaften zu konfigurieren. Dies funktioniert analog zum Einsatz des Anwendungs-Plug-ins für Android und der Nutzung des android-Konfigurationsblocks für die Deklaration von Eigenschaften.

As you’re implementing the instructions below, you may find it useful to reference a sample app with a completed Fullstory installation. If you would like a sample modern app to review, please contact Fullstory Support and reference this document.

For legacy Android apps

Legacy Android apps that have been migrated from Eclipse to Android Studio have a single monolithic build.gradle file, rather than distinct Root and App build.gradle files. As such, the Fullstory installation process is identical to the process for modern apps, except that all modifications take place in the single build.gradle file. If you would like a sample legacy app to review, please contact Fullstory Support and reference this document.

 

Setup

1. In the Root Project build.gradle, add the Fullstory plugin

Paste the highlighted lines into the buildscript section, ensure that you replace <PLUGIN VERSION> with the latest version of the Fullstory Android plugin. You can find the latest release notes here (this is currently 1.49.0).

buildscript {
  repositories {
... maven { url "https://maven.fullstory.com" } } dependencies { ... classpath 'com.fullstory:gradle-plugin-local:<PLUGIN VERSION>'
}
}

 

If your project is configured to prefer settings repositories or you receive the following error:

Build was configured to prefer settings repositories but repository 'MavenLocal' was added by plugin 'fullstory'

 

Do not add the above code (or remove if already added) to your root build.gradle and instead use the configuration shown below in your settings.gradle:

import org.gradle.api.initialization.resolve.RepositoriesMode

pluginManagement { repositories {
... gradlePluginPortal()
google()
mavenCentral() }
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) repositories {
...
gradlePluginPortal()
google()
mavenCentral()
maven { url "https://maven.fullstory.com" }
}
}
rootProject.name = "My Application"
include ':app'


2. In the App/Module build.gradle, apply the Fullstory plugin

Füge die hervorgehobenen Zeilen ein:

Wenn deine Gradle-Datei Plug-ins über die Plug-in-ID hinzufügt:

plugins {
id 'com.android.application' id 'fullstory'
}

fullstory {
org "<ORG ID>"
<PLUGIN PROPERTIES>
}
android { ...

Wenn deine Gradle-Datei Plug-ins anwendet:

apply plugin: 'com.android.application'
apply plugin: 'fullstory'

fullstory {
org "<ORG ID>"

<PLUGIN PROPERTIES>
}

android {
...

 

3. Add the Plugin Properties

Ersetze <PLUGIN PROPERTIES> durch die folgenden verfügbaren Eigenschaften:

Eigenschaft Optionen Beschreibung
org

Erforderlich

Deine Organisations-ID
orgs

Default: empty

Your Org ID specified per variant
enabledVariants

Default: release

Optionen: variiert

Gib an, welche Build-Varianten angewandt werden sollen
logcatLevel

Default: off

Optionen: off, error, warn, info, debug, log

Erfasse Logcat-Meldungen auf oder über der angegebenen Ebene
logLevel

Default: info

Optionen: off, error, warn, info, debug, log

Erfasse FS.log()-Meldungen auf oder über der angegebenen Ebene
recordOnStart (optional)

Default: true

Optionen: true, false

Prevent Fullstory from starting data capture on App Startup
addDependencies (optional)

Default: true

Optionen: true, false

Prevent Fullstory Gradle Plugin from Auto-adding Gradle Dependencies
serverUrl (optional)

Default: https://fullstory.com

Optionen: variiert

Specify the server url to route Fullstory traffic through
previewModeEnabled (optional)

Default: false

Optionen: true, false

Capture sessions in preview mode

 

Setting Org ID

Add your Org ID, which can be obtained by logging into Fullstory. Navigate to Settings > Data Capture and Privacy > Fullstory Setup, where you should see a line that looks like the following:window['_fs_org'] = 'XXXXX';. This string is your Org ID. For additional help finding your Org ID, check out this article.

Additionally, when you login to your Fullstory account, your Org ID can be found in the URL of your browser.

https://app.fullstory.com/ui/<ORG_ID>/home

Setting an Org ID per Variant

If your build requires an Org ID to be set per variant (flavor + build type), you can use the orgs property. The variant value is a regex that performs a caseless comparison to match the variant.

Note that an entry that matches a variant will take precedence over the general org property.

You can set value by specifying an array:

 orgs ['variant0': 'org0', 'variant1': 'org1']

You can also put an entry individually:

 putOrg('variant0', 'org0')

Gib an, welche Build-Varianten angewandt werden sollen

By default, Fullstory is only applied to the release variant of your app. If your build variant contains the word “release”, we will add our instrumentation code to the APK after it is built.

To apply Fullstory to all variants, including those used at debug time, add the following line below the org line:

enabledVariants 'all'

If you want Fullstory to be applied to specific variants, you can also use a regular expression like so:

enabledVariants 'debug|release'

The variant name is constructed from the product flavor and build type (see example here). The Fullstory build plugin will match the variant name case-insensitively.

Erfassung von LogCat- und FS.log()-Meldungen

By default, Fullstory will not capture logcat messages. Logcat messages, however, can capture frustration signals, such as error clicks. To change this behavior and capture frustration signals, update your logcatLevel flag.

logcatLevel 'error'

By default, Fullstory will capture any Log statements sent via FS.log() API above and at 'info' level in your application. To change this behavior, update your logLevel flag.

logLevel 'error'

Any message sent below the specified level will not be sent to Fullstory. For example, if 'info' level is specified, 'debug' and 'log' messages will not be sent. Available options:

  • 'off' – kein Logging
  • 'error' – Fehler
  • 'warn' – Warnung
  • 'info' – Info
  • 'debug' – Debuggen
  • 'log' - verbose

Prevent Fullstory from starting data capture on App Startup

By default, Fullstory will start data capture on app startup. If you want to only start data capture once certain conditions are met, you can set recordOnStart flag to false, which will prevent data capture until FS.restart() API is explicitly invoked.

recordOnStart false

Prevent Fullstory Gradle Plugin from Auto-adding Gradle Dependencies

By default, Fullstory Gradle Plugin will automatically add the correct AAR files to the project. If you do not want the Plugin to do this, you can set addDependencies flag to false.

addDependencies false

When this is passed in, the Fullstory Plugin will output information to assist you in manually configuring the necessary pieces. For example, building with 1.49.0 will output:

FullStory: skipping auto-adding dependencies
FullStory: you must add `maven { url "https://maven.fullstory.com" }` manually to your root project's `allprojects.repositories`
FullStory: you must add `implementation 'com.fullstory:instrumentation-full:1.49.0@aar'` manually to your application project's `dependencies`

If you are using a Fullstory release prior to 1.23.0, you will need to pass in -PfsAddGradleDependency=falsein the command line or set it as a project property in gradle.properties as fsAddGradleDependency=false

 

4. Subclass from Application

Fullstory requires that you enable MultiDex. If your minSdkVersion is set to 21 or higher, Multidex is enabled by default. Subclass from application class android.app.Application.

Wenn deine minSdkVersion niedriger als 21 ist, musst du stattdessen eine Unterklasse von androidx.multidex.MultiDexApplication erzeugen.

Java:

Wenn du keine Anwendungsklasse hast, erstelle eine und füge Folgendes in App.java hinzu:

import android.app.Application;
public class App extends Application {
...
}

Füge in deinem AndroidManifest.xmlunter dem Tag <application> auf folgende Weise android:name="App" hinzu:

<application
android:name="App"
...

Kotlin:

Wenn du keine Anwendungsklasse hast, erstelle eine und füge Folgendes in App.kt hinzu:

import android.app.Application
class App: Application() {
...
}

Füge in deinem AndroidManifest.xmlunter dem Tag <application> auf folgende Weise android:name="App" hinzu:

<application
android:name="App"
...

 

5. Declare App Permissions

Füge deinem AndroidManifest.xmldie folgenden Berechtigungen hinzu, falls du dies noch nicht getan hast:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

 

Using Fullstory in library modules

The Fullstory Android plugin supports libraries inside of multi-module applications, but does not support being applied to a stand-alone library. If you want to reference Fullstory APIs from a library module within a multi-module app, set the repository and dependency as follows:

apply plugin: 'com.android.library'
repositories {
maven { url "https://maven.fullstory.com" }
...
}
dependencies {
implementation 'com.fullstory:instrumentation-full:<PLUGIN VERSION>@aar'
...
}

If using Jetpack Compose, also add this to your dependencies:

implementation 'com.fullstory:compose'

Using Fullstory's Advanced Features

Identifying users and passing custom data to Fullstory

The FS.identify and FS.setUserVars enables you to enrich your Fullstory data with additional variables for use in searches, segments, and integrations. This functionality allows you to pass user information to Fullstory directly from your mobile app. The parameters are: FS.identify takes a String and an optional Map<String, Object>, while FS.setUserVars takes a Map<String, Object>.

 

Fullstory Initialization Callback

You can implement FSOnReadyListener and override onReady to get notified of session data when Fullstory is fully initialized and ready to be used.

Java:

public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
FS.setReadyListener(new FSSessionReadyListener());
}

private static class FSSessionReadyListener implements FSOnReadyListener {
@Override
public void onReady(FSSessionData sessionData) {
String sessionUrl = sessionData.getCurrentSessionURL();
Log.d("FullStory", "Session URL is: " + sessionUrl);
}
}
}

Kotlin:

class App : Application() {
override fun onCreate() {
super.onCreate()
FS.setReadyListener(FSSessionReadyListener())
}

private class FSSessionReadyListener : FSOnReadyListener {
override fun onReady(sessionData: FSSessionData) {
Log.d("FullStory", "Session URL is: ${sessionData.currentSessionURL}")
}
}
}

 

Datenschutzbestimmungen von FullStory für mobile Apps

For more information about configuring privacy rules and masking, please consult our Fullstory for Mobile Apps Privacy Rules guide.

 

Ein- oder Ausschalten der mobilen Datenerfassung

Mobile data capture can be toggled on or off from Settings > Data Capture and Privacy > Mobile Data Capture. This applies across your entire Fullstory account.

 

Konfigurieren des Domain-Allowlisting für WebViews

If your application makes use of WebViews, you must explicitly allowlist any domain you wish to capture within a WebView. For security and privacy reasons, you should only allowlist domains which are under your control. Wildcards and subdomains are supported using the same scheme as Web domain settings. If your application doesn’t use WebViews or you don’t care to capture within WebViews, you can safely ignore this section.

Diese Einstellungen können unter Einstellungen > Datenerfassung und Datenschutz > Mobile Datenerfassung konfiguriert werden.

Note:  Fullstory SDK can capture contents of WKWebView (iOS) /WebView (Android) but not SFSafariViewController (iOS) /Chrome Custom Tabs (Android). Fullstory for Web may be used to capture contents of SFSafariViewController/Chrome Custom Tabs, but they will be displayed as separate sessions

 

Fullstory API

For information on usage, visit our developer docs.


War dieser Beitrag hilfreich?

Got Questions?

Get in touch with a Fullstory rep, ask the community or check out our developer documentation.