删除埋点,im和客服
This commit is contained in:
@@ -204,11 +204,12 @@ class CommonService {
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//广告点击统计 广告类型 0:应用 1:广告
|
||||
static Future<bool> adsClick(int? type) async {
|
||||
/// 广告点击日志:[id] 广告 id(后端必填,空就不报);type 固定传 0(普通广告)
|
||||
static Future<bool> adsClick(String? id) async {
|
||||
if (id == null || id.isEmpty) return false;
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/ads/click/stat',
|
||||
param: {'type': type},
|
||||
'/ads/click',
|
||||
param: {'id': id, 'type': 0},
|
||||
);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:jydj/tools_base/net/http_manager.dart';
|
||||
|
||||
/// 短剧接口。金币解锁已并入 PayManager/BuyService,这里只剩读操作 + 两个计数型写操作:
|
||||
/// 信息流翻页去重、分享互动计数,都必须带 `X-Request-ID`——同一次业务的重试要复用同一个 id,
|
||||
/// 换新 id 就会重复计数。播放埋点走现有 analytics SDK(TrackVideoManager),不另建短剧专用上报
|
||||
/// 换新 id 就会重复计数。
|
||||
class DramaService {
|
||||
static Options _idempotent(String requestId) => Options(headers: {'X-Request-ID': requestId});
|
||||
|
||||
|
||||
@@ -177,12 +177,6 @@ class MineService {
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
/// 获取客服对接地址
|
||||
static Future<String?> fetchCustomService() async {
|
||||
final result = await httpManager.fetchResponseByGET('/customer/url', param: {});
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
/// 积分兑换商品
|
||||
static Future<bool> integralExchange(String id, {String? name, String? tel, String? address}) async {
|
||||
final param = <String, dynamic>{"id": id, "name": name, "tel": tel, "address": address};
|
||||
|
||||
@@ -74,7 +74,7 @@ class ResolveResponse {
|
||||
final data = json['Question'];
|
||||
if (data == null) return null;
|
||||
if (data is List) {
|
||||
return (data as List)
|
||||
return data
|
||||
.map(
|
||||
(question) => _Question.fromJson(question as Map<String, dynamic>),
|
||||
)
|
||||
|
||||
@@ -342,8 +342,8 @@ class CacheServer {
|
||||
// 是否是预缓存的请求
|
||||
bool isPreCache = false;
|
||||
Map<String, String> queryParameters = {};
|
||||
queryParameters.addAll(localReq.uri.queryParameters ?? {});
|
||||
if (queryParameters.containsKey("isPreCache") ?? false) {
|
||||
queryParameters.addAll(localReq.uri.queryParameters);
|
||||
if (queryParameters.containsKey("isPreCache")) {
|
||||
queryParameters.remove("isPreCache");
|
||||
isPreCache = true;
|
||||
}
|
||||
@@ -432,7 +432,7 @@ class CacheServer {
|
||||
if (rangeStart <= 0) {
|
||||
resp.data?.headers.forEach((key, values) {
|
||||
if (HttpHeaders.contentLengthHeader == key) {
|
||||
var ct = int.parse(values[0] ?? "0");
|
||||
var ct = int.parse(values[0]);
|
||||
localReq.response.headers.add(key, ct > 0 ? (ct - 6) : ct);
|
||||
csPrint("resp header ct:$key ${ct > 0 ? (ct - 6) : ct}");
|
||||
} else {
|
||||
@@ -515,12 +515,6 @@ class CacheServer {
|
||||
/// 处理M3u8
|
||||
_handleM3u8(Uri remoteUri, HttpRequest localReq, Stream<FileResponse> s, BaseCacheManager cacheManager) async {
|
||||
final sc = s.listen((f) {
|
||||
if (null == f) {
|
||||
//l.e(local_server_tag, "handleM3u8()...$remoteUri 来了个null���鬼东西");
|
||||
_requestErr(localReq);
|
||||
return;
|
||||
}
|
||||
|
||||
if (f is FileInfo) {
|
||||
var len = localReq.response.headers.value(HttpHeaders.contentLengthHeader);
|
||||
if (null != len) {
|
||||
@@ -540,7 +534,7 @@ class CacheServer {
|
||||
);
|
||||
// csPrint("before source:$source");
|
||||
if (TextUtil.isNotEmpty(tsLine) && tsLine.startsWith("http")) {
|
||||
var domin = Uri.parse(tsLine ?? "").origin;
|
||||
var domin = Uri.parse(tsLine).origin;
|
||||
if (TextUtil.isNotEmpty(domin)) {
|
||||
csPrint("need replace m3u8 inner host:$domin");
|
||||
source = source.replaceAll(domin, "");
|
||||
@@ -581,17 +575,15 @@ class CacheServer {
|
||||
|
||||
/// 请求错误
|
||||
_requestErr(HttpRequest req, {StreamSubscription? sc}) async {
|
||||
if (null != req) {
|
||||
// if (null == req.response.statusCode) {
|
||||
try {
|
||||
req.response.statusCode = HttpStatus.badRequest;
|
||||
} catch (e) {
|
||||
//l.e(local_server_tag, "_requestErr()..." + req.response.toString());
|
||||
}
|
||||
// }
|
||||
await req.response.close();
|
||||
sc?.cancel();
|
||||
// if (null == req.response.statusCode) {
|
||||
try {
|
||||
req.response.statusCode = HttpStatus.badRequest;
|
||||
} catch (e) {
|
||||
//l.e(local_server_tag, "_requestErr()..." + req.response.toString());
|
||||
}
|
||||
// }
|
||||
await req.response.close();
|
||||
sc?.cancel();
|
||||
}
|
||||
|
||||
BaseCacheManager _getCacheManager(String url) {
|
||||
@@ -641,7 +633,6 @@ class CacheServer {
|
||||
// l.i(local_server_tag, "getCacheFile()...闲时缓存策略预测需要缓��的url:$remoteUrl");
|
||||
var cacheManager = _getCacheManager(remotePath);
|
||||
var fileInfo = cacheManager.getFileFromMemory(getCacheKey(remotePath));
|
||||
fileInfo ??= (await cacheManager.getFileFromCache(getCacheKey(remotePath))) as Future<FileInfo?>;
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
@@ -662,8 +653,7 @@ class CacheServer {
|
||||
// return "https://fs.lhexm.com/sp/8a/67/lf/mg/605635d590d11f0679a058dbc013bd53.mp4";
|
||||
// remotePath = "sp/r1/8p/mt/if/970dd3185c924ff29c273917615c844a.m3u8";
|
||||
if (TextUtil.isEmpty(remotePath)) return null;
|
||||
var remoteUri = Uri.parse(remotePath); //修正后的绝对��径
|
||||
if (null == remoteUri) return null;
|
||||
var remoteUri = Uri.parse(remotePath);
|
||||
final dot = remoteUri.path.lastIndexOf(".");
|
||||
if (dot <= 0 || dot >= remoteUri.path.length - 1) return null;
|
||||
final fileExtension = remoteUri.path.substring(dot);
|
||||
@@ -715,8 +705,7 @@ class CacheServer {
|
||||
// 兼容相对路径 sp/vid/xxxx.m3u8
|
||||
remotePath = reqFilter.pathPrefix + "/" + remotePath;
|
||||
}
|
||||
var uri = Uri.parse(remotePath); //修正后的绝对路径
|
||||
if (null == uri) return null;
|
||||
var uri = Uri.parse(remotePath);
|
||||
//这里替换远程
|
||||
final remoteUri = uri.replace(scheme: reqFilter.schema, host: reqFilter.host, port: reqFilter.port);
|
||||
return remoteUri.toString();
|
||||
@@ -725,6 +714,5 @@ class CacheServer {
|
||||
|
||||
/// url/绝对路径和相对路径
|
||||
String getCacheKey(String url) {
|
||||
assert(null != url);
|
||||
return FileUtil.getName(url);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class LocalServerGuard {
|
||||
bool _running = false;
|
||||
bool _checking = false;
|
||||
|
||||
LocalServerGuard(this.cacheServer) : assert(cacheServer != null);
|
||||
LocalServerGuard(this.cacheServer);
|
||||
|
||||
/// 运行localserver守护
|
||||
Future run() async {
|
||||
@@ -28,14 +28,12 @@ class LocalServerGuard {
|
||||
_checking = true;
|
||||
// csPrint("local_server_gard is called");
|
||||
Uri uri = cacheServer.localServerUri;
|
||||
if (uri != null) {
|
||||
uri = uri.replace(path: LOCAL_SERVER_PING_PATH);
|
||||
var options = Options(responseType: ResponseType.bytes);
|
||||
// l.i(local_server_tag, "begin ping local server");
|
||||
final response = await _dio.getBytes(uri.toString(), options: options);
|
||||
// l.i(local_server_tag, "end ping local server");
|
||||
if ((response.data?.statusCode ?? 0) > 0) return;
|
||||
}
|
||||
uri = uri.replace(path: LOCAL_SERVER_PING_PATH);
|
||||
var options = Options(responseType: ResponseType.bytes);
|
||||
// l.i(local_server_tag, "begin ping local server");
|
||||
final response = await _dio.getBytes(uri.toString(), options: options);
|
||||
// l.i(local_server_tag, "end ping local server");
|
||||
if ((response.data?.statusCode ?? 0) > 0) return;
|
||||
await cacheServer.start();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user