1

I wrote some python code that's being used fairly often (from the number of clones on github recently). However, I'd like some way of keeping a permanent count (github is a rolling 14 day window) of the number of times the code has been run and the number of unique users using the code.

I thought about having the code ping a website (Github Pages is static so it won't work - AWS specifically for this?) and a specific subdirectory every time it's used, but this seems to be more complex than I thought (system specific, maybe root needed). Ideally, I would want to abstract away any user info (MAC/IP) and just keep the counter (to respect user privacy).

Is there any way of doing this?

1 Answers1

0

The question you linked is about sending actual ICMP pings, which is not what you need. Rather, you need some simple network call which can be counted by the server.

While there are other options, I feel like making an HTTP call to an AWS Lambda function could be a good fit here. Making an HTTP call from python is easy and requires no external dependencies. And unless your library is extremely popular, these calls will probably be very infrequent, so it would be a lot cheaper to invoke a lambda than to keep an entire VM running just for this counter.

You should however take care to preserve your user's privacy, and make sure you don't violate any privacy laws or regulations (e.g. GDPR). Let your users know what information is being collected and why, and allow them to opt out of your telemetry.

Malt
  • 28,965
  • 9
  • 65
  • 105
  • 1
    Given that Lambda is stateless, how would I store the ping count? If I store no actual user data and just the ping count, I presume that would not require any disclaimer? –  Sep 06 '20 at 16:15
  • I don't know about the legal aspects so I can't answer about the disclaimer. But about the lambda - take a look at lambda's logging functionality here: https://docs.aws.amazon.com/lambda/latest/dg/python-logging.html – Malt Sep 06 '20 at 17:34