Skip to content

Commit

Permalink
Merge pull request #518 from pateljannat/telemetry-changes
Browse files Browse the repository at this point in the history
fix: telemetry capture on client side
  • Loading branch information
pateljannat authored May 18, 2023
2 parents 611cc4d + 56266a3 commit dc65bff
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions lms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
"lms.lms.utils.get_filtered_membership",
"lms.lms.utils.show_start_learing_cta",
"lms.lms.utils.can_create_courses",
"lms.lms.utils.get_telemetry_boot_info",
],
"filters": [],
}
Expand Down
16 changes: 16 additions & 0 deletions lms/lms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,3 +698,19 @@ def get_course_completion_data():
}
],
}


def get_telemetry_boot_info():
POSTHOG_PROJECT_FIELD = "posthog_project_id"
POSTHOG_HOST_FIELD = "posthog_host"

if not frappe.conf.get(POSTHOG_HOST_FIELD) or not frappe.conf.get(
POSTHOG_PROJECT_FIELD
):
return {}

return {
"posthog_host": frappe.conf.get(POSTHOG_HOST_FIELD),
"posthog_project_id": frappe.conf.get(POSTHOG_PROJECT_FIELD),
"enable_telemetry": 1,
}
2 changes: 1 addition & 1 deletion lms/public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ textarea.field-input {
border-bottom: none;
}

.outline-lesson .level {
.outline-lesson .level, .chapter-container .level {
justify-content: start;
}

Expand Down
1 change: 0 additions & 1 deletion lms/public/js/website.bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "./profile.js";
import "./common_functions.js";
import "../../../../frappe/frappe/public/js/frappe/ui/chart.js";
import "../../../../frappe/frappe/public/js/telemetry/index.js";
13 changes: 13 additions & 0 deletions lms/templates/lms_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@
Hello, world!
{% endblock %}
{% endblock %}

{%- block script -%}
{{ super() }}
{% if frappe.get_system_settings("enable_telemetry") %}
{% set telemetry_boot_info = get_telemetry_boot_info() %}
<script>
const telemetry_boot_info = {{ get_telemetry_boot_info() }}
if (telemetry_boot_info && Object.keys(telemetry_boot_info).length)
Object.assign(frappe.boot, telemetry_boot_info)
</script>
{% endif %}
{{ include_script("telemetry.bundle.js") }}
{%- endblock -%}

0 comments on commit dc65bff

Please sign in to comment.