【问题标题】:Where to store data about user activities?在哪里存储有关用户活动的数据?
【发布时间】:2021-05-03 04:57:04
【问题描述】:

我们有一个市场,我们将用户搜索查询和请求日志存储到 API,以便我们以后可以使用这些数据深入了解客户行为。我们有一个重要的端点api/products,我们正在存储这个端点的所有请求有效负载。通过这个,我们可以知道正在搜索哪些条形码、品牌、供应商、搜索查询等。简而言之,这就像后端分析。

我正在为此使用 MySQL,但我不知道这是否是一个好方法,或者是否有其他开箱即用的解决方案。

以下类包含调用api/products 端点时请求可能具有的过滤器、查询等,我将其存储为JSON 类型在MySql 中。

注意:我们使用NodeJs 作为后端。

class GetProductsDto extends OffsetLimitDto {
  @IsOptional()
  @IsString()
  @Trim()
  @MaxLength(36)
  outsourceId: string;

  @IsOptional()
  @IsString()
  @Trim()
  @MaxLength(48)
  barcode: string;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @IsPositive()
  productCategoryId: number;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @IsPositive()
  supplierStoreId: number;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @IsPositive()
  manufacturerCompanyId: number;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @IsPositive()
  manufacturerCountryId: number;

  @IsOptional()
  @Expose({ name: 'quantity.gt', toPlainOnly: true })
  @Type(() => Number)
  @IsInt()
  quantityGreaterThan: number;

  @IsOptional()
  @Expose({ name: 'quantity.lt', toPlainOnly: true })
  @Type(() => Number)
  @IsInt()
  quantityLessThan: number;

  @IsOptional()
  @IsString()
  @TrimAndRemoveConsecutiveSpaces()
  @MaxLength(1000)
  q: string;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @IsPositive()
  operationCityId: number;

  @IsOptional()
  @IsArray()
  @ToDistinctArrayValues()
  @ArrayMaxSize(Object.values(ProductIncludeFilter).length)
  @IsEnum(ProductIncludeFilter, {
    each: true,
    message: `Array values should be one of [${Object.values(
      ProductIncludeFilter,
    )}]`,
  })
  include: ProductIncludeFilter[];
}

【问题讨论】:

    标签: mysql node.js database analytics user-data


    【解决方案1】:

    最好使用 ElasticSearch 和 elkStack 等工具来实现此目的。你有能力存储大量日志数据,索引和查询,并使用 kibana 和 grafana 制作丰富类型的报告

    检查此链接

    elk-stack

    Running Elastic Stack on Docker

    【讨论】:

      猜你喜欢
      • 2019-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-06
      • 1970-01-01
      • 2018-09-14
      相关资源
      最近更新 更多