我最近向网站添加了 Google Analytics GA4 标记,用于统计当前活跃用户的数量。之前,我现在可以看到实时用户数量(我认为有一分钟的延迟,但我不确定)。
但在新的GA4中,我只能看到30分钟对应的数字,这不是我需要的。
我环顾四周,找到了一个添加 1 分钟时间维度的选项,但它是针对旧的谷歌分析的,对我来说似乎不合适。
不确定是否需要为这个问题提供我的代码,但如果是必须的,那么我会添加它。
编辑:
#Run a realtime report to get desired metrics.
def run_realtime_report(property_id):
#Runs a realtime report on a Google Analytics 4 property.
client = BetaAnalyticsDataClient()
#Run the request.
request = RunRealtimeReportRequest(
property=f"properties/{property_id}",
metrics=[Metric(name="activeUsers")],
)
#Parse the response.
response = client.run_realtime_report(request)
...
return activeUsers
#Run the realtime report function.
def run_sample():
global property_id
return run_realtime_report(property_id)
Run Code Online (Sandbox Code Playgroud) ASP 核心 3.1 - API。我正在使用最新版本的 Entity Framework Core。
我创建了一个表ToDoItem和一个ToDoItemContext. 创建初始迁移并运行update-database. 我现在在我的数据库中有那个表。我现在添加了一个新模型,名为:ToDoItemDescription.
创建新迁移后尝试更新数据库时,出现错误:
表 'todoitems' 已经存在
更多细节:我有两个上下文,这是我运行的命令:
update-database -context todoitemscontext
Run Code Online (Sandbox Code Playgroud)
我也试过:
update-database -context todoitemscontext -migration AddDescription
Run Code Online (Sandbox Code Playgroud)
这是我的完整代码:
楷模:
public class TodoItem : IEntity
{
public long Id { get; set; }
public string Name { get; set; }
bool IsComplete { get; set; }
}
public class ToDoItemDescription
{
public int id { get; set; }
public string Description { get; set; } …Run Code Online (Sandbox Code Playgroud) c# entity-framework asp.net-web-api entity-framework-core asp.net-core
我正在制作 Laravel API,但我似乎无法在其中一篇文章中发送 JSON 数据。我检查了 StackOverflow 中的其他帖子,但似乎我的 JSON 请求是正确的,所以我似乎找不到错误:
这是我的控制器方法中的代码:
$validator = Validator::make($request->all(), [
"name" => "required|string",
"colors" => "json",
"sizes" => "json"
]);
if($validator->fails())
return response()->json(["errors" => $validator->errors()], 400);
Run Code Online (Sandbox Code Playgroud)
这是请求正文:
{
"name": "Test",
"colors": {
"Man": "#0000ff",
"Second": "#FF0000"
},
"sizes": {
"titles": "20px"
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
{
"errors": {
"colors": ["The colors must be a valid JSON string."],
"text_sizes": ["The text sizes must be a valid JSON string."]
}
}
Run Code Online (Sandbox Code Playgroud)
似乎有什么问题?谢谢你!