Capacitor AXA Mobile Sdk
DX AXA Mobile Sdk is a modern, well-supported, and cross-platform sdk for App Experience Analytics that provides deep insights into the performance, user experience, crash, and log analytics of apps. This plugin, helps applications using Capacitor as the Native bridge to collect and fine tune custome metrics.
Platforms Supported
- iOS
Getting started
Read about DX App Experience Analytics
Check out our documentation for more information about the features that the App Experience Analytics SDK collects from your app.
Prerequisite(For iOS only)
Run the following command to install the Ruby Gem xcodeproj to make the CAMDOReporter.h file as a public header of the AXA Capacitor plugin target in your application:
sudo gem install xcodeproj
Register Your Application
Register your application with AXA. For more information, see the Manage Apps section.
Integrate SDK
-
Download the camdo.plist file.
- Click MANAGE APPS in the DX App Experience Analytics Administration Console.
- Select the application you want to wrap and then under HYBRID , click Capacitor.
- Download the _camdo.plist file.
-
Install Plugin
npm install capacitor-axa-mobile-sdk-plugin-xcframework npx cap sync
Note: Goto ios/App folder and Run pod update 'CAMobileAppAnalytics/xcframework' to get the latest version of pod.
-
Set up your platform
iOS
-
Integrate SDK
- Go to the ios/App folder and open the workspace
- Drag and drop the downloaded xxx_camdo.plist file into the project target.
- Add the following code in the App Component class to subscribe to the Ionic router change event:
import { NavigationEnd, Router } from '@angular/router'; import { CapacitorAxaMobileSdk } from 'capacitor-axa-mobile-sdk-plugin-xcframework'; export class AppComponent { constructor(private router: Router) { this.router.events.subscribe((e) => { if (e instanceof NavigationEnd) { setTimeout(() => { CapacitorAxaMobileSdk.viewLoaded({viewName: e.urlAfterRedirects, loadTime: 0.25, screenShot: true}).then((result) => { }); }, 250); } }); } }
-
Initialising the SDK in your Source code
Swift
1. Add a header file with the file name format as `<app_name>-Bridging-header.h`. 2. Add the import header `#import "CAMDOReporter.h"` to your `<app_name>-Bridging-header.h` file. 3. Add the `<app_name>-Bridging-header.h` file to Swift Compiler - Code Generation section in the Build Settings. `<name of the project>/<app_name>-Bridging-header.h` 4. Initialize the CAMobileAppAnalytics sdk in `didFinishLaunchingWithOptions` method ```sh func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { //Initialize CA App Experience Analytics SDK CAMDOReporter.initializeSDK(options: SDKOptions.SDKLogLevelVerbose) { (completed, error) in } return true } ``` 5. Drag & Drop the downloaded `xxx_camdo.plist` file into the Supporting files
Objective C
1. Add the import header `#import "CAMDOReporter.h"` to your AppDelegate.m file 2. Initialize the CAMobileAppAnalytics sdk in `didFinishLaunchingWithOptions:` method ```sh - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [CAMDOReporter initializeSDKWithOptions:SDKLogLevelVerbose completionHandler:nil]; return YES; } ``` 3. Drag & Drop the downloaded `xxx_camdo.plist` file into the Supporting files
-
Updation
npm upgrade capacitor-axa-mobile-sdk-plugin-xcframework
npx cap sync
Note: Goto ios/App folder and Run pod update 'CAMobileAppAnalytics/xcframework' to get the latest version of pod.
Usage
import { CAMDOSDKImageQualityType, CapacitorAxaMobileSdk } from 'capacitor-axa-mobile-sdk-plugin-xcframework';
CapacitorAxaMobileSdk.addListener(CAMAA_NOTIFICATION_TYPE.CAMAA_UPLOAD_INITIATED, () => {
console.log("Upload initiated by SDK");
})
CapacitorAxaMobileSdk.getDeviceId().then(({value}) => {
console.log(value);
});
APIs
Individual APIs interact with the SDK to perform specific tasks, reading, or setting information. All APIs are asynchronous and returning information is achieved using a block.
CapacitorAxaMobileSdk.individualAPI();
CapacitorAxaMobileSdk.individualAPI({ argument1: value, argument2: value, ... });
CapacitorAxaMobileSdk.individualAPI({ argument1: value, argument2: value, ... }).then(result) => {};
enableSDK()
disableSDK()
isSDKEnabled()
getDeviceId()
getCustomerId()
setCustomerId(...)
setSessionAttribute(...)
enterPrivateZone()
exitPrivateZone()
isInPrivateZone()
getAPMHeaders()
addToAPMHeader(...)
setSSLPinningMode(...)
stopCurrentSession()
startNewSession()
stopCurrentAndStartNewSession()
startApplicationTransaction(...)
stopApplicationTransaction(...)
setCustomerFeedback(...)
setCustomerLocation(...)
sendScreenShot(...)
viewLoaded(...)
ignoreView(...)
ignoreViews(...)
isScreenshotPolicyEnabled()
logNetworkEvent(...)
logTextMetric(...)
logNumericMetric(...)
uploadEvents()
addListener(CAMAA_NOTIFICATION_TYPE.CAMAA_CRASH_OCCURRED, ...)
addListener(CAMAA_NOTIFICATION_TYPE.CAMAA_UPLOAD_INITIATED, ...)
logUIEvent(...)
setNSURLSessionDelegate(...)
setLocation(...)
enableScreenShots(...)
induceNativeCrash(...)
- Interfaces
- Enums
enableSDK()
enableSDK() => Promise<void>
Use this API to enable SDK. The SDK is enabled by default. You need to call this API only if you called disableSDK earlier.
disableSDK()
disableSDK() => Promise<void>
Use this API to disable the SDK. When disabled, the SDK no longer does any tracking of the application, or user interaction.
isSDKEnabled()
isSDKEnabled() => Promise<{ value: boolean; }>
Use this API to determine if the SDK is enabled or not.
Returns a boolean value
Returns: Promise<{ value: boolean; }>
getDeviceId()
getDeviceId() => Promise<{ value: string; }>
Use this API to get the unique device ID generated by the SDK
Returns a device id value
Returns: Promise<{ value: string; }>
getCustomerId()
getCustomerId() => Promise<{ value: string | null; }>
Use this API to get the customer ID for this session. Returns a customerId value. If the customer ID is not set, this API returns a null value.
Returns: Promise<{ value: string | null; }>
setCustomerId(...)
setCustomerId(options: { customerId: string; }) => Promise<{ error: SDKError; }>
Use this API to set the customer ID for this session.
Param | Type |
---|---|
options |
{ customerId: string; } |
Returns: Promise<{ error: SDKError; }>
setSessionAttribute(...)
setSessionAttribute(options: { name: string; value: string; }) => Promise<{ error: SDKError; }>
Use this API to set a custom session attribute.
Param | Type |
---|---|
options |
{ name: string; value: string; } |
Returns: Promise<{ error: SDKError; }>
enterPrivateZone()
enterPrivateZone() => Promise<void>
Use this API to stop collecting potentially sensitive data.
The following data is not collected when the app enters a private zone
- Screenshots
- Location information including GPS and IP addresses
- Value in the text entry fields
exitPrivateZone()
exitPrivateZone() => Promise<void>
Use this API to start collecting all data again
isInPrivateZone()
isInPrivateZone() => Promise<{ value: boolean; }>
Use this API to determine if the SDK is in a private zone.
Returns a boolean value
Returns: Promise<{ value: boolean; }>
getAPMHeaders()
getAPMHeaders() => Promise<{ value: object | null; }>
Use this API to get the SDK computed APM header in key value format. Returns dictionary or map of key, value pairs Returns an empty string if apm header cannot be computed
Returns: Promise<{ value: object | null; }>
addToAPMHeader(...)
addToAPMHeader(options: { data: string; }) => Promise<void>
Use this API to add custom data to the SDK computed APM header.
Param | Type |
---|---|
options |
{ data: string; } |
setSSLPinningMode(...)
setSSLPinningMode(options: { pinningMode: CAMDOSSLPinningMode; pinnedValues: string[]; }) => Promise<void>
Use this API to set the ssl pinning mode and array of pinned values. This method expects array of values depending on the pinningMode
Param | Type |
---|---|
options |
{ pinningMode: CAMDOSSLPinningMode; pinnedValues: string[]; } |
stopCurrentSession()
stopCurrentSession() => Promise<void>
Use this API to stop the current session. No data will be logged until the startSession API is called
startNewSession()
startNewSession() => Promise<void>
Use this API to start a new session. If a session is already in progress, it will be stopped and new session is started
stopCurrentAndStartNewSession()
stopCurrentAndStartNewSession() => Promise<void>
Convenience API to stop the current session in progress and start a new session Equivalent to calling stopCurrentSession() and startNewSession()
startApplicationTransaction(...)
startApplicationTransaction(options: { transactionName: string; serviceName?: string; }) => Promise<{ completed: boolean; error: string | null; }>
Use this API to start a transaction with a specific name
Param | Type |
---|---|
options |
{ transactionName: string; serviceName?: string; } |
Returns: Promise<{ completed: boolean; error: string | null; }>
stopApplicationTransaction(...)
stopApplicationTransaction(options: { transactionName: string; failure?: string; }) => Promise<{ completed: boolean; error: string | null; }>
Use this API to stop a transaction with a specific name and an optional failure string
Param | Type |
---|---|
options |
{ transactionName: string; failure?: string; } |
Returns: Promise<{ completed: boolean; error: string | null; }>
setCustomerFeedback(...)
setCustomerFeedback(options: { feedback: string; }) => Promise<void>
Use this API to provide feedback from the user after a crash
Param | Type |
---|---|
options |
{ feedback: string; } |
setCustomerLocation(...)
setCustomerLocation(options: { postalCode: string; countryCode: string; }) => Promise<void>
Use this API to set Location of the Customer/User using postalCode and countryCode.
Param | Type |
---|---|
options |
{ postalCode: string; countryCode: string; } |
sendScreenShot(...)
sendScreenShot(options: { name: string; quality: CAMDOSDKImageQualityType; }) => Promise<{ completed: boolean; error: string | null; }>
Use this API to send a screen shot of the current screen
Param | Type |
---|---|
options |
{ name: string; quality: CAMDOSDKImageQualityType; } |
Returns: Promise<{ completed: boolean; error: string | null; }>
viewLoaded(...)
viewLoaded(options: { viewName: string; loadTime: number; screenShot?: boolean; }) => Promise<{ completed: boolean; error: string | null; }>
Use this API to create a custom app flow with dynamic views
Param | Type |
---|---|
options |
{ viewName: string; loadTime: number; screenShot?: boolean; } |
Returns: Promise<{ completed: boolean; error: string | null; }>
ignoreView(...)
ignoreView(options: { viewName: string; }) => Promise<void>
Use this API to set the name of a view to be ignored
Param | Type |
---|---|
options |
{ viewName: string; } |
ignoreViews(...)
ignoreViews(options: { viewNames: string[]; }) => Promise<void>
Use this API to provide a list of view names to be ignored.
Param | Type |
---|---|
options |
{ viewNames: string[]; } |
isScreenshotPolicyEnabled()
isScreenshotPolicyEnabled() => Promise<{ value: boolean; }>
Use this API to determine if automatic screenshots are enabled by policy.
Returns a boolean value Returns YES if screenshots are enabled by policy. Otherwise returns NO
Returns: Promise<{ value: boolean; }>
logNetworkEvent(...)
logNetworkEvent(options: { url: string; status: number; responseTime: number; inBytes: number; outBytes: number; }) => Promise<{ completed: boolean; error: string | null; }>
Use this API to add a custom network event in the current session
Param | Type |
---|---|
options |
{ url: string; status: number; responseTime: number; inBytes: number; outBytes: number; } |
Returns: Promise<{ completed: boolean; error: string | null; }>
logTextMetric(...)
logTextMetric(options: { textMetricName: string; value: string; attributes?: object; }) => Promise<{ completed: boolean; error: string | null; }>
Use this API to add a custom text metric in the current session
Param | Type |
---|---|
options |
{ textMetricName: string; value: string; attributes?: object; } |
Returns: Promise<{ completed: boolean; error: string | null; }>
logNumericMetric(...)
logNumericMetric(options: { numericMetricName: string; value: number; attributes?: object; }) => Promise<{ completed: boolean; error: string | null; }>
Use this API to add a custom numeric metric value in the current session
Param | Type |
---|---|
options |
{ numericMetricName: string; value: number; attributes?: object; } |
Returns: Promise<{ completed: boolean; error: string | null; }>
uploadEvents()
uploadEvents() => Promise<{ response: object; error: string | null; }>
Use this API to force an upload event. This is bulk/resource consuming operation and should be used with caution
Returns: Promise<{ response: object; error: string | null; }>
addListener(CAMAA_NOTIFICATION_TYPE.CAMAA_CRASH_OCCURRED, ...)
addListener(eventName: CAMAA_NOTIFICATION_TYPE.CAMAA_CRASH_OCCURRED, listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
CAMAA_NOTIFICATION_TYPE.CAMAA_CRASH_OCCURRED |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(CAMAA_NOTIFICATION_TYPE.CAMAA_UPLOAD_INITIATED, ...)
addListener(eventName: CAMAA_NOTIFICATION_TYPE.CAMAA_UPLOAD_INITIATED, listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
CAMAA_NOTIFICATION_TYPE.CAMAA_UPLOAD_INITIATED |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
logUIEvent(...)
logUIEvent(options: { eventType: CAMDOUIEventType; value: string; }) => Promise<void>
Param | Type |
---|---|
options |
{ eventType: CAMDOUIEventType; value: string; } |
setNSURLSessionDelegate(...)
setNSURLSessionDelegate(options: { delegate: string; }) => Promise<void>
Use this API to set your delegate instance to handle auth challenges. Use it when using SDKUseNetworkProtocolSwizzling option
Param | Type |
---|---|
options |
{ delegate: string; } |
setLocation(...)
setLocation(options: { latitude: number; longitude: number; }) => Promise<void>
Use this API to set Geographic or GPS Location of the Customer
Param | Type |
---|---|
options |
{ latitude: number; longitude: number; } |
enableScreenShots(...)
enableScreenShots(captureScreen: boolean) => Promise<void>
Use this API to programmatically enable or disable automatic screen captures.
Param | Type | Description |
---|---|---|
captureScreen |
boolean |
is a boolean value to enable/disable automatic screen captures. Normally the policy determines whether automatic screen captures are performed. Use this API to override the policy, or the current setting of this flag. |
induceNativeCrash(...)
induceNativeCrash(options: { crashType: string; }) => void
This is a SDK Dev API
Param | Type |
---|---|
options |
{ crashType: string; } |
Interfaces
PluginListenerHandle
Prop | Type |
---|---|
remove |
() => Promise<void> |
Enums
SDKError
Members |
---|
ErrorNone |
ErrorNoTransactionName |
ErrorTransactionInProgress |
ErrorFailedToTakeScreenshot |
ErrorInvalidValuesPassed |
CAMDOSSLPinningMode
Members |
---|
CAMDOSSLPinningModeNone |
CAMDOSSLPinningModePublicKey |
CAMDOSSLPinningModeCertificate |
CAMDOSSLPinningModeFingerPrintSHA1Signature |
CAMDOSSLPinningModePublicKeyHash |
CAMDOSDKImageQualityType
Members | Value |
---|---|
CAMAA_SCREENSHOT_QUALITY_HIGH |
'CAMAA_SCREENSHOT_QUALITY_HIGH' |
CAMAA_SCREENSHOT_QUALITY_MEDIUM |
'CAMAA_SCREENSHOT_QUALITY_MEDIUM' |
CAMAA_SCREENSHOT_QUALITY_LOW |
'CAMAA_SCREENSHOT_QUALITY_LOW' |
CAMAA_SCREENSHOT_QUALITY_DEFAULT |
'CAMAA_SCREENSHOT_QUALITY_DEFAULT' |
CAMAA_NOTIFICATION_TYPE
Members | Value |
---|---|
CAMAA_UPLOAD_INITIATED |
'CAMAA_UPLOAD_INITIATED' |
CAMAA_CRASH_OCCURRED |
'CAMAA_CRASH_OCCURRED' |
CAMDOUIEventType
Members | Value |
---|---|
CAMAA_EVENT_BUTTON_PRESSED |
'button_pressed' |
CAMAA_AI_START |
'ai_start' |
CAMAA_AI_END |
'ai_end' |
CAMAA_EVENT_DATE_PICKER_VIEW_SELECTED |
'date_picker_selected' |
CAMAA_EVENT_PAGE_CHANGED |
'page_changed' |
CAMAA_EVENT_SEGMENTED_CONTROL_PRESSED |
'segment_control_pressed' |
CAMAA_EVENT_SLIDER_MOVED |
'slider_moved' |
CAMAA_EVENT_STEPPER_PRESSED |
'stepper_pressed' |
CAMAA_EVENT_SWITCH_PRESSED |
'switch_pressed' |
CAMAA_EVENT_RADIO_BUTTON_PRESS |
"radio_button_pressed" |
CAMAA_EVENT_CHECK_BOX_PRESS |
"check_box_pressed" |
CAMAA_EVENT_SPINNER_ITEM_SELECTED |
"spinner_item_selected" |
CAMAA_EVENT_TOGGLE_PRESS |
"switch_pressed" |
CAMAA_EVENT_UNSUPPORTED |
"unknow_action" |
iOS-only APIs
The iOS version of the SDK implements a few APIs which are not available in the Android version of the SDK.
The best way to handle these APIs is to put them in conditionals for the platform the App is running on