@@ -15,12 +15,6 @@ defmodule Plausible.Factory do
1515 merge_attributes ( user , attrs )
1616 end
1717
18- def spike_notification_factory do
19- % Plausible.Site.SpikeNotification {
20- threshold: 10
21- }
22- end
23-
2418 def site_factory do
2519 domain = sequence ( :domain , & "example-#{ & 1 } .com" )
2620
@@ -104,191 +98,6 @@ defmodule Plausible.Factory do
10498 }
10599 end
106100
107- def goal_factory do
108- % Plausible.Goal { }
109- end
110-
111- def subscription_factory do
112- % Plausible.Billing.Subscription {
113- paddle_subscription_id: sequence ( :paddle_subscription_id , & "subscription-#{ & 1 } " ) ,
114- paddle_plan_id: sequence ( :paddle_plan_id , & "plan-#{ & 1 } " ) ,
115- cancel_url: "cancel.com" ,
116- update_url: "cancel.com" ,
117- status: "active" ,
118- next_bill_amount: "6.00" ,
119- next_bill_date: Timex . today ( ) ,
120- last_bill_date: Timex . today ( ) ,
121- currency_code: "USD"
122- }
123- end
124-
125- def enterprise_plan_factory do
126- % Plausible.Billing.EnterprisePlan {
127- paddle_plan_id: sequence ( :paddle_plan_id , & "plan-#{ & 1 } " ) ,
128- billing_interval: :monthly ,
129- monthly_pageview_limit: 1_000_000 ,
130- hourly_api_request_limit: 3000 ,
131- site_limit: 100
132- }
133- end
134-
135- def google_auth_factory do
136- % Plausible.Site.GoogleAuth {
137- email: sequence ( :google_auth_email , & "email-#{ & 1 } @email.com" ) ,
138- refresh_token: "123" ,
139- access_token: "123" ,
140- expires: Timex . now ( ) |> Timex . shift ( days: 1 )
141- }
142- end
143-
144- def custom_domain_factory do
145- % Plausible.Site.CustomDomain {
146- domain: sequence ( :custom_domain , & "domain-#{ & 1 } .com" )
147- }
148- end
149-
150- def weekly_report_factory do
151- % Plausible.Site.WeeklyReport { }
152- end
153-
154- def monthly_report_factory do
155- % Plausible.Site.MonthlyReport { }
156- end
157-
158- def shared_link_factory do
159- % Plausible.Site.SharedLink {
160- name: "Link name" ,
161- slug: Nanoid . generate ( )
162- }
163- end
164-
165- def invitation_factory do
166- % Plausible.Auth.Invitation {
167- invitation_id: Nanoid . generate ( ) ,
168- email: sequence ( :email , & "email-#{ & 1 } @example.com" ) ,
169- role: :admin
170- }
171- end
172-
173- def api_key_factory do
174- key = :crypto . strong_rand_bytes ( 64 ) |> Base . url_encode64 ( ) |> binary_part ( 0 , 64 )
175-
176- % Plausible.Auth.ApiKey {
177- name: "api-key-name" ,
178- key: key ,
179- key_hash: Plausible.Auth.ApiKey . do_hash ( key ) ,
180- key_prefix: binary_part ( key , 0 , 6 )
181- }
182- end
183-
184- def imported_visitors_factory do
185- % {
186- table: "imported_visitors" ,
187- date: Timex . today ( ) ,
188- visitors: 1 ,
189- pageviews: 1 ,
190- bounces: 0 ,
191- visits: 1 ,
192- visit_duration: 10
193- }
194- end
195-
196- def imported_sources_factory do
197- % {
198- table: "imported_sources" ,
199- date: Timex . today ( ) ,
200- source: "" ,
201- visitors: 1 ,
202- visits: 1 ,
203- bounces: 0 ,
204- visit_duration: 10
205- }
206- end
207-
208- def imported_pages_factory do
209- % {
210- table: "imported_pages" ,
211- date: Timex . today ( ) ,
212- page: "" ,
213- visitors: 1 ,
214- pageviews: 1 ,
215- exits: 0 ,
216- time_on_page: 10
217- }
218- end
219-
220- def imported_entry_pages_factory do
221- % {
222- table: "imported_entry_pages" ,
223- date: Timex . today ( ) ,
224- entry_page: "" ,
225- visitors: 1 ,
226- entrances: 1 ,
227- bounces: 0 ,
228- visit_duration: 10
229- }
230- end
231-
232- def imported_exit_pages_factory do
233- % {
234- table: "imported_exit_pages" ,
235- date: Timex . today ( ) ,
236- exit_page: "" ,
237- visitors: 1 ,
238- exits: 1
239- }
240- end
241-
242- def imported_locations_factory do
243- % {
244- table: "imported_locations" ,
245- date: Timex . today ( ) ,
246- country: "" ,
247- region: "" ,
248- city: 0 ,
249- visitors: 1 ,
250- visits: 1 ,
251- bounces: 0 ,
252- visit_duration: 10
253- }
254- end
255-
256- def imported_devices_factory do
257- % {
258- table: "imported_devices" ,
259- date: Timex . today ( ) ,
260- device: "" ,
261- visitors: 1 ,
262- visits: 1 ,
263- bounces: 0 ,
264- visit_duration: 10
265- }
266- end
267-
268- def imported_browsers_factory do
269- % {
270- table: "imported_browsers" ,
271- date: Timex . today ( ) ,
272- browser: "" ,
273- visitors: 1 ,
274- visits: 1 ,
275- bounces: 0 ,
276- visit_duration: 10
277- }
278- end
279-
280- def imported_operating_systems_factory do
281- % {
282- table: "imported_operating_systems" ,
283- date: Timex . today ( ) ,
284- operating_system: "" ,
285- visitors: 1 ,
286- visits: 1 ,
287- bounces: 0 ,
288- visit_duration: 10
289- }
290- end
291-
292101 defp hash_key ( ) do
293102 Keyword . fetch! (
294103 Application . get_env ( :plausible , PlausibleWeb.Endpoint ) ,
0 commit comments