@picked/analytics 0.0.50-next.3 → 0.0.50-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,119 +1,105 @@
1
- import { supportsWindow as x } from "@picked/client";
2
- import { split as E, attach as S } from "effector";
3
- import { p as k, n as b, o as _, x as l, z as g, B as F, A as I, F as A, E as C, D as L, y as h, t as z, s as U, w, q as B, r as R } from "../../../user-interaction-DIVYOG3I.js";
4
- import "@snowplow/browser-tracker";
5
- function D(o) {
6
- return o.isResolved;
1
+ import { G as e, H as t, I as n, K as r, R as i, U as a, V as o, W as s, g as c, h as l, m as u, n as d, p as f, q as p, t as m, z as h } from "../../../src-B3CVPde9.js";
2
+ import { supportsWindow as g } from "@picked/client";
3
+ import { attach as _, split as v } from "effector";
4
+ //#region src/plugins/analytics/plugin.ts
5
+ function y(e) {
6
+ return e.isResolved;
7
7
  }
8
- const y = ({
9
- trackerOptions: o,
10
- enableDocumentListeners: d = !1
11
- }) => ({
12
- name: "analytics",
13
- setup: (r) => {
14
- if (!x())
15
- return;
16
- const { organizationId: c, projectId: a } = r, f = () => r.features.listStore.getState().flatMap((e) => {
17
- if (!D(e)) return [];
18
- const { id: n, key: i, name: p } = e, { bucket: u } = e.getBucket();
19
- return [
20
- {
21
- name: p,
22
- key: i,
23
- feature: n,
24
- bucket: u
25
- }
26
- ];
27
- }), v = (t) => {
28
- if ("experience" in t && t.experience) {
29
- const { experience: e } = t;
30
- return {
31
- id: e.experienceId,
32
- title: e.configStore.getState().name
33
- };
34
- }
35
- };
36
- k({
37
- organizationId: c,
38
- projectId: a,
39
- ...o
40
- });
41
- const m = (t) => {
42
- const { experience: e } = t || {}, n = f();
43
- return function() {
44
- return {
45
- organizationId: c,
46
- projectId: a,
47
- sessionId: r.session?.id,
48
- identifiers: r.session?.identifiers,
49
- isUser: r.session?.isUser,
50
- features: n,
51
- ...e && {
52
- experience: {
53
- id: e.experienceId,
54
- title: e.configStore.getState().name
55
- }
56
- }
57
- };
58
- };
59
- };
60
- if (d) {
61
- const t = m();
62
- b(t);
63
- }
64
- r.experienceInstances.listStore.watch((t) => {
65
- t.forEach((e) => {
66
- const n = e.target;
67
- if (n) {
68
- const i = m({ experience: e });
69
- _(i, n.shadowRoot);
70
- }
71
- });
72
- });
73
- function s(t) {
74
- return S({
75
- source: { fields: r.fields.listStore, responses: r.responses.listStore },
76
- effect: async ({ fields: e, responses: n }, i) => {
77
- const p = f(), u = {
78
- organizationId: c,
79
- projectId: a,
80
- sessionId: r.session?.id,
81
- experience: v(i),
82
- step: "step" in i ? i.step : void 0,
83
- form: "form" in i ? i.form : void 0,
84
- exception: "exception" in i ? i.exception.reason?.[0] : void 0,
85
- // todo: support multiple exceptions
86
- fields: e,
87
- responses: n,
88
- features: p,
89
- isUser: r.session?.isUser,
90
- identifiers: r.session?.identifiers
91
- };
92
- return t(u);
93
- }
94
- });
95
- }
96
- E({
97
- source: r.eventBus,
98
- match: (t) => t.type,
99
- cases: {
100
- load: s(R),
101
- initialize: s(B),
102
- experience_initialize: s(w),
103
- experience_open: s(U),
104
- experience_close: s(z),
105
- field_validation_error: s(h),
106
- step_enter: s(L),
107
- step_submit: s(C),
108
- step_submit_success: s(A),
109
- form_submit: s(I),
110
- form_submit_success: s(F),
111
- form_submit_error: s(g),
112
- feature_decide: s(l)
113
- }
114
- });
115
- }
8
+ var b = ({ trackerOptions: b, enableDocumentListeners: x = !1 }) => ({
9
+ name: "analytics",
10
+ setup: (S) => {
11
+ if (!g()) return;
12
+ let { organizationId: C, projectId: w } = S, T = () => S.features.listStore.getState().flatMap((e) => {
13
+ if (!y(e)) return [];
14
+ let { id: t, key: n, name: r } = e, { bucket: i } = e.getBucket();
15
+ return [{
16
+ name: r,
17
+ key: n,
18
+ feature: t,
19
+ bucket: i
20
+ }];
21
+ }), E = (e) => {
22
+ if ("experience" in e && e.experience) {
23
+ let { experience: t } = e;
24
+ return {
25
+ id: t.experienceId,
26
+ title: t.configStore.getState().name
27
+ };
28
+ }
29
+ };
30
+ p({
31
+ organizationId: C,
32
+ projectId: w,
33
+ ...b
34
+ });
35
+ let D = (e) => {
36
+ let { experience: t } = e || {}, n = T();
37
+ return function() {
38
+ return {
39
+ organizationId: C,
40
+ projectId: w,
41
+ sessionId: S.session?.id,
42
+ identifiers: S.session?.identifiers,
43
+ isUser: S.session?.isUser,
44
+ features: n,
45
+ ...t && { experience: {
46
+ id: t.experienceId,
47
+ title: t.configStore.getState().name
48
+ } }
49
+ };
50
+ };
51
+ };
52
+ x && m(D()), S.experienceInstances.listStore.watch((e) => {
53
+ e.forEach((e) => {
54
+ let t = e.target;
55
+ t && d(D({ experience: e }), t.shadowRoot);
56
+ });
57
+ });
58
+ function O(e) {
59
+ return _({
60
+ source: {
61
+ fields: S.fields.listStore,
62
+ responses: S.responses.listStore
63
+ },
64
+ effect: async ({ fields: t, responses: n }, r) => {
65
+ let i = T();
66
+ return e({
67
+ organizationId: C,
68
+ projectId: w,
69
+ sessionId: S.session?.id,
70
+ experience: E(r),
71
+ step: "step" in r ? r.step : void 0,
72
+ form: "form" in r ? r.form : void 0,
73
+ exception: "exception" in r ? r.exception.reason?.[0] : void 0,
74
+ fields: t,
75
+ responses: n,
76
+ features: i,
77
+ isUser: S.session?.isUser,
78
+ identifiers: S.session?.identifiers
79
+ });
80
+ }
81
+ });
82
+ }
83
+ v({
84
+ source: S.eventBus,
85
+ match: (e) => e.type,
86
+ cases: {
87
+ load: O(s),
88
+ initialize: O(e),
89
+ experience_initialize: O(t),
90
+ experience_open: O(a),
91
+ experience_close: O(r),
92
+ field_validation_error: O(c),
93
+ step_enter: O(h),
94
+ step_submit: O(i),
95
+ step_submit_success: O(n),
96
+ form_submit: O(l),
97
+ form_submit_success: O(f),
98
+ form_submit_error: O(u),
99
+ feature_decide: O(o)
100
+ }
101
+ });
102
+ }
116
103
  });
117
- export {
118
- y as analyticsPlugin
119
- };
104
+ //#endregion
105
+ export { b as analyticsPlugin };