Giter Club home page Giter Club logo

shopify-monitor's People

Contributors

seansica avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

shopify-monitor's Issues

Add Discord slash command to report sites in Discord

Add a Discord slash command, /sites, that, when executed, retrieves a list of site URLs that are being monitored and notifies the webhook.

TODO:

  • Add script that creates a Discord global command via HTTP POST. Details here.
  • Make the Discord global command trigger a POST request to /sites on AWS Gateway.
  • Make AWS Gateway route POST /sites requests to a Lambda function called CheckSiteTargetsFunction.
  • Make the CheckSiteTargetsFunction function send a list of sites stored in the ConfigTable to QueuePublisherFunction for Discord message processing.
    • Figure out how to enable Lambda-to-Lambda event trigger, ideally without introducing Lambda Step Functions.

Pass options.removeUndefinedValues=true to remove undefined values from map/array/set

The following error is sometimes thrown by DynamoDB while trying to PUT an item in the InventoryTable:

PUT operation:

2022-12-28T05:42:02.487Z	b455ce90-bad2-422b-af9d-a7974285fcbf	INFO	Attempting put operation of item '
{
    "id": "39870446600227",
    "title": "NEVEREST Series EC keyboards by deskeys - 19 / AL Grey / Assembly",
    "available": false,
    "site": "https://deskeys.io/products/neverest-series-ec-kbs-by-deskeys"
}
' in table 'shopify-bot-InventoryTable-19JFEI4DD4A4B'

Error:

2022-12-28T05:42:02.351Z	b455ce90-bad2-422b-af9d-a7974285fcbf	INFO	Error Error: Pass options.removeUndefinedValues=true to remove undefined values from map/array/set.
    at convertToAttr (/opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/node_modules/@aws-sdk/util-dynamodb/dist-cjs/convertToAttr.js:7:15)
    at /opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/node_modules/@aws-sdk/util-dynamodb/dist-cjs/convertToAttr.js:118:54
    at convertToMapAttrFromEnumerableProps (/opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/node_modules/@aws-sdk/util-dynamodb/dist-cjs/convertToAttr.js:122:7)
    at convertToAttr (/opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/node_modules/@aws-sdk/util-dynamodb/dist-cjs/convertToAttr.js:23:16)
    at marshall (/opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/node_modules/@aws-sdk/util-dynamodb/dist-cjs/marshall.js:6:62)
    at marshallFunc (/opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/commands/utils.js:39:71)
    at processObj (/opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/commands/utils.js:8:20)
    at processKeyInObj (/opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/commands/utils.js:25:12)
    at /opt/nodejs/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/commands/utils.js:30:20
    at Array.reduce (<anonymous>)

Add Self Role Bot to filter notifications

As a user, I want to be able to control which notifications I receive by self-subscribing to roles.

e.g., User-A executes slash command /subscribe deskeys and is assigned the role of deskeys. User-B does not and thus does not have the deskeys role. Whenever an inventory notification relating to deskeys is triggered, User-A will receive the notification, but User-B will not.

Add ability to configure Discord username

TODO:

  • Add endpoint or piggyback off existing config handler and use a unique URL query parameter like ?discordUser=
  • Username should be stored in ConfigTable and fetched by Discord handler during web hook activation

Add CI/CD to deploy in prod

TODO:

Add a GitHub Actions runner to build & deploy the application off the main branch to the production/public Discord server

Fix duplicate events

The current state of the application allows for duplicate events to be fired to Discord.

When an item changes in the inventory table, precisely three duplicate events records are getting processed and added to the SNS topic.

I think an SQS queue should fix this.

Example:
SCR-20221223-jn3

Add site handling function

Currently, all sites are sourced by the SHOPIFY_SITES environment variable. This is sub-optimal for two reasons:

  1. The value is hard-coded into the template.yaml.
  2. The value is a JSON string. Yuck.

There should instead be a separate function that:

  • accepts an array of sites
  • persist the sites somewhere (S3 or DDB table)
  • notify the ShopifySynchronizationFunction. New sites should be included on the event object.

Add HTTP Basic Authentication

TODO:

  • Add Basic Auth to REST API endpoints
  • Use AWS Cognito Pool for authorization
  • Modify endpoints:
    • GET {api-root}/ should return a table summary
    • GET {api-root}/sync should trigger ShopifySyncFunction and return 200 "ok"

Make Bot Automatically Scan All Inventory

Currently, the bot is only capable of monitoring specific products based on product paths.

e.g.:

  • https://my-shopify-site.com/products/product1.js
  • https://my-shopify-site.com/products/product2.js

Instead, make the bot automatically monitor all available products without referencing a specific product path.

This can be done by intermittently querying the /products.json Shopify endpoint. The response will contain a list of all available products. Each element can thus be subsequently queried for inventory information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.