@picked/analytics 0.0.10-next.4 → 0.0.10

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@picked/client"),g=require("effector"),n=require("../../../user-interaction-C2A-97sb.cjs");require("@snowplow/browser-tracker");function b(a){return a.isResolved}const k=({trackerOptions:a,enableDocumentListeners:v=!1})=>({name:"analytics",setup:s=>{if(!E.supportsWindow())return;const{organizationId:u,projectId:p}=s,S=()=>s.features.listStore.getState().flatMap(e=>{if(!b(e))return[];const{id:c,key:r,name:o}=e,{bucket:f}=e.getBucket();return[{name:o,key:r,feature:c,bucket:f}]}),l=t=>{if("experience"in t&&t.experience){const{experience:e}=t;return{id:e.id,type:e.configStore.getState().type,title:e.configStore.getState().name}}if("experienceInstance"in t&&t.experienceInstance){const{experienceInstance:e}=t;return{id:e.experienceId,type:e.configStore.getState().type,title:e.configStore.getState().name}}};n.createTracker({organizationId:u,projectId:p,...a});const m=t=>{const{experience:e}=t||{},c=S();return function(){var o;return{organizationId:u,projectId:p,sessionId:(o=s.session)==null?void 0:o.id,features:c,...e&&{experience:{id:e.experienceId,type:e.configStore.getState().type,title:e.configStore.getState().name}}}}};if(v){const t=m();n.bindGlobalEventListeners(t)}s.experienceInstances.listStore.watch(t=>{t.forEach(e=>{const c=e.target;if(c){const r=m({experience:e});n.bindUserInteractionListeners(r,c.shadowRoot)}})});function i(t){return g.attach({source:{fields:s.fields.listStore,responses:s.responses.listStore},effect:async({fields:e,responses:c},r)=>{var x,d;const o=S(),f={organizationId:u,projectId:p,sessionId:(x=s.session)==null?void 0:x.id,experience:l(r),step:"step"in r?r.step:void 0,form:"form"in r?r.form:void 0,exception:"exception"in r?(d=r.exception.reason)==null?void 0:d[0]:void 0,fields:e,responses:c,features:o};return t(f)}})}g.split({source:s.eventBus,match:t=>t.type,cases:{initialized:i(n.trackAppLoadEvent),experience_open:i(n.trackAppOpenEvent),experience_close:i(n.trackAppCloseEvent),field_validation_error:i(n.trackFieldValidationErrorEvent),experience_initialized:i(n.trackExperienceLoadEvent),step_enter:i(n.trackStepEnterEvent),step_submit:i(n.trackStepSubmitEvent),step_submit_success:i(n.trackStepSubmitSuccessEvent),form_submit:i(n.trackFormSubmitEvent),form_submit_success:i(n.trackFormSubmitSuccessEvent),form_submit_error:i(n.trackFormSubmitErrorEvent)}})}});exports.analyticsPlugin=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@picked/client"),g=require("effector"),n=require("../../../user-interaction-C2A-97sb.cjs");require("@snowplow/browser-tracker");function d(o){return o.isResolved}const k=({trackerOptions:o,sessionId:S,enableDocumentListeners:l=!1})=>({name:"analytics",setup:s=>{if(!b.supportsWindow())return;const{organizationId:a,projectId:u}=s,m=()=>s.features.listStore.getState().flatMap(e=>{if(!d(e))return[];const{id:c,key:r,name:p}=e,{bucket:f}=e.getBucket();return[{name:p,key:r,feature:c,bucket:f}]}),E=t=>{if("experience"in t&&t.experience){const{experience:e}=t;return{id:e.id,type:e.configStore.getState().type,title:e.configStore.getState().name}}if("experienceInstance"in t&&t.experienceInstance){const{experienceInstance:e}=t;return{id:e.experienceId,type:e.configStore.getState().type,title:e.configStore.getState().name}}};n.createTracker({organizationId:a,projectId:u,...o});const v=t=>{const{experience:e}=t||{},c=m();return function(){return{organizationId:a,projectId:u,sessionId:S,features:c,...e&&{experience:{id:e.experienceId,type:e.configStore.getState().type,title:e.configStore.getState().name}}}}};if(l){const t=v();n.bindGlobalEventListeners(t)}s.experienceInstances.listStore.watch(t=>{t.forEach(e=>{const c=e.target;if(c){const r=v({experience:e});n.bindUserInteractionListeners(r,c.shadowRoot)}})});function i(t){return g.attach({source:{fields:s.fields.listStore,responses:s.responses.listStore},effect:async({fields:e,responses:c},r)=>{var x;const p=m(),f={organizationId:a,projectId:u,sessionId:S,experience:E(r),step:"step"in r?r.step:void 0,form:"form"in r?r.form:void 0,exception:"exception"in r?(x=r.exception.reason)==null?void 0:x[0]:void 0,version:"version"in r?r.version:void 0,fields:e,responses:c,features:p};return t(f)}})}g.split({source:s.eventBus,match:t=>t.type,cases:{initialized:i(n.trackAppLoadEvent),experience_open:i(n.trackAppOpenEvent),experience_close:i(n.trackAppCloseEvent),field_validation_error:i(n.trackFieldValidationErrorEvent),experience_initialized:i(n.trackExperienceLoadEvent),step_enter:i(n.trackStepEnterEvent),step_submit:i(n.trackStepSubmitEvent),step_submit_success:i(n.trackStepSubmitSuccessEvent),form_submit:i(n.trackFormSubmitEvent),form_submit_success:i(n.trackFormSubmitSuccessEvent),form_submit_error:i(n.trackFormSubmitErrorEvent)}})}});exports.analyticsPlugin=k;
@@ -1,30 +1,31 @@
1
- import { supportsWindow as g } from "@picked/client";
2
- import { split as E, attach as k } from "effector";
3
- import { m as b, o as l, n as _, v as I, w as F, u as C, z as L, y as h, x as A, r as w, s as y, t as z, q as R, p as B } from "../../../user-interaction-B2ZoDZL_.js";
1
+ import { supportsWindow as E } from "@picked/client";
2
+ import { split as k, attach as b } from "effector";
3
+ import { m as d, o as l, n as _, v as F, w as I, u as C, z as L, y as h, x as A, r as w, s as z, t as R, q as y, p as B } from "../../../user-interaction-B2ZoDZL_.js";
4
4
  import "@snowplow/browser-tracker";
5
- function G(o) {
6
- return o.isResolved;
5
+ function G(c) {
6
+ return c.isResolved;
7
7
  }
8
8
  const O = ({
9
- trackerOptions: o,
10
- enableDocumentListeners: v = !1
9
+ trackerOptions: c,
10
+ sessionId: f,
11
+ enableDocumentListeners: x = !1
11
12
  }) => ({
12
13
  name: "analytics",
13
14
  setup: (s) => {
14
- if (!g())
15
+ if (!E())
15
16
  return;
16
- const { organizationId: a, projectId: p } = s, f = () => s.features.listStore.getState().flatMap((e) => {
17
+ const { organizationId: o, projectId: a } = s, m = () => s.features.listStore.getState().flatMap((e) => {
17
18
  if (!G(e)) return [];
18
- const { id: i, key: r, name: c } = e, { bucket: u } = e.getBucket();
19
+ const { id: i, key: r, name: p } = e, { bucket: u } = e.getBucket();
19
20
  return [
20
21
  {
21
- name: c,
22
+ name: p,
22
23
  key: r,
23
24
  feature: i,
24
25
  bucket: u
25
26
  }
26
27
  ];
27
- }), d = (t) => {
28
+ }), g = (t) => {
28
29
  if ("experience" in t && t.experience) {
29
30
  const { experience: e } = t;
30
31
  return {
@@ -42,19 +43,18 @@ const O = ({
42
43
  };
43
44
  }
44
45
  };
45
- b({
46
- organizationId: a,
47
- projectId: p,
48
- ...o
46
+ d({
47
+ organizationId: o,
48
+ projectId: a,
49
+ ...c
49
50
  });
50
- const m = (t) => {
51
- const { experience: e } = t || {}, i = f();
51
+ const S = (t) => {
52
+ const { experience: e } = t || {}, i = m();
52
53
  return function() {
53
- var c;
54
54
  return {
55
- organizationId: a,
56
- projectId: p,
57
- sessionId: (c = s.session) == null ? void 0 : c.id,
55
+ organizationId: o,
56
+ projectId: a,
57
+ sessionId: f,
58
58
  features: i,
59
59
  ...e && {
60
60
  experience: {
@@ -66,56 +66,57 @@ const O = ({
66
66
  };
67
67
  };
68
68
  };
69
- if (v) {
70
- const t = m();
69
+ if (x) {
70
+ const t = S();
71
71
  l(t);
72
72
  }
73
73
  s.experienceInstances.listStore.watch((t) => {
74
74
  t.forEach((e) => {
75
75
  const i = e.target;
76
76
  if (i) {
77
- const r = m({ experience: e });
77
+ const r = S({ experience: e });
78
78
  _(r, i.shadowRoot);
79
79
  }
80
80
  });
81
81
  });
82
82
  function n(t) {
83
- return k({
83
+ return b({
84
84
  source: { fields: s.fields.listStore, responses: s.responses.listStore },
85
85
  effect: async ({ fields: e, responses: i }, r) => {
86
- var S, x;
87
- const c = f(), u = {
88
- organizationId: a,
89
- projectId: p,
90
- sessionId: (S = s.session) == null ? void 0 : S.id,
91
- experience: d(r),
86
+ var v;
87
+ const p = m(), u = {
88
+ organizationId: o,
89
+ projectId: a,
90
+ sessionId: f,
91
+ experience: g(r),
92
92
  step: "step" in r ? r.step : void 0,
93
93
  form: "form" in r ? r.form : void 0,
94
- exception: "exception" in r ? (x = r.exception.reason) == null ? void 0 : x[0] : void 0,
94
+ exception: "exception" in r ? (v = r.exception.reason) == null ? void 0 : v[0] : void 0,
95
95
  // todo: support multiple exceptions
96
+ version: "version" in r ? r.version : void 0,
96
97
  fields: e,
97
98
  responses: i,
98
- features: c
99
+ features: p
99
100
  };
100
101
  return t(u);
101
102
  }
102
103
  });
103
104
  }
104
- E({
105
+ k({
105
106
  source: s.eventBus,
106
107
  match: (t) => t.type,
107
108
  cases: {
108
109
  initialized: n(B),
109
- experience_open: n(R),
110
- experience_close: n(z),
111
- field_validation_error: n(y),
110
+ experience_open: n(y),
111
+ experience_close: n(R),
112
+ field_validation_error: n(z),
112
113
  experience_initialized: n(w),
113
114
  step_enter: n(A),
114
115
  step_submit: n(h),
115
116
  step_submit_success: n(L),
116
117
  form_submit: n(C),
117
- form_submit_success: n(F),
118
- form_submit_error: n(I)
118
+ form_submit_success: n(I),
119
+ form_submit_error: n(F)
119
120
  }
120
121
  });
121
122
  }
@@ -2,9 +2,10 @@ import { Picked } from '@picked/client';
2
2
  import { CreateTrackerOptions } from '../../types';
3
3
  interface AnalyticsPluginOptions {
4
4
  trackerOptions?: CreateTrackerOptions;
5
+ sessionId?: string;
5
6
  enableDocumentListeners?: boolean;
6
7
  }
7
- export declare const analyticsPlugin: ({ trackerOptions, enableDocumentListeners, }: AnalyticsPluginOptions) => {
8
+ export declare const analyticsPlugin: ({ trackerOptions, sessionId, enableDocumentListeners, }: AnalyticsPluginOptions) => {
8
9
  name: string;
9
10
  setup: (client: Picked) => void;
10
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/analytics/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,MAAM,EAEP,MAAM,gBAAgB,CAAA;AAoBvB,OAAO,KAAK,EAAoB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEzE,UAAU,sBAAsB;IAC9B,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC;AAMD,eAAO,MAAM,eAAe,GAAI,8CAG7B,sBAAsB,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAiJ1E,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/analytics/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,MAAM,EAEP,MAAM,gBAAgB,CAAA;AAoBvB,OAAO,KAAK,EAAoB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEzE,UAAU,sBAAsB;IAC9B,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC;AAMD,eAAO,MAAM,eAAe,GAAI,yDAI7B,sBAAsB,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAkJ1E,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@picked/analytics",
3
3
  "description": "Picked Analytics",
4
- "version": "0.0.10-next.4",
4
+ "version": "0.0.10",
5
5
  "dependencies": {
6
6
  "@snowplow/browser-plugin-button-click-tracking": "^4.6.5",
7
7
  "@snowplow/browser-plugin-error-tracking": "^4.6.5",
@@ -48,7 +48,7 @@
48
48
  "main": "./dist/cjs/index.js",
49
49
  "module": "./dist/esm/index.js",
50
50
  "peerDependencies": {
51
- "@picked/client": "0.0.10-next.4",
51
+ "@picked/client": "0.0.10",
52
52
  "effector": "^23.3.0"
53
53
  },
54
54
  "private": false,