CA App Experience Analytic native SDK's capacitor supplement for using custom metrics
npm install capacitor-axa-mobile-sdk-plugin-xcframeworkDX 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.
- iOS
- Android
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.
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:
``bash `
sudo gem install xcodeproj
Register your application with AXA. For more information, see the Manage Apps section.
- Download the camdo.plist file.
1. Click MANAGE APPS in the DX App Experience Analytics Administration Console.
2. Select the application you want to wrap and then under HYBRID , click Capacitor.
3. Download the
- Install Plugin
`bash`
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
1. Go to the ios/App folder and open the workspace
2. Drag and drop the downloaded xxx_camdo.plist file into the project target.
3. Add the following code in the App Component class to subscribe to the Ionic router change event:
`bash`
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
-Bridging-header.h .#import "CAMDOReporter.h"
2. Add the import headerto your-Bridging-header.h file.
3. Add the-Bridging-header.h file to Swift Compiler - Code Generation section in the Build Settings.
/ -Bridging-header.h didFinishLaunchingWithOptions
4. Initialize the CAMobileAppAnalytics sdk inmethod`
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
}
xxx_camdo.plist
5. Drag & Drop the downloadedfile into the Supporting files
Objective C
1. Add the import header #import "CAMDOReporter.h"
to your AppDelegate.m filedidFinishLaunchingWithOptions:
2. Initialize the CAMobileAppAnalytics sdk inmethod`
sh`
- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions
{
[CAMDOReporter initializeSDKWithOptions:SDKLogLevelVerbose completionHandler:nil];
return YES;
}
xxx_camdo.plist
3. Drag & Drop the downloadedfile into the Supporting files
Android
1. Go to the android folder and add packages.broadcom.com as a repository in the project build.gradle file
`
bash
buildscript {
repositories {
google()
..
..
maven {
url 'https://packages.broadcom.com/apm-agents'
}
}
dependencies {
..
..
classpath 'com.ca.dxapm:sdk-gradle-plugin:2022.6.0.0'
}
}allprojects {
repositories {
google()
..
..
maven {
url 'https://packages.broadcom.com/apm-agents'
}
}
}
`2. Go to the android/app folder and add the following to the app's build.gradle file:
`
bash`
apply plugin: 'com.ca.dxapm.sdk.gradle.plugin'
cadxapmsdk {
plist = "path to camdo.plist"
}
`bash`
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.
`typescript
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.
`typescript`
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
`typescript`
enableSDK() => Promise
Use this API to enable SDK.
The SDK is enabled by default. You need to call this API
only if you called disableSDK earlier.
--------------------
`typescript`
disableSDK() => Promise
Use this API to disable the SDK.
When disabled, the SDK no longer does any tracking of the application,
or user interaction.
--------------------
`typescript`
isSDKEnabled() => Promise<{ value: boolean; }>
Use this API to determine if the SDK is enabled or not.
Returns a boolean value
Returns: Promise<{ value: boolean; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
enterPrivateZone() => Promise
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
--------------------
`typescript`
exitPrivateZone() => Promise
Use this API to start collecting all data again
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
addToAPMHeader(options: { data: string; }) => Promise
Use this API to add custom data to the SDK computed APM header.
| Param | Type |
| ------------- | ------------------------------ |
| options | { data: string; } |
--------------------
`typescript`
setSSLPinningMode(options: { pinningMode: CAMDOSSLPinningMode; pinnedValues: string[]; }) => Promise
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[]; } |
--------------------
`typescript`
stopCurrentSession() => Promise
Use this API to stop the current session.
No data will be logged until the startSession API is called
--------------------
`typescript`
startNewSession() => Promise
Use this API to start a new session.
If a session is already in progress, it will be stopped and new session is started
--------------------
`typescript`
stopCurrentAndStartNewSession() => Promise
Convenience API to stop the current session in progress and start a new session
Equivalent to calling stopCurrentSession() and startNewSession()
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
setCustomerFeedback(options: { feedback: string; }) => Promise
Use this API to provide feedback from the user after a crash
| Param | Type |
| ------------- | ---------------------------------- |
| options | { feedback: string; } |
--------------------
`typescript`
setCustomerLocation(options: { postalCode: string; countryCode: string; }) => Promise
Use this API to set Location of the Customer/User
using postalCode and countryCode.
| Param | Type |
| ------------- | --------------------------------------------------------- |
| options | { postalCode: string; countryCode: string; } |
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
ignoreView(options: { viewName: string; }) => Promise
Use this API to set the name of a view to be ignored
| Param | Type |
| ------------- | ---------------------------------- |
| options | { viewName: string; } |
--------------------
`typescript`
ignoreViews(options: { viewNames: string[]; }) => Promise
Use this API to provide a list of view names to be ignored.
| Param | Type |
| ------------- | ------------------------------------- |
| options | { viewNames: string[]; } |
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
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; }>
--------------------
`typescript`
addListener(eventName: CAMAA_NOTIFICATION_TYPE.CAMAA_CRASH_OCCURRED, listenerFunc: () => void) => Promise
| Param | Type |
| ------------------ | ------------------------------------------------------------------------------------------------ |
| eventName | CAMAA_NOTIFICATION_TYPE.CAMAA_CRASH_OCCURRED |
| listenerFunc | () => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
`typescript`
addListener(eventName: CAMAA_NOTIFICATION_TYPE.CAMAA_UPLOAD_INITIATED, listenerFunc: () => void) => Promise
| Param | Type |
| ------------------ | -------------------------------------------------------------------------------------------------- |
| eventName | CAMAA_NOTIFICATION_TYPE.CAMAA_UPLOAD_INITIATED |
| listenerFunc | () => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
`typescript`
logUIEvent(options: { eventType: CAMDOUIEventType; value: string; }) => Promise
| Param | Type |
| ------------- | -------------------------------------------------------------------------------------------- |
| options | { eventType: CAMDOUIEventType; value: string; } |
--------------------
`typescript`
setNSURLSessionDelegate(options: { delegate: string; }) => Promise
Use this API to set your delegate instance to handle auth challenges.
Use it when using SDKUseNetworkProtocolSwizzling option
| Param | Type |
| ------------- | ---------------------------------- |
| options | { delegate: string; } |
--------------------
`typescript`
setLocation(options: { latitude: number; longitude: number; }) => Promise
Use this API to set Geographic or GPS Location of the Customer
| Param | Type |
| ------------- | ----------------------------------------------------- |
| options | { latitude: number; longitude: number; } |
--------------------
`typescript`
enableScreenShots(captureScreen: boolean) => Promise
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. |
--------------------
`typescript`
induceNativeCrash(options: { crashType: string; }) => void
This is a SDK Dev API
| Param | Type |
| ------------- | ----------------------------------- |
| options | { crashType: string; } |
--------------------
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
#### 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" |
The best way to handle these APIs is to put them in conditionals for the platform the App is running on
* addListener(CAMAA_NOTIFICATION_TYPE.CAMAA_CRASH_OCCURRED, ...)
* addListener(CAMAA_NOTIFICATION_TYPE.CAMAA_UPLOAD_INITIATED, ...)
* logUIEvent(...)
* setNSURLSessionDelegate(...)
* setLocation(...)
* enableScreenShots(...)`