Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIBRARIES-2434 [Analytics Python CLI E2E Testing Tool] #511

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

neelkanth-kaushik
Copy link

@neelkanth-kaushik neelkanth-kaushik commented Mar 24, 2025

This commit contains code for Analytics Python CLI E2E Testing Tool - LIBRARIES-2434

Changes in Commit #18827f3e14091da5e7e740a0b0d79cb6cdd07f3c

  1. Added —apiHost option.
  2. Added support for passing array of JSON objects.
  3. Removed writing logs to file.
  4. Removed IPs and UserAgents from the examples in README.md file.
  5. Updated README.md file and added details about the command options.
  6. Added .DS_Store in .gitignore



@click.command()
@click.option('--writeKey', type=str, help='Segment write key')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd also like to have an --apihost option

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

try:
# Decode the JSON payload
decodedJson = json.loads(payload)
data = json.loads(decodedJson)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is handling a single event. Could we make the root json datatype an array and send multiple events?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

logger.setLevel(logging.DEBUG)

# Create a file handler to log messages to a file
log_directory = f"{os.getenv('LOG_DIRECTORY')}/{datetime.now().strftime('%Y%m%d')}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need logging for a simple test, and logs on CI machines are often impossible to get to. If we do want something to be recorded in the build logs for this, we could look into printing to standard error, and reading and reporting from our Golang publisher. I'm not concerned about it at the moment, so just printing errors is fine until we think we need more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

### 1. Identify

``` bash
$ e2e-test:run --writeKey='YOUR_WRITE_KEY' --payload='"{\"anonymousId\":\"507f191e810c89729de960ea\",\"channel\":\"browser\",\"context\":{\"ip\":\"8.8.8.8\",\"userAgent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36\"},\"integrations\":{\"All\":false,\"Mixpanel\":true,\"Salesforce\":true},\"messageId\":\"022bb90c-bbac-11e4-8dfc-aa07a5b093q8\",\"traits\":{\"name\":\"Clark Kent\",\"email\":\"[email protected]\",\"plan\":\"premium\",\"logins\":5,\"address\":{\"street\":\"6th St\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postalCode\":\"94103\",\"country\":\"USA\"}},\"type\":\"identify\",\"userId\":\"97980cfea0062\",\"version\":\"2.0\"}"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPs and userAgents are added by the SDK itself, so we should remove them from the examples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants