Rename dimensions script to pageview-props (#2786)

* rename dimensions script to pageview-props

* commit mix.lock change
This commit is contained in:
RobertJoonas 2023-03-27 17:50:15 +03:00 committed by GitHub
parent 5fe32b59cd
commit bc835895a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -10,7 +10,7 @@ defmodule PlausibleWeb.Tracker do
"local",
"manual",
"file-downloads",
"dimensions",
"pageview-props",
"tagged-events"
]

View File

@ -1,11 +1,11 @@
<%= if !Application.get_env(:plausible, :is_selfhost) && !@conn.assigns[:skip_plausible_tracking] do %>
<%= if Application.get_env(:plausible, :environment) in ["prod", "staging"] do %>
<script defer data-domain="<%= base_domain() %>" event-logged_in="<%= !!@conn.assigns[:current_user] %>" src="<%="#{plausible_url()}/js/script.dimensions.js"%>"></script>
<script defer data-domain="<%= base_domain() %>" event-logged_in="<%= !!@conn.assigns[:current_user] %>" src="<%="#{plausible_url()}/js/script.pageview-props.js"%>"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
<% end %>
<%= if Application.get_env(:plausible, :environment) == "dev" do %>
<script defer data-domain="<%= base_domain() %>" event-logged_in="<%= !!@conn.assigns[:current_user] %>" src="<%="#{plausible_url()}/js/plausible.local.dimensions.js"%>"></script>
<script defer data-domain="<%= base_domain() %>" event-logged_in="<%= !!@conn.assigns[:current_user] %>" src="<%="#{plausible_url()}/js/plausible.local.pageview-props.js"%>"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
<% end %>
<% end %>

View File

@ -26,7 +26,7 @@ function compilefile(input, output, templateVars = {}) {
}
}
const base_variants = ["hash", "outbound-links", "exclusions", "compat", "local", "manual", "file-downloads", "dimensions", "tagged-events"]
const base_variants = ["hash", "outbound-links", "exclusions", "compat", "local", "manual", "file-downloads", "pageview-props", "tagged-events"]
const variants = [...g.clone.powerSet(base_variants)].filter(a => a.length > 0).map(a => a.sort());
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.js'))

View File

@ -77,14 +77,14 @@
payload.p = options.props
}
{{#if dimensions}}
var dimensionAttributes = scriptEl.getAttributeNames().filter(function (name) {
{{#if pageview_props}}
var propAttributes = scriptEl.getAttributeNames().filter(function (name) {
return name.substring(0, 6) === 'event-'
})
var props = payload.p || {}
dimensionAttributes.forEach(function(attribute) {
propAttributes.forEach(function(attribute) {
var propKey = attribute.replace('event-', '')
var propValue = scriptEl.getAttribute(attribute)
props[propKey] = props[propKey] || propValue