Configuration
AppSpector uses modules called monitors to track different app activities and gather stats.
We provide a bunch of monitors out of the box which could be used together or in any combinations.
AppSpector SDK supports two ways of setup: config based and manual. Config based setup is supported starting version 1.5.
Setup
Manual setup
To start AppSpector you need to build instance of AppSpectorConfig
and provide your API key.
You can start exact monitors with:
let config = AppSpectorConfig(apiKey: "API_KEY", monitorIDs: [Monitor.logs, Monitor.http])
ASConfig *config = [ASConfig configWithAPIKey:@"API_KEY"
monitorIDs:[NSSet setWithObjects:
AS_LOG_MONITOR,
AS_LOCATION_MONITOR,
AS_HTTP_MONITOR, nil]
];
Or start all available with:
let config = AppSpectorConfig(apiKey: "API_KEY")
ASConfig *config = [ASConfig configWithAPIKey:@"API_KEY"];
Available monitors:
Monitor.screenshot
Monitor.sqlite
Monitor.http
Monitor.coredata
Monitor.performance
Monitor.logs
Monitor.location
Monitor.environment
Monitor.notifications
Monitor.analytics
Monitor.userdefaults
Monitor.commands
Monitor.customEvents
Monitor.fileSystem
AS_SCREENSHOT_MONITOR
AS_SQLITE_MONITOR
AS_HTTP_MONITOR
AS_COREDATA_MONITOR
AS_PERFORMANCE_MONITOR
AS_LOG_MONITOR
AS_LOCATION_MONITOR
AS_ENVIRONMENT_MONITOR
AS_NOTIFICATION_MONITOR
AS_ANALYTICS_MONITOR
AS_DEFAULTS_MONITOR
AS_COMMANDS_MONITOR
AS_CUSTOMEVENTS_MONITOR
AS_FS_MONITOR
Then import the framework:
import AppSpectorSDK
@import AppSpectorSDK;
Start selected monitors only:
let config = AppSpectorConfig(apiKey: "API_KEY", monitorIDs: [Monitor.http, Monitor.logs])
AppSpector.run(with: config)
NSSet *monitorIDs = [NSSet setWithObjects:AS_HTTP_MONITOR, AS_LOG_MONITOR, nil];
AppSpectorConfig *config = [AppSpectorConfig configWithAPIKey:@"API_KEY" monitorIDs:monitorIDs];
[AppSpector runWithConfig:config];
or start all monitors:
let config = AppSpectorConfig(apiKey: "API_KEY")
AppSpector.run(with: config)
ASConfig *config = [ASConfig configWithAPIKey:@"API_KEY"];
[AppSpector runWithConfig:config];
To start encrypted session you need to use SDK version with E2EE enabled (see SDK Installation and Configuration ) for details) and provide your app public key alongside with API key:
let config = AppSpectorConfig(apiKey: "API_KEY", publicKey: "PUB_KEY")
AppSpector.run(with: config)
AppSpectorConfig *config = [AppSpectorConfig configWithAPIKey:@"API_KEY" publicKey:@"PUB_KEY"];
[AppSpector runWithConfig:config];
Config based setup
Config based setup is preferred way to setup the SDK starting version 1.5. You should prefer it to manual unless you have reasons to use older versions of SDK. Config setup relies on a .plist file in the main bundle of your application that contains all needed info for the SDK to start.
Config file should be named AppSpector.plist
and be a valid plist file. We recommend to take one from our repository here: AppSpector.plist and then edit to add your credentials and configuration options.
There are three required keys needed to start the SDK:
Monitors
- array of monitor ids to start. Monitors not listed wont start at all but could be started later from the dashboard. For details see [Running monitors on demand]
API Key
- your application API key
Public Key
- your application public key for apps with enabled E2E encryption. See [e2ee] for details. You can omit this key for non-encrypted apps.
SDK loads config at the early phase of app lifecycle before any app code is executed. Listing only monitors you need allows to avoid unnecessary side effects and performance hit. Starting SDK v1.5 monitors can be enabled and disabled at runtime using dynamic monitors control feature: https://docs.appspector.com/update/docs/running-monitors-on-demand
Custom device name
You can assign a custom name to your device to easily find needed sessions in sessions list.
To do this you have to add desired name as a value for AS_DEVICE_NAME_KEY
key to the config.metadata
dictionary:
let config = AppSpectorConfig(apiKey: "API_KEY", monitorIDs: [Monitor.http, Monitor.logs])
config.metadata = [ DeviceNameKey : "Your device name" ]
AppSpectorConfig *config = [AppSpectorConfig configWithAPIKey:@"API_KEY" monitorIDs:monitorIDs];
config.metadata = @{ AS_DEVICE_NAME_KEY : @"Your device name" };
Start/Stop SDK
AppSpector start is two step process.
When you link with AppSpector framework it starts to collect data immediately after load. When you call startWithConfig
method - AppSpector opens a connection to the backend and from that point you can see your session on the frontend.
You can manually control AppSpector state by calling start
and stop
methods.
stop
tells AppSpector to disable all data collection and close current session.
start
starts it again using config you provided at load. This will be a new session, all activity between stop
and start
calls will not be tracked. To check current SDK state you can use + (BOOL)isRunning
method.
AppSpector.stop()
AppSpector.start()
[AppSpector stop];
[AppSpector start];
Updated 2 days ago