event_analysis_library

Last updated:

0 purchases

event_analysis_library Image
event_analysis_library Images
Add to Cart

Description:

event analysis library

Event Analysis Package #
Getting Started #
First, add the event_analysis_library package to your pubspec dependencies.
To import PineWheel:
import 'package:event_analysis_library/event_analysis_library.dart';
copied to clipboard
Add the following permission on android manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
copied to clipboard
Add the following permission on info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>
copied to clipboard
Add the following to your Podfile file:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',

]

end
end
end
copied to clipboard
To use the package, create a singleton class:
import 'package:event_analysis_library/event_analysis_library.dart';

class AnalysisSdk {
factory AnalysisSdk() {
return _instance;
}

AnalysisSdk._internal();

static final AnalysisSdk _instance = AnalysisSdk._internal();

CreateEvent? _createEvent;
bool? result;

initializeSdk({required String locale}) async {
_createEvent = CreateEvent(productKey: 'bigmart-mobile', locale: locale);
result = await _createEvent!.initialize(askLocationPermission: true); //False if you want to handle location permission in app
return result;
}

postEvent(String eventType, String eventValue, String userId, var offset) async {
if(result!){
await _createEvent!.postEvent(eventType: eventType, eventValue: eventValue, userId: userId, position: offset);
}else{
result = await initializeSdk(locale: 'en_us');
await _createEvent!.postEvent(eventType: eventType, eventValue: eventValue, userId: userId, position: offset);
}
}

userIdentity(String userId) async {
if(result!){
await _createEvent!.userIdentity(userId);
}else{
result = await initializeSdk(locale: 'en_us');
await _createEvent!.userIdentity(userId);
}
}
}
copied to clipboard
Note: Provide the product key on initialize sdk as per required.
Initialize SDK on main and provide the current locale used
await AnalysisSdk().initializeSdk(locale: "en_US");
copied to clipboard
Call userIdentity while use logs into the app
await AnalysisSdk().userIdentity('123123');
copied to clipboard
Call postEvent on required events like button clicks.
Provide the event type. For example: button clicks, Navigation.
Also get the position of the item clicked and send the value on position field.
var offset = _getPositions(context);
await AnalysisSdk().postEvent("BUTTON CLICK", "EVENT VALUE", 'USER ID', offset);

_getPositions(BuildContext context, GlobalKey key) {
final RenderBox? renderBox = key.currentContext!.findRenderObject() as RenderBox?;
final offSet = renderBox!.localToGlobal(Offset.zero);
return offSet;
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.