Skip to content

Commit

Permalink
👾 log_webhook_data example fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
archatas committed Feb 11, 2024
1 parent 56990ae commit c8b1e68
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
13 changes: 8 additions & 5 deletions docs/customization/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,23 @@ <h2 id="support-for-upsells">Support for Upsells</h2>

def log_webhook_data(sender, **kwargs):
import os
import json
from django.conf import settings
from django.utils.timezone import now

api_event = kwargs.get(&quot;api_event&quot;)

with open(os.path.join(settings.BASE_DIR, &quot;logs&quot;, &quot;webhook_data.log&quot;), &quot;a&quot;) as f:
json_data = (
api_event.data.model_dump_json()
if hasattr(api_event.data, &quot;model_dump_json&quot;)
else json.dumps(api_event.data)
)
with open(os.path.join(settings.BASE_DIR, &quot;webhook_data.log&quot;), &quot;a&quot;) as f:
f.write(
f&quot;&quot;&quot;{now():%Y-%m-%d %H:%M:%S} {api_event.event_type}
{api_event.data.json()}

{json_data}
&quot;&quot;&quot;
)


class MiscConfig(AppConfig):
name = &quot;myproject.apps.misc&quot;
verbose_name = _(&quot;Miscellaneous&quot;)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,5 @@ <h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>

<!--
MkDocs version : 1.5.3
Build Date UTC : 2024-02-10 20:23:09.267191+00:00
Build Date UTC : 2024-02-11 01:36:12.766934+00:00
-->
2 changes: 1 addition & 1 deletion docs/search/search_index.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://websightful.github.io/django-paddle-subscriptions-docs/</loc>
<lastmod>2024-02-10</lastmod>
<lastmod>2024-02-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://websightful.github.io/django-paddle-subscriptions-docs/CHANGELOG/</loc>
<lastmod>2024-02-10</lastmod>
<lastmod>2024-02-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://websightful.github.io/django-paddle-subscriptions-docs/LICENSE/</loc>
<lastmod>2024-02-10</lastmod>
<lastmod>2024-02-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://websightful.github.io/django-paddle-subscriptions-docs/customization/</loc>
<lastmod>2024-02-10</lastmod>
<lastmod>2024-02-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://websightful.github.io/django-paddle-subscriptions-docs/getting-started/</loc>
<lastmod>2024-02-10</lastmod>
<lastmod>2024-02-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://websightful.github.io/django-paddle-subscriptions-docs/screenshots/</loc>
<lastmod>2024-02-10</lastmod>
<lastmod>2024-02-11</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>
Binary file modified docs/sitemap.xml.gz
Binary file not shown.
13 changes: 8 additions & 5 deletions src/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,23 @@ from django.utils.translation import gettext_lazy as _

def log_webhook_data(sender, **kwargs):
import os
import json
from django.conf import settings
from django.utils.timezone import now

api_event = kwargs.get("api_event")

with open(os.path.join(settings.BASE_DIR, "logs", "webhook_data.log"), "a") as f:
json_data = (
api_event.data.model_dump_json()
if hasattr(api_event.data, "model_dump_json")
else json.dumps(api_event.data)
)
with open(os.path.join(settings.BASE_DIR, "webhook_data.log"), "a") as f:
f.write(
f"""{now():%Y-%m-%d %H:%M:%S} {api_event.event_type}
{api_event.data.json()}
{json_data}
"""
)


class MiscConfig(AppConfig):
name = "myproject.apps.misc"
verbose_name = _("Miscellaneous")
Expand Down

0 comments on commit c8b1e68

Please sign in to comment.