identify static method
Implementation
static void identify(String userID, AttributeBuilder properties, OtherBuilder otherid) async {
GenricModel genricModel = GenricModel();
genricModel.name = userID;
genricModel.properties = properties.properties;
genricModel.otherid = otherid.otherid;
GenricModel? fMain = await genricModel;
String? deviceId;
String? deviceType;
String? deviceManufacture;
String? deviceModel;
String? versionName;
String? appName;
String? appVersion;
String? appBuild;
String? googleAdvertisingID;
dynamic? googleAdvertisingBool;
String? networkIP;
String? appScreenHeightWidth;
String? appScreenHeightHeight;
String? appDataReceivedAt;
String? appDataSenddAt;
String? appOriginalTimetemp;
String? appTimestemp;
String? appServerTs;
String? appMsgId;
try {
deviceId = await _getDeviceId;
deviceType = await _getPlatFormDeviceType;
deviceModel = await _getDeviceModel;
deviceManufacture = await _getManufactureModel;
versionName = await _getOSVersion;
appName = await _getAppName;
appVersion = await _getAppVersion;
appBuild = await _getBuildNumber;
googleAdvertisingID = await _getGoogleadvertisingID;
googleAdvertisingBool = await _getGoogleadvertisingIDBoolValue;
networkIP = await _getNetworkIP;
appScreenHeightHeight = await _getScreenHeight;
appScreenHeightWidth = await _getScreenWidth;
appDataReceivedAt = await _getReceivedAt;
appDataSenddAt = await _getSendAt;
appOriginalTimetemp = await _getOriginalTimestemp;
appTimestemp = await _getTimestemp;
appServerTs = await _getServerTs;
appMsgId = await _getMessageId;
} on PlatformException {
deviceId = 'Failed to get information.';
}
Map<dynamic, dynamic> lib = {
"library": {
"name": "Flutter SDK",
"version": sdkVersion,
},
"server_ts": appServerTs,
"app": {
"name": appName,
"version": appVersion,
"build": appBuild,
},
"device": {
"id": deviceId,
"advertisingId": googleAdvertisingID,
"adTrackingEnabled": googleAdvertisingBool,
"manufacturer": deviceManufacture,
"model": deviceModel,
"type": deviceType,
"token": LemniskFirebase.FCM_URL,
},
"screen": {
"width": appScreenHeightWidth,
"height": appScreenHeightHeight,
"density": 2,
},
"userAgent": {
"osType": deviceType,
"osVersion": versionName,
},
"ip": networkIP
};
Map map = {
"id": deviceId,
"userId": "userId",
"otherIds": fMain.otherid,
"event": userID,
"messageId": appMsgId,
"customerProperties": fMain.properties,
"receivedAt": appDataReceivedAt,
"sentAt": appDataSenddAt,
"timestamp": appTimestemp,
"type": "identify",
"originalTimestamp": appOriginalTimetemp,
"writeKey": _writeKey,
};
map.addAll({"context": lib});
//After the full payload is created..now we send all to lemnisk server
print('identify event' + _serverUrl!);
Uri uri = Uri.parse(_serverUrl!);
var response = await http.post(uri, body: JsonEncoder().convert(map));
if (response.statusCode == 200) {
final String responseString = response.body;
print('event identify success ===== $responseString');
} else {
final String responseString = response.body;
print('event identify failed ===== $responseString');
}
if (_enableAppsFlyer == true) {
try {
_appsflyerSdk?.setCustomerUserId(userID);
print('AppsFlyer userId set as $userID');
// _appsflyerSdk?.setUserEmails(emails)
} on Exception catch (e) {
print("Result logEvent appsflyer Error: ${e.toString()}");
}
}
//clevertap analytics
if (_enableClevertap == true) {
try {
Map<String, dynamic> ctMap = new Map.from(properties.properties);
ctMap.putIfAbsent("Identity", () => userID);
if(otherid.otherid["email"] != null) {
ctMap.putIfAbsent("Email", () => otherid.otherid["email"]);
otherid.otherid.remove("email");
}
if(otherid.otherid["mobile"] != null) {
ctMap.putIfAbsent("Phone", () => otherid.otherid["mobile"]);
otherid.otherid.remove("mobile");
}
if(otherid.otherid["phone"] != null) {
ctMap.putIfAbsent("Phone", () => otherid.otherid["phone"]);
otherid.otherid.remove("phone");
}
ctMap.addAll(otherid.otherid);
CleverTapPlugin.profileSet(ctMap);
if(properties.properties["lat"] != null && properties.properties["lat"] is double
&& properties.properties["long"] != null && properties.properties["long"] is double) {
double latitude = double.parse((properties.properties["lat"] as double).toStringAsFixed(2));
double longitude = double.parse((properties.properties["long"] as double).toStringAsFixed(2));
CleverTapPlugin.setLocation(latitude, longitude);
}
} on Exception catch (e) {
print("recordEvent CleverTap Error: ${e.toString()}");
}
}
if (_enableFirebase == true) {
//firebase analytics
analytics?.setUserId(id: userID);
print("setUserId firebase");
}
}