@junobuild/analytics 0.1.8 → 0.2.0

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.
Files changed (49) hide show
  1. package/dist/browser/chunk-YVLJX3HV.js +2 -0
  2. package/dist/browser/chunk-YVLJX3HV.js.map +7 -0
  3. package/dist/browser/chunk-ZUUQVOC7.js +2 -0
  4. package/dist/browser/chunk-ZUUQVOC7.js.map +7 -0
  5. package/dist/browser/index.js +1 -1
  6. package/dist/browser/index.js.map +4 -4
  7. package/dist/browser/tracker.js +2 -0
  8. package/dist/browser/tracker.js.map +7 -0
  9. package/dist/browser/ua-parser-GFKOYVJI.js +2 -0
  10. package/dist/browser/ua-parser-GFKOYVJI.js.map +7 -0
  11. package/dist/browser/web-vitals-YBMS6D2C.js +2 -0
  12. package/dist/browser/web-vitals-YBMS6D2C.js.map +7 -0
  13. package/dist/node/index.mjs +1 -1
  14. package/dist/node/index.mjs.map +4 -4
  15. package/dist/types/api/orbiter.api.d.ts +26 -0
  16. package/dist/types/constants/container.constants.d.ts +1 -0
  17. package/dist/types/index.d.ts +8 -3
  18. package/dist/types/services/orbiter.services.d.ts +10 -0
  19. package/dist/types/services/performance.services.d.ts +11 -1
  20. package/dist/types/services/user-agent.services.d.ts +4 -0
  21. package/dist/types/tracker.d.ts +37 -0
  22. package/dist/types/types/env.d.ts +10 -25
  23. package/dist/types/types/orbiter.d.ts +95 -0
  24. package/dist/types/types/track.d.ts +2 -4
  25. package/dist/types/utils/analytics.utils.d.ts +2 -3
  26. package/dist/types/utils/dfinity/asserts.utils.d.ts +7 -0
  27. package/dist/types/utils/dfinity/debounce.utils.d.ts +12 -0
  28. package/dist/types/utils/dfinity/json.utils.d.ts +25 -0
  29. package/dist/types/utils/dfinity/nullish.utils.d.ts +30 -0
  30. package/dist/types/utils/env.utils.d.ts +5 -0
  31. package/dist/types/utils/log.utils.d.ts +1 -1
  32. package/package.json +5 -10
  33. package/dist/browser/idb.services-CVJFLYYN.js +0 -2
  34. package/dist/browser/idb.services-CVJFLYYN.js.map +0 -7
  35. package/dist/browser/web-vitals-JGDN2KW5.js +0 -2
  36. package/dist/browser/web-vitals-JGDN2KW5.js.map +0 -7
  37. package/dist/declarations/orbiter/orbiter.did.d.ts +0 -229
  38. package/dist/declarations/orbiter/orbiter.factory.certified.did.js +0 -255
  39. package/dist/declarations/orbiter/orbiter.factory.did.js +0 -271
  40. package/dist/declarations/orbiter/orbiter.factory.did.mjs +0 -271
  41. package/dist/types/api/actor.api.d.ts +0 -3
  42. package/dist/types/services/analytics.services.d.ts +0 -25
  43. package/dist/types/services/idb.services.d.ts +0 -19
  44. package/dist/types/types/idb.d.ts +0 -12
  45. package/dist/types/types/post-message.d.ts +0 -7
  46. package/dist/types/utils/actor.utils.d.ts +0 -6
  47. package/dist/types/workers/analytics.worker.d.ts +0 -1
  48. package/dist/workers/analytics.worker.js +0 -89
  49. package/dist/workers/analytics.worker.js.map +0 -7
@@ -1,271 +0,0 @@
1
- // @ts-ignore
2
- export const idlFactory = ({IDL}) => {
3
- const DeleteControllersArgs = IDL.Record({
4
- controllers: IDL.Vec(IDL.Principal)
5
- });
6
- const ControllerScope = IDL.Variant({
7
- Write: IDL.Null,
8
- Admin: IDL.Null
9
- });
10
- const Controller = IDL.Record({
11
- updated_at: IDL.Nat64,
12
- metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
13
- created_at: IDL.Nat64,
14
- scope: ControllerScope,
15
- expires_at: IDL.Opt(IDL.Nat64)
16
- });
17
- const DelSatelliteConfig = IDL.Record({version: IDL.Opt(IDL.Nat64)});
18
- const DepositCyclesArgs = IDL.Record({
19
- cycles: IDL.Nat,
20
- destination_id: IDL.Principal
21
- });
22
- const GetAnalytics = IDL.Record({
23
- to: IDL.Opt(IDL.Nat64),
24
- from: IDL.Opt(IDL.Nat64),
25
- satellite_id: IDL.Opt(IDL.Principal)
26
- });
27
- const AnalyticKey = IDL.Record({
28
- key: IDL.Text,
29
- collected_at: IDL.Nat64
30
- });
31
- const PageViewDevice = IDL.Record({
32
- inner_height: IDL.Nat16,
33
- inner_width: IDL.Nat16
34
- });
35
- const PageView = IDL.Record({
36
- title: IDL.Text,
37
- updated_at: IDL.Nat64,
38
- referrer: IDL.Opt(IDL.Text),
39
- time_zone: IDL.Text,
40
- session_id: IDL.Text,
41
- href: IDL.Text,
42
- created_at: IDL.Nat64,
43
- satellite_id: IDL.Principal,
44
- device: PageViewDevice,
45
- version: IDL.Opt(IDL.Nat64),
46
- user_agent: IDL.Opt(IDL.Text)
47
- });
48
- const AnalyticsBrowsersPageViews = IDL.Record({
49
- safari: IDL.Float64,
50
- opera: IDL.Float64,
51
- others: IDL.Float64,
52
- firefox: IDL.Float64,
53
- chrome: IDL.Float64
54
- });
55
- const AnalyticsDevicesPageViews = IDL.Record({
56
- desktop: IDL.Float64,
57
- others: IDL.Float64,
58
- mobile: IDL.Float64
59
- });
60
- const AnalyticsClientsPageViews = IDL.Record({
61
- browsers: AnalyticsBrowsersPageViews,
62
- devices: AnalyticsDevicesPageViews
63
- });
64
- const CalendarDate = IDL.Record({
65
- day: IDL.Nat8,
66
- month: IDL.Nat8,
67
- year: IDL.Int32
68
- });
69
- const AnalyticsMetricsPageViews = IDL.Record({
70
- bounce_rate: IDL.Float64,
71
- average_page_views_per_session: IDL.Float64,
72
- daily_total_page_views: IDL.Vec(IDL.Tuple(CalendarDate, IDL.Nat32)),
73
- total_page_views: IDL.Nat32,
74
- unique_page_views: IDL.Nat64,
75
- unique_sessions: IDL.Nat64
76
- });
77
- const AnalyticsTop10PageViews = IDL.Record({
78
- referrers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Nat32)),
79
- pages: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Nat32))
80
- });
81
- const NavigationType = IDL.Variant({
82
- Navigate: IDL.Null,
83
- Restore: IDL.Null,
84
- Reload: IDL.Null,
85
- BackForward: IDL.Null,
86
- BackForwardCache: IDL.Null,
87
- Prerender: IDL.Null
88
- });
89
- const WebVitalsMetric = IDL.Record({
90
- id: IDL.Text,
91
- value: IDL.Float64,
92
- navigation_type: IDL.Opt(NavigationType),
93
- delta: IDL.Float64
94
- });
95
- const PerformanceData = IDL.Variant({WebVitalsMetric: WebVitalsMetric});
96
- const PerformanceMetricName = IDL.Variant({
97
- CLS: IDL.Null,
98
- FCP: IDL.Null,
99
- INP: IDL.Null,
100
- LCP: IDL.Null,
101
- TTFB: IDL.Null
102
- });
103
- const PerformanceMetric = IDL.Record({
104
- updated_at: IDL.Nat64,
105
- session_id: IDL.Text,
106
- data: PerformanceData,
107
- href: IDL.Text,
108
- metric_name: PerformanceMetricName,
109
- created_at: IDL.Nat64,
110
- satellite_id: IDL.Principal,
111
- version: IDL.Opt(IDL.Nat64)
112
- });
113
- const AnalyticsWebVitalsPageMetrics = IDL.Record({
114
- cls: IDL.Opt(IDL.Float64),
115
- fcp: IDL.Opt(IDL.Float64),
116
- inp: IDL.Opt(IDL.Float64),
117
- lcp: IDL.Opt(IDL.Float64),
118
- ttfb: IDL.Opt(IDL.Float64)
119
- });
120
- const AnalyticsWebVitalsPerformanceMetrics = IDL.Record({
121
- overall: AnalyticsWebVitalsPageMetrics,
122
- pages: IDL.Vec(IDL.Tuple(IDL.Text, AnalyticsWebVitalsPageMetrics))
123
- });
124
- const TrackEvent = IDL.Record({
125
- updated_at: IDL.Nat64,
126
- session_id: IDL.Text,
127
- metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
128
- name: IDL.Text,
129
- created_at: IDL.Nat64,
130
- satellite_id: IDL.Principal,
131
- version: IDL.Opt(IDL.Nat64)
132
- });
133
- const AnalyticsTrackEvents = IDL.Record({
134
- total: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Nat32))
135
- });
136
- const OrbiterSatelliteFeatures = IDL.Record({
137
- performance_metrics: IDL.Bool,
138
- track_events: IDL.Bool,
139
- page_views: IDL.Bool
140
- });
141
- const OrbiterSatelliteConfig = IDL.Record({
142
- updated_at: IDL.Nat64,
143
- features: IDL.Opt(OrbiterSatelliteFeatures),
144
- created_at: IDL.Nat64,
145
- version: IDL.Opt(IDL.Nat64)
146
- });
147
- const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
148
- const SetController = IDL.Record({
149
- metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
150
- scope: ControllerScope,
151
- expires_at: IDL.Opt(IDL.Nat64)
152
- });
153
- const SetControllersArgs = IDL.Record({
154
- controller: SetController,
155
- controllers: IDL.Vec(IDL.Principal)
156
- });
157
- const SetPageView = IDL.Record({
158
- title: IDL.Text,
159
- updated_at: IDL.Opt(IDL.Nat64),
160
- referrer: IDL.Opt(IDL.Text),
161
- time_zone: IDL.Text,
162
- session_id: IDL.Text,
163
- href: IDL.Text,
164
- satellite_id: IDL.Principal,
165
- device: PageViewDevice,
166
- version: IDL.Opt(IDL.Nat64),
167
- user_agent: IDL.Opt(IDL.Text)
168
- });
169
- const Result = IDL.Variant({Ok: PageView, Err: IDL.Text});
170
- const Result_1 = IDL.Variant({
171
- Ok: IDL.Null,
172
- Err: IDL.Vec(IDL.Tuple(AnalyticKey, IDL.Text))
173
- });
174
- const SetPerformanceMetric = IDL.Record({
175
- session_id: IDL.Text,
176
- data: PerformanceData,
177
- href: IDL.Text,
178
- metric_name: PerformanceMetricName,
179
- satellite_id: IDL.Principal,
180
- version: IDL.Opt(IDL.Nat64),
181
- user_agent: IDL.Opt(IDL.Text)
182
- });
183
- const Result_2 = IDL.Variant({Ok: PerformanceMetric, Err: IDL.Text});
184
- const SetSatelliteConfig = IDL.Record({
185
- features: IDL.Opt(OrbiterSatelliteFeatures),
186
- version: IDL.Opt(IDL.Nat64)
187
- });
188
- const SetTrackEvent = IDL.Record({
189
- updated_at: IDL.Opt(IDL.Nat64),
190
- session_id: IDL.Text,
191
- metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
192
- name: IDL.Text,
193
- satellite_id: IDL.Principal,
194
- version: IDL.Opt(IDL.Nat64),
195
- user_agent: IDL.Opt(IDL.Text)
196
- });
197
- const Result_3 = IDL.Variant({Ok: TrackEvent, Err: IDL.Text});
198
- return IDL.Service({
199
- del_controllers: IDL.Func(
200
- [DeleteControllersArgs],
201
- [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
202
- []
203
- ),
204
- del_satellite_config: IDL.Func([IDL.Principal, DelSatelliteConfig], [], []),
205
- deposit_cycles: IDL.Func([DepositCyclesArgs], [], []),
206
- get_page_views: IDL.Func(
207
- [GetAnalytics],
208
- [IDL.Vec(IDL.Tuple(AnalyticKey, PageView))],
209
- ['query']
210
- ),
211
- get_page_views_analytics_clients: IDL.Func(
212
- [GetAnalytics],
213
- [AnalyticsClientsPageViews],
214
- ['query']
215
- ),
216
- get_page_views_analytics_metrics: IDL.Func(
217
- [GetAnalytics],
218
- [AnalyticsMetricsPageViews],
219
- ['query']
220
- ),
221
- get_page_views_analytics_top_10: IDL.Func([GetAnalytics], [AnalyticsTop10PageViews], ['query']),
222
- get_performance_metrics: IDL.Func(
223
- [GetAnalytics],
224
- [IDL.Vec(IDL.Tuple(AnalyticKey, PerformanceMetric))],
225
- ['query']
226
- ),
227
- get_performance_metrics_analytics_web_vitals: IDL.Func(
228
- [GetAnalytics],
229
- [AnalyticsWebVitalsPerformanceMetrics],
230
- ['query']
231
- ),
232
- get_track_events: IDL.Func(
233
- [GetAnalytics],
234
- [IDL.Vec(IDL.Tuple(AnalyticKey, TrackEvent))],
235
- ['query']
236
- ),
237
- get_track_events_analytics: IDL.Func([GetAnalytics], [AnalyticsTrackEvents], ['query']),
238
- list_controllers: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], ['query']),
239
- list_satellite_configs: IDL.Func(
240
- [],
241
- [IDL.Vec(IDL.Tuple(IDL.Principal, OrbiterSatelliteConfig))],
242
- ['query']
243
- ),
244
- memory_size: IDL.Func([], [MemorySize], ['query']),
245
- set_controllers: IDL.Func(
246
- [SetControllersArgs],
247
- [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
248
- []
249
- ),
250
- set_page_view: IDL.Func([AnalyticKey, SetPageView], [Result], []),
251
- set_page_views: IDL.Func([IDL.Vec(IDL.Tuple(AnalyticKey, SetPageView))], [Result_1], []),
252
- set_performance_metric: IDL.Func([AnalyticKey, SetPerformanceMetric], [Result_2], []),
253
- set_performance_metrics: IDL.Func(
254
- [IDL.Vec(IDL.Tuple(AnalyticKey, SetPerformanceMetric))],
255
- [Result_1],
256
- []
257
- ),
258
- set_satellite_configs: IDL.Func(
259
- [IDL.Vec(IDL.Tuple(IDL.Principal, SetSatelliteConfig))],
260
- [IDL.Vec(IDL.Tuple(IDL.Principal, OrbiterSatelliteConfig))],
261
- []
262
- ),
263
- set_track_event: IDL.Func([AnalyticKey, SetTrackEvent], [Result_3], []),
264
- set_track_events: IDL.Func([IDL.Vec(IDL.Tuple(AnalyticKey, SetTrackEvent))], [Result_1], []),
265
- version: IDL.Func([], [IDL.Text], ['query'])
266
- });
267
- };
268
- // @ts-ignore
269
- export const init = ({IDL}) => {
270
- return [];
271
- };
@@ -1,3 +0,0 @@
1
- import type { _SERVICE as OrbiterActor } from '../../declarations/orbiter/orbiter.did';
2
- import type { EnvironmentActor } from '../types/env';
3
- export declare const getOrbiterActor: (env: EnvironmentActor) => Promise<OrbiterActor>;
@@ -1,25 +0,0 @@
1
- import type { Environment } from '../types/env';
2
- import type { PostMessageInitEnvData } from '../types/post-message';
3
- import type { TrackEvent } from '../types/track';
4
- export declare const initWorker: (env: Environment) => {
5
- cleanup: () => void;
6
- };
7
- export declare const initTrackPageViews: () => {
8
- cleanup: () => void;
9
- };
10
- export declare const setPageView: () => Promise<void>;
11
- export declare const initTrackPerformance: ({ options }: Environment) => Promise<void>;
12
- /**
13
- * Tracks a page view in Juno Analytics.
14
- * @returns {Promise<void>} A promise that resolves when the page view is tracked.
15
- */
16
- export declare const trackPageView: () => Promise<void>;
17
- /**
18
- * Tracks a custom event in Juno Analytics.
19
- * @param {TrackEvent} data - The event details.
20
- * @returns {Promise<void>} A promise that resolves when the event is tracked.
21
- */
22
- export declare const trackEvent: (data: TrackEvent) => Promise<void>;
23
- export declare const initWorkerEnvironment: (env: PostMessageInitEnvData) => void;
24
- export declare const startTracking: () => void;
25
- export declare const stopTracking: () => void;
@@ -1,19 +0,0 @@
1
- import type { IdbKey, IdbPageView, IdbPerformanceMetric, IdbTrackEvent } from '../types/idb';
2
- export declare const setPageView: ({ key, view }: {
3
- key: IdbKey;
4
- view: IdbPageView;
5
- }) => Promise<void>;
6
- export declare const getPageViews: () => Promise<[IDBValidKey, IdbPageView][]>;
7
- export declare const delPageViews: (keys: IDBValidKey[]) => Promise<void>;
8
- export declare const setTrackEvent: ({ key, track }: {
9
- key: IdbKey;
10
- track: IdbTrackEvent;
11
- }) => Promise<void>;
12
- export declare const getTrackEvents: () => Promise<[IDBValidKey, IdbTrackEvent][]>;
13
- export declare const delTrackEvents: (keys: IDBValidKey[]) => Promise<void>;
14
- export declare const setPerformanceMetric: ({ key, view }: {
15
- key: IdbKey;
16
- view: IdbPerformanceMetric;
17
- }) => Promise<void>;
18
- export declare const getPerformanceMetrics: () => Promise<[IDBValidKey, IdbPerformanceMetric][]>;
19
- export declare const delPerformanceMetrics: (keys: IDBValidKey[]) => Promise<void>;
@@ -1,12 +0,0 @@
1
- import type { SetPageView, SetPerformanceMetric, SetTrackEvent } from '../../declarations/orbiter/orbiter.did';
2
- import type { TrackEvent } from './track';
3
- export type IdbKey = string;
4
- export type IdbPageView = Omit<SetPageView, 'satellite_id'> & {
5
- collected_at: bigint;
6
- };
7
- export type IdbTrackEvent = TrackEvent & Pick<SetTrackEvent, 'user_agent' | 'updated_at' | 'version' | 'session_id'> & {
8
- collected_at: bigint;
9
- };
10
- export type IdbPerformanceMetric = Omit<SetPerformanceMetric, 'satellite_id'> & {
11
- collected_at: bigint;
12
- };
@@ -1,7 +0,0 @@
1
- import type { Environment } from './env';
2
- export type PostMessageRequest = 'junoInitEnvironment' | 'junoTrackPageView' | 'junoTrackEvent' | 'junoStartTrackTimer' | 'junoStopTracker';
3
- export type PostMessageInitEnvData = Environment;
4
- export interface PostMessage {
5
- msg: PostMessageRequest;
6
- data?: PostMessageInitEnvData;
7
- }
@@ -1,6 +0,0 @@
1
- import { type ActorMethod, type ActorSubclass } from '@dfinity/agent';
2
- import type { IDL } from '@dfinity/candid';
3
- import type { EnvironmentActor } from '../types/env';
4
- export declare const createActor: <T = Record<string, ActorMethod>>({ orbiterId: canisterId, idlFactory, container }: {
5
- idlFactory: IDL.InterfaceFactory;
6
- } & EnvironmentActor) => Promise<ActorSubclass<T>>;
@@ -1 +0,0 @@
1
- export {};