From 818d4404a8a6a58f3a06a62153ea1b1bd37cd41c Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Wed, 18 Jan 2023 16:35:37 +0200 Subject: [PATCH] Support custom events and props in mix send_pageview (#2606) --- lib/mix/tasks/send_pageview.ex | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/mix/tasks/send_pageview.ex b/lib/mix/tasks/send_pageview.ex index 29b69bec1..0cf8eafbe 100644 --- a/lib/mix/tasks/send_pageview.ex +++ b/lib/mix/tasks/send_pageview.ex @@ -15,13 +15,17 @@ defmodule Mix.Tasks.SendPageview do @default_domain "dummy.site" @default_page "/" @default_referrer "https://google.com" + @default_event "pageview" + @default_props "{}" @options [ ip: :string, user_agent: :string, domain: :string, page: :string, referrer: :string, - host: :string + host: :string, + event: :string, + props: :string ] def run(opts) do @@ -78,13 +82,16 @@ defmodule Mix.Tasks.SendPageview do domain = Keyword.get(opts, :domain, @default_domain) page = Keyword.get(opts, :page, @default_page) referrer = Keyword.get(opts, :referrer, @default_referrer) + event = Keyword.get(opts, :event, @default_event) + props = Keyword.get(opts, :props, @default_props) %{ - name: "pageview", + name: event, url: "http://#{domain}#{page}", domain: domain, referrer: referrer, - width: 1666 + width: 1666, + props: props } end