Add subscription events (#6563)

*  Add subscription events

* 📎 Fixes PR feedback

* 📎 Fixes PR feedback
This commit is contained in:
Marina López 2025-05-28 10:50:36 +02:00 committed by GitHub
parent f84ffc3562
commit 878952f7b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 8 deletions

View file

@ -5,6 +5,7 @@
(:require
[app.common.data.macros :as dm]
[app.config :as cf]
[app.main.data.event :as ev]
[app.main.router :as rt]
[app.main.store :as st]
[app.main.ui.components.dropdown-menu :refer [dropdown-menu-item*]]
@ -14,6 +15,7 @@
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[lambdaisland.uri :as u]
[potok.v2.core :as ptk]
[rumext.v2 :as mf]))
(mf/defc cta-power-up*
@ -86,7 +88,9 @@
go-to-manage-subscription
(mf/use-fn
(fn []
;; TODO add event tracking
(st/emit! (ptk/event ::ev/event {::ev/name "open-subscription-management"
::ev/origin "dashboard"
:section "team-settings"}))
(let [href (-> (rt/get-current-href)
(rt/encode-url))
href (str "payments/subscriptions/show?returnUrl=" href)]

View file

@ -59,7 +59,9 @@
(mf/use-fn
(mf/deps min-members)
(fn []
;; TODO add event tracking subscribe trial unlimited
(st/emit! (ptk/event ::ev/event {::ev/name "create-trial-subscription"
:type "unlimited"
:quantity min-members}))
(let [current-href (rt/get-current-href)
returnUrl (js/encodeURIComponent current-href)
href (dm/str "payments/subscriptions/create?type=unlimited&quantity=" min-members "&returnUrl=" returnUrl)]
@ -67,14 +69,17 @@
(mf/use-fn
(fn []
;; TODO add event tracking subscribe trial enterprise
(st/emit! (ptk/event ::ev/event {::ev/name "create-trial-subscription"
:type "enterprise"}))
(let [current-href (rt/get-current-href)
returnUrl (js/encodeURIComponent current-href)
href (dm/str "payments/subscriptions/create?type=enterprise&returnUrl=" returnUrl)]
(st/emit! (rt/nav-raw :href href))))))
handle-accept-dialog (mf/use-callback
(fn []
;; TODO add event subscribe to another subscription
(st/emit! (ptk/event ::ev/event {::ev/name "open-subscription-management"
::ev/origin "profile"
:section "subscription-management-modal"}))
(let [current-href (rt/get-current-href)
returnUrl (js/encodeURIComponent current-href)
href (dm/str "payments/subscriptions/show?returnUrl=" returnUrl)]
@ -82,7 +87,7 @@
(modal/hide!)))
handle-close-dialog (mf/use-callback
(fn []
;; TODO add event tracking close modal/cancel subscription
(st/emit! (ptk/event ::ev/event {::ev/name "close-subscription-modal"}))
(modal/hide!)))]
[:div {:class (stl/css :modal-overlay)}
@ -147,7 +152,7 @@
(let [handle-close-dialog (mf/use-callback
(fn []
;; TODO add event tracking close modal
(st/emit! (ptk/event ::ev/event {::ev/name "subscription-success"}))
(modal/hide!)))]
[:div {:class (stl/css :modal-overlay)}
@ -192,7 +197,9 @@
(dom/open-new-window "https://penpot.app/pricing")))
go-to-payments (mf/use-fn
(fn []
;; TODO add event tracking manage subscription in stripe
(st/emit! (ptk/event ::ev/event {::ev/name "open-subscription-management"
::ev/origin "profile"
:section "subscription"}))
(let [current-href (rt/get-current-href)
returnUrl (js/encodeURIComponent current-href)
href (dm/str "payments/subscriptions/show?returnUrl=" returnUrl)]
@ -200,7 +207,7 @@
open-subscription-modal (mf/use-fn
(mf/deps teams)
(fn [subscription-name]
;; TODO add event tracking open modal to try trial
(st/emit! (ptk/event ::ev/event {::ev/name "open-subscription-modal"}))
(st/emit!
(modal/show :management-dialog
{:subscription-name subscription-name