From 9e8f06872451d8cb42477330f954bb2706ccce1f Mon Sep 17 00:00:00 2001 From: Tom Bocklisch Date: Thu, 24 Aug 2023 10:18:46 +0200 Subject: [PATCH 1/6] only submit telemetry data if there is a license --- changelog/1493.improvement.md | 1 + rasa/telemetry.py | 5 +++++ tests/test_telemetry.py | 22 ++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 changelog/1493.improvement.md diff --git a/changelog/1493.improvement.md b/changelog/1493.improvement.md new file mode 100644 index 000000000000..f2b43d85714f --- /dev/null +++ b/changelog/1493.improvement.md @@ -0,0 +1 @@ +Telemetry data is only send for licensed users. diff --git a/rasa/telemetry.py b/rasa/telemetry.py index 700f483522fd..0a3b35c934ca 100644 --- a/rasa/telemetry.py +++ b/rasa/telemetry.py @@ -402,6 +402,11 @@ def _send_event( logger.debug("Skipping request to external service: telemetry key not set.") return + if not "license_hash" in context: + # only send telemetry data for customers + logger.debug("Skipping telemetry reporting: no license hash found.") + return + headers = segment_request_header(write_key) resp = requests.post( diff --git a/tests/test_telemetry.py b/tests/test_telemetry.py index 0c0447ae5a33..c189345bdbcf 100644 --- a/tests/test_telemetry.py +++ b/tests/test_telemetry.py @@ -251,7 +251,9 @@ def test_segment_gets_called(monkeypatch: MonkeyPatch): with responses.RequestsMock() as rsps: rsps.add(responses.POST, "https://api.segment.io/v1/track", json={}) - telemetry._track("test event", {"foo": "bar"}, {"foobar": "baz"}) + telemetry._track( + "test event", {"foo": "bar"}, {"foobar": "baz", "license_hash": "foobar"} + ) assert len(rsps.calls) == 1 r = rsps.calls[0] @@ -274,11 +276,27 @@ def test_segment_does_not_raise_exception_on_failure(monkeypatch: MonkeyPatch): rsps.add(responses.POST, "https://api.segment.io/v1/track", body="", status=505) # this call should complete without throwing an exception - telemetry._track("test event", {"foo": "bar"}, {"foobar": "baz"}) + telemetry._track( + "test event", {"foo": "bar"}, {"foobar": "baz", "license_hash": "foobar"} + ) assert rsps.assert_call_count("https://api.segment.io/v1/track", 1) +def test_segment_does_not_get_called_without_license(monkeypatch: MonkeyPatch): + monkeypatch.setenv("RASA_TELEMETRY_ENABLED", "true") + monkeypatch.setenv("RASA_TELEMETRY_WRITE_KEY", "foobar") + telemetry.initialize_telemetry() + + with responses.RequestsMock(assert_all_requests_are_fired=False) as rsps: + rsps.add(responses.POST, "https://api.segment.io/v1/track", body="", status=505) + + # this call should complete without throwing an exception + telemetry._track("test event", {"foo": "bar"}, {"foobar": "baz"}) + + assert rsps.assert_call_count("https://api.segment.io/v1/track", 0) + + def test_environment_write_key_overwrites_key_file(monkeypatch: MonkeyPatch): monkeypatch.setenv("RASA_TELEMETRY_WRITE_KEY", "foobar") assert telemetry.telemetry_write_key() == "foobar" From 4b442746caf7c557d89341fad2ac84bf990e4aff Mon Sep 17 00:00:00 2001 From: John Trammell <22057+trammell@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:23:04 -0500 Subject: [PATCH 2/6] remove requirements_file from CICD documentation [rasa-train-test-gha](https://github.com/RasaHQ/rasa-train-test-gha) does not have a `requirements_file` parameter. --- docs/docs/setting-up-ci-cd.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/docs/setting-up-ci-cd.mdx b/docs/docs/setting-up-ci-cd.mdx index 95b644779245..420994870272 100644 --- a/docs/docs/setting-up-ci-cd.mdx +++ b/docs/docs/setting-up-ci-cd.mdx @@ -68,7 +68,6 @@ jobs: - name: Rasa Train and Test GitHub Action uses: RasaHQ/rasa-train-test-gha@main with: - requirements_file: requirements.txt data_validate: true rasa_train: true cross_validation: true From 9715708b1fe77c38163216487407590f15ed3f7c Mon Sep 17 00:00:00 2001 From: Tawakalt Date: Mon, 4 Sep 2023 14:32:42 +0200 Subject: [PATCH 3/6] add a default value of None to domain_responses --- rasa/core/nlg/callback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/core/nlg/callback.py b/rasa/core/nlg/callback.py index a8d0e681e055..d997f6ace092 100644 --- a/rasa/core/nlg/callback.py +++ b/rasa/core/nlg/callback.py @@ -73,7 +73,7 @@ async def generate( **kwargs: Any, ) -> Dict[Text, Any]: """Retrieve a named response from the domain using an endpoint.""" - domain_responses = kwargs.pop("domain_responses") + domain_responses = kwargs.pop("domain_responses", None) response_id = self.fetch_response_id( utter_action, tracker, output_channel, domain_responses ) From f2766695f4b4039688919c1e98d3f6c074584dbb Mon Sep 17 00:00:00 2001 From: Tawakalt Date: Mon, 4 Sep 2023 16:45:20 +0200 Subject: [PATCH 4/6] add changelog entry --- changelog/12790.bugfix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/12790.bugfix.md diff --git a/changelog/12790.bugfix.md b/changelog/12790.bugfix.md new file mode 100644 index 000000000000..4715d8ac618a --- /dev/null +++ b/changelog/12790.bugfix.md @@ -0,0 +1 @@ +Fixed `KeyError` which resulted when `domain_responses` doesn't exist as a keyword argument while using a custom action dispatcher with nlg server. \ No newline at end of file From a4a2aa78f4afb7528dd24057d6c864c9a5ee0543 Mon Sep 17 00:00:00 2001 From: m-vdb Date: Mon, 18 Sep 2023 14:34:11 +0200 Subject: [PATCH 5/6] fix lint --- rasa/telemetry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/telemetry.py b/rasa/telemetry.py index 0a3b35c934ca..eaaf2b711fde 100644 --- a/rasa/telemetry.py +++ b/rasa/telemetry.py @@ -402,7 +402,7 @@ def _send_event( logger.debug("Skipping request to external service: telemetry key not set.") return - if not "license_hash" in context: + if "license_hash" not in context: # only send telemetry data for customers logger.debug("Skipping telemetry reporting: no license hash found.") return From b837a3b79bea6855cec44e265734faaa12fd4fbd Mon Sep 17 00:00:00 2001 From: Radovan Zivkovic Date: Tue, 12 Sep 2023 15:00:59 +0200 Subject: [PATCH 6/6] Set IMAGE_TAG when tagging the image for GA version --- .github/workflows/continous-integration.yml | 12 ++++++------ 3.7.0b1/main_plain/.config/rasa/global.yml | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 3.7.0b1/main_plain/.config/rasa/global.yml diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml index 13fc9bd19b27..8813c17b9006 100644 --- a/.github/workflows/continous-integration.yml +++ b/.github/workflows/continous-integration.yml @@ -906,7 +906,7 @@ jobs: # Base MITIE image BASE_MITIE_IMAGE_HASH=${{ hashFiles('docker/Dockerfile.base-mitie') }} MAKEFILE_MITIE_HASH=${{ hashFiles('Makefile') }} - echo "base_mitie_image_hash=${BASE_MITIE_IMAGE_HASH:0:50}-${MAKEFILE_MITIE_HASH:0:50}" >> $GITHUB_OUTPUT + echo "base_mitie_image_hash=${BASE_MITIE_IMAGE_HASH}" >> $GITHUB_OUTPUT BASE_IMAGE_MITIE_EXISTS=$((docker manifest inspect rasa/rasa:base-mitie-${BASE_MITIE_IMAGE_HASH:0:50}-${MAKEFILE_MITIE_HASH:0:50} &> /dev/null && echo true || echo false) || true) echo "base_mitie_exists=${BASE_IMAGE_MITIE_EXISTS}" >> $GITHUB_OUTPUT @@ -1095,8 +1095,6 @@ jobs: IS_NEWEST_VERSION=${{ needs.build_docker_base_images_and_set_env.outputs.is_newest_version }} docker buildx bake --set *.platform=linux/amd64,linux/arm64 -f docker/docker-bake.hcl ${{ matrix.image }} --push - docker buildx bake --set *.platform=linux/amd64 -f docker/docker-bake.hcl ${{ matrix.image }} --load - docker buildx bake --set *.platform=linux/arm64 -f docker/docker-bake.hcl ${{ matrix.image }} --load # Tag the image as latest if [[ "${IS_NEWEST_VERSION}" == "true" ]]; then @@ -1107,9 +1105,11 @@ jobs: fi LATEST_TAG=$(echo $RELEASE_TAG | sed 's/'$IMAGE_TAG'/latest/g') - - docker tag rasa/rasa:${RELEASE_TAG} rasa/rasa:${LATEST_TAG} - docker push rasa/rasa:${LATEST_TAG} + + # This will not build the image from ground up, but will only tag the existing image with LATEST_TAG + IMAGE_TAG=${LATEST_TAG} docker buildx bake --set *.platform=linux/amd64,linux/arm64 -f docker/docker-bake.hcl ${{ matrix.image }} + # Push tagged image + IMAGE_TAG=${LATEST_TAG} docker buildx bake --set *.platform=linux/amd64,linux/arm64 -f docker/docker-bake.hcl ${{ matrix.image }} --push fi deploy: diff --git a/3.7.0b1/main_plain/.config/rasa/global.yml b/3.7.0b1/main_plain/.config/rasa/global.yml new file mode 100644 index 000000000000..c5dcee2da8c9 --- /dev/null +++ b/3.7.0b1/main_plain/.config/rasa/global.yml @@ -0,0 +1,4 @@ +metrics: + enabled: true + rasa_user_id: 003ff8fbd6e04031b5597b37356022d4 + date: 2023-09-12 13:20:59.423434