Skip to content

Conversation

@zackproser
Copy link
Contributor

@zackproser zackproser commented Jun 5, 2023

Relates to: https://github.com/gruntwork-io/dogfood-infrastructure-modules/pull/150

These changes examine the URL's query string params for a github_username and inject it, along with our tutorial service's endpoint, into the user's demo lambda handler code.

The injections are implemented by a new custom client-side script included in this PR. The client side script is designed to only run on our "Deploying your first module" tutorial page, so it should theoretically have minimal impact on the operation of the rest of the docs site.

The injected endpoint is our GW tutorial service's API gateway deployment URL. The customer's demo lambda's Python handler code has also been updated in this PR to call this specific endpoint and return its response, thus completing the round-trip and book-keeping for tracking activations / users who reached our tutorial goal state.

Ideally, I'd like to figure out how to properly define our GW tutorial service's endpoint solely in docusaurus.config.js and load it from within the custom client script that handles the value injection on our "Deploying your first module" , but currently when I attempt to follow docusaurus's docs on loading docusaurus config values I get an error about misusing React hooks. I'd like to manage this config centrally so that future PRs to update the endpoint could be one line change.

@netlify
Copy link

netlify bot commented Jun 5, 2023

Deploy Preview for pensive-meitner-faaeee ready!

Name Link
🔨 Latest commit 730f39e
🔍 Latest deploy log https://app.netlify.com/sites/pensive-meitner-faaeee/deploys/648b19701ab20000085a95ea
😎 Deploy Preview https://deploy-preview-855--pensive-meitner-faaeee.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Contributor

@MoonMoon1919 MoonMoon1919 left a comment

Choose a reason for hiding this comment

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

Small, non-blocking nit, but otherwise LGTM

@zackproser zackproser changed the title Core-977 - inject GitHub username and tutorial service endpoint Core-977 - inject GitHub username into lambda handler and call Mixpanel API directly Jun 6, 2023

def lambda_handler(event, context):
return "Hello from Gruntwork!"
url = "https://api.mixpanel.com/track"
Copy link
Contributor

Choose a reason for hiding this comment

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

👨🏻‍🍳 🤌 excellent

githubUsername = 'unknown'
}
// Rewrite the %unknown% placeholder in the main.py configuration on the tutorial page
document.body.innerHTML = document.body.innerHTML.replace('%unknown%', githubUsername);
Copy link
Contributor

Choose a reason for hiding this comment

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

slick!

Copy link
Contributor

@MoonMoon1919 MoonMoon1919 left a comment

Choose a reason for hiding this comment

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

Looking great. Did you check in package-lock.json by accident, or is that a bi-product of something else?

@zackproser
Copy link
Contributor Author

Looking great. Did you check in package-lock.json by accident, or is that a bi-product of something else?

Ah yeah - that was actually intended: in the docusaurus config file, to load the new client module script, I needed to call path - but seems I may not have done that correctly yet - I was originally getting build errors about Webpack > 5 having removed polyfills for certain node.js APIs such as path - so I thought the fix was to explicitly npm install it.

Not sure yet if current build errors are still related to that or not. Yesterday and the day before, Netlify logs were showing me an auth error where it looked like Netlify was unable to fetch the repo itself during the build 🤔

- These changes examine the URL's query string params for a
  github_username and inject it, along with our tutorial service's
  endpoint, into the user's demo lambda handler code
-Use requests bundled with lambda to avoid dependencies
- Fix call to extremely tempermental Mixpanel API
@zackproser zackproser force-pushed the core-977/extend-module-tutorial branch from a77fd52 to 8281a9a Compare June 9, 2023 18:56
@zackproser
Copy link
Contributor Author

Thanks for review!

Copy link
Contributor

@eak12913 eak12913 left a comment

Choose a reason for hiding this comment

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

👍

@zackproser zackproser merged commit c58c453 into master Jun 15, 2023
@zackproser zackproser deleted the core-977/extend-module-tutorial branch June 15, 2023 14:37
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.

4 participants