Skip to content

Commit

Permalink
Bump fideslog to v1.1.3, update usage patterns (#453)
Browse files Browse the repository at this point in the history
* Update the usage of `AnalyticsClient.send`, bump fideslog to v1.1.0

Fideslog v1.1.0 changes the `AnalyticsClient.send` interface such that
it automatically executes the request in a separate event loop. There
is no longer a need to manually wrap the call in `asyncio.run` or
similar.

These changes were introduced in ethyca/fideslog#50

* Use the new `OPT_OUT_PROMPT` constant

* `AnalyticsException` --> `AnalyticsError`

* Bump fideslog to v1.1.1

* Bump fideslog to v1.1.2

* Bump fideslog to v1.1.3
  • Loading branch information
PSalant726 authored Apr 18, 2022
1 parent 8c474f5 commit c86c46c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fidesctl/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ click>=7.1.2,<8
colorama>=0.4.3
cryptography>=36
deepdiff==5.5
fideslog==1.0.1
fideslog==1.1.3
loguru>=0.5,<0.6
openpyxl==3.0.9
pandas==1.4
Expand Down
6 changes: 4 additions & 2 deletions fidesctl/src/fidesctl/cli/commands/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import os

import click
from fideslog.sdk.python.utils import OPT_OUT_COPY
import toml

from fideslog.sdk.python.utils import OPT_OUT_COPY, OPT_OUT_PROMPT

import fidesctl
from fidesctl.cli.utils import check_server, with_analytics
from fidesctl.core.utils import echo_green, echo_red
Expand Down Expand Up @@ -62,7 +63,8 @@ def init(ctx: click.Context, fides_directory_location: str) -> None:
config_docs_url = "https://ethyca.github.io/fides/installation/configuration/"
config_message = f"""Created a config file at '{config_path}'. To learn more, see:
{config_docs_url}"""
config.user.analytics_opt_out = bool(input(OPT_OUT_COPY).lower() == "n")
click.echo(OPT_OUT_COPY)
config.user.analytics_opt_out = bool(input(OPT_OUT_PROMPT).lower() == "n")
with open(config_path, "w") as config_file:
config_dict = config.dict(include=included_values)
toml.dump(config_dict, config_file)
Expand Down
12 changes: 6 additions & 6 deletions fidesctl/src/fidesctl/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import json
import sys
from asyncio import run
from datetime import datetime, timezone
from os import getenv
from typing import Any, Callable, Dict

import click
import requests
from fideslog.sdk.python.event import AnalyticsEvent
from fideslog.sdk.python.exceptions import AnalyticsException
from fideslog.sdk.python.utils import OPT_OUT_COPY
from fideslog.sdk.python.exceptions import AnalyticsError
from fideslog.sdk.python.utils import OPT_OUT_COPY, OPT_OUT_PROMPT

from fidesctl.core import api as _api
from fidesctl.core.config.utils import get_config_from_file, update_config_file
Expand Down Expand Up @@ -74,8 +73,9 @@ def check_and_update_analytics_config(ctx: click.Context, config_path: str) -> N

config_updates: Dict[str, Dict] = {}
if ctx.obj["CONFIG"].user.analytics_opt_out is None:
click.echo(OPT_OUT_COPY)
ctx.obj["CONFIG"].user.analytics_opt_out = bool(
input(OPT_OUT_COPY).lower() == "n"
input(OPT_OUT_PROMPT).lower() == "n"
)

config_updates.update(
Expand Down Expand Up @@ -138,6 +138,6 @@ def with_analytics(ctx: click.Context, command_handler: Callable, **kwargs: Dict
)

try:
run(ctx.meta["ANALYTICS_CLIENT"].send(event))
except AnalyticsException:
ctx.meta["ANALYTICS_CLIENT"].send(event)
except AnalyticsError:
pass # cli analytics should fail silently

0 comments on commit c86c46c

Please sign in to comment.