Hi, I use docker and for some reason this analytic...
# community-help
p
Hi, I use docker and for some reason this analytics rule is not saved whenever I restart my docker containers. Can someone point my mistake? Thanks in advance. Here are the steps to reproduce: ## docker-compose.yml
Copy code
services:
  typesense:
    image: typesense/typesense:26.0
    container_name: test-typesense
    restart: on-failure
    volumes:
      - ./typesense-data-dir:/data
    ports:
      - 8108:8108
    command: '--data-dir /data --api-key=xyz --enable-cors --cors-domains=<http://localhost:8188> --enable-search-analytics=true --analytics-dir=/data/analytics --analytics-flush-interval=60'

  typesense_dashboard:
    image: <http://ghcr.io/bfritscher/typesense-dashboard:latest|ghcr.io/bfritscher/typesense-dashboard:latest>
    container_name: test-typesense_dashboard
    restart: on-failure
    volumes:
      - ./typesense-dashboard/config.json:/srv/config.json
    ports:
      - 8188:80
## create collection
Copy code
curl "<http://localhost:8108/collections>" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: xyz" \
       -d '{
         "name": "product_variants",
         "fields": [
           {"name": "name", "type": "string" },
           {"name": "popularity", "type": "int32" }
         ],
         "default_sorting_field": "popularity"
       }'
## insert document
Copy code
curl "<http://localhost:8108/collections/product_variants/documents>" -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: xyz" \
        -d '{
          "id": "1",
          "name": "First test product",
          "popularity": 0
        }'
## create rule
Copy code
curl -k "<http://localhost:8108/analytics/rules>" \
      -X POST \
      -H "Content-Type: application/json" \
      -H "X-TYPESENSE-API-KEY: xyz" \
      -d '{
        "name": "product_variants_popularity",
        "type": "counter",
        "params": {
            "source": {
                "collections": ["product_variants"],
                "events":  [
                    {"type": "click", "weight": 1, "name": "product_variants_click_event"}
                ]
            },
            "destination": {
                "collection": "product_variants",
                "counter_field": "popularity"
            }
        }
      }'
## restart docker containers docker-compose down && docker-compose up -d ## check if rule is still present
Copy code
curl -k "<http://localhost:8108/analytics/rules>" \
    -X GET \
    -H "Content-Type: application/json" \
    -H "X-TYPESENSE-API-KEY: xyz"