@24i/bigscreen-sdk 1.0.42-alpha.2710 → 1.0.43-alpha.2725
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.
- package/package.json +1 -1
- package/packages/analytics/src/clients/GoogleAnalytics/GoogleAnalytics.ts +10 -14
- package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +1 -0
- package/packages/analytics/src/clients/GoogleAnalytics/mapPayload.ts +1 -0
- package/packages/list/src/BasicList/BasicList.tsx +7 -7
- package/packages/list/src/CenteredList/CenteredList.tsx +2 -2
- package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +7 -7
- package/packages/list/src/FirstOnlyList/FirstOnlyList.tsx +2 -2
- package/packages/list/src/FirstOnlyVariedList/FirstOnlyVariedList.tsx +2 -2
- package/packages/list/src/FixedToEndList/FixedToEndList.tsx +2 -2
- package/packages/list/src/interface.ts +2 -2
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { createTimeout } from '@24i/bigscreen-sdk/utils/timers';
|
|
|
5
5
|
import { MINUTE_IN_MS } from '@24i/bigscreen-sdk/utils/timeConstants';
|
|
6
6
|
import { generateUuid } from '@24i/bigscreen-sdk/utils/generateUuid';
|
|
7
7
|
import { i18n } from '@24i/bigscreen-sdk/i18n';
|
|
8
|
-
import type { AnalyticsClient, AnalyticsEventsMap,
|
|
8
|
+
import type { AnalyticsClient, AnalyticsEventsMap, AnyPayload } from '../../interface';
|
|
9
9
|
import { mapEventParamsToUrlParams, mapPayload } from './mapPayload';
|
|
10
10
|
import { prepareBody } from './prepareBody';
|
|
11
11
|
import { getUrl } from './getUrl';
|
|
@@ -74,7 +74,7 @@ export class GoogleAnalytics implements AnalyticsClient {
|
|
|
74
74
|
params.cid = generateUuid();
|
|
75
75
|
await Storage.setItem(GA_CLIENT_ID, params.cid);
|
|
76
76
|
}
|
|
77
|
-
this.firstVisit = !(await Storage.getItem(GA_FIRST_VISIT))
|
|
77
|
+
this.firstVisit = !(await Storage.getItem(GA_FIRST_VISIT));
|
|
78
78
|
if (this.firstVisit) {
|
|
79
79
|
await Storage.setItem(GA_FIRST_VISIT, '0');
|
|
80
80
|
}
|
|
@@ -123,18 +123,10 @@ export class GoogleAnalytics implements AnalyticsClient {
|
|
|
123
123
|
this.lastOnEvent = now;
|
|
124
124
|
await Promise.all(events.map(async (event, index) => {
|
|
125
125
|
const sessionInfo = await this.getSessionInfo(
|
|
126
|
-
index === 0 ? engagementTime : undefined,
|
|
126
|
+
payload!, index === 0 ? engagementTime : undefined,
|
|
127
127
|
);
|
|
128
|
-
const gtagPayload = mapPayload(
|
|
129
|
-
|
|
130
|
-
...payload,
|
|
131
|
-
...sessionInfo,
|
|
132
|
-
},
|
|
133
|
-
);
|
|
134
|
-
const urlParams = mapEventParamsToUrlParams({
|
|
135
|
-
...sessionInfo as SessionInfo,
|
|
136
|
-
...payload as SceneInfo,
|
|
137
|
-
});
|
|
128
|
+
const gtagPayload = mapPayload(event, triggerName, { ...payload, ...sessionInfo });
|
|
129
|
+
const urlParams = mapEventParamsToUrlParams({ ...sessionInfo, ...payload });
|
|
138
130
|
this.send(event, gtagPayload, urlParams);
|
|
139
131
|
}));
|
|
140
132
|
}
|
|
@@ -177,7 +169,10 @@ export class GoogleAnalytics implements AnalyticsClient {
|
|
|
177
169
|
|
|
178
170
|
private sendQueueWithDelay = debounce(this.sendQueue, SEND_DEBOUNCE_MS);
|
|
179
171
|
|
|
180
|
-
private async getSessionInfo(
|
|
172
|
+
private async getSessionInfo(
|
|
173
|
+
payload: AnyPayload,
|
|
174
|
+
engagementTime: number | undefined,
|
|
175
|
+
): Promise<SessionInfo> {
|
|
181
176
|
const sessionStarted = !this.sessionStartSent;
|
|
182
177
|
this.sessionStartSent = true;
|
|
183
178
|
const { firstEvent } = this;
|
|
@@ -194,6 +189,7 @@ export class GoogleAnalytics implements AnalyticsClient {
|
|
|
194
189
|
sessionStarted,
|
|
195
190
|
engagementTime,
|
|
196
191
|
firstEvent,
|
|
192
|
+
isAuthenticated: payload?.userId ? '1' : '0',
|
|
197
193
|
firstVisit: firstVisit as boolean,
|
|
198
194
|
};
|
|
199
195
|
}
|
|
@@ -127,34 +127,34 @@ export class BasicList<T extends Item<U>, U>
|
|
|
127
127
|
this.controller.focusCurrentItem(options);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
scrollTo(index: number) {
|
|
130
|
+
scrollTo(index: number, animate?: boolean) {
|
|
131
131
|
const list = this.base.current!;
|
|
132
132
|
const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
|
|
133
133
|
if (list.index === safeIndex) return;
|
|
134
134
|
if (list.index < safeIndex) {
|
|
135
|
-
this.scrollToForward(safeIndex);
|
|
135
|
+
this.scrollToForward(safeIndex, animate);
|
|
136
136
|
} else {
|
|
137
|
-
this.scrollToBackward(safeIndex);
|
|
137
|
+
this.scrollToBackward(safeIndex, animate);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
private scrollToForward(index: number) {
|
|
141
|
+
private scrollToForward(index: number, animate?: boolean) {
|
|
142
142
|
const { visibleItems } = this.props;
|
|
143
143
|
const list = this.base.current!;
|
|
144
144
|
list.index = index;
|
|
145
145
|
const scrollTarget = list.index - visibleItems + VISIBLE_ITEMS_OFFSET;
|
|
146
146
|
if (scrollTarget > this.controller.scrollIndex) {
|
|
147
|
-
this.controller.scroll(scrollTarget);
|
|
147
|
+
this.controller.scroll(scrollTarget, animate);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
private scrollToBackward(index: number) {
|
|
151
|
+
private scrollToBackward(index: number, animate?: boolean) {
|
|
152
152
|
const { firstScrollStep, scrollStep } = this.props;
|
|
153
153
|
const list = this.base.current!;
|
|
154
154
|
list.index = index;
|
|
155
155
|
const offset = firstScrollStep < scrollStep ? 1 : 0;
|
|
156
156
|
if (list.index - offset < this.controller.scrollIndex) {
|
|
157
|
-
this.controller.scroll(list.index);
|
|
157
|
+
this.controller.scroll(list.index, animate);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -90,12 +90,12 @@ export class CenteredList<T extends Item<U>, U>
|
|
|
90
90
|
this.controller.focusCurrentItem(options);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
scrollTo(index: number) {
|
|
93
|
+
scrollTo(index: number, animate?: boolean) {
|
|
94
94
|
const list = this.base.current!;
|
|
95
95
|
const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
|
|
96
96
|
if (list.index === safeIndex) return;
|
|
97
97
|
list.index = safeIndex;
|
|
98
|
-
this.controller.scroll(list.index);
|
|
98
|
+
this.controller.scroll(list.index, animate);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
render() {
|
|
@@ -120,18 +120,18 @@ export class EdgeOffsetList<T extends Item<U>, U>
|
|
|
120
120
|
this.controller.focusCurrentItem(options);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
scrollTo(index: number) {
|
|
123
|
+
scrollTo(index: number, animate?: boolean) {
|
|
124
124
|
const list = this.base.current!;
|
|
125
125
|
const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
|
|
126
126
|
if (list.index === safeIndex) return;
|
|
127
127
|
if (list.index < safeIndex) {
|
|
128
|
-
this.scrollToForward(safeIndex);
|
|
128
|
+
this.scrollToForward(safeIndex, animate);
|
|
129
129
|
} else {
|
|
130
|
-
this.scrollToBackward(safeIndex);
|
|
130
|
+
this.scrollToBackward(safeIndex, animate);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
private scrollToForward(index: number) {
|
|
134
|
+
private scrollToForward(index: number, animate?: boolean) {
|
|
135
135
|
const { visibleItems, edgeOffset } = this.props;
|
|
136
136
|
const list = this.base.current!;
|
|
137
137
|
list.index = index;
|
|
@@ -140,16 +140,16 @@ export class EdgeOffsetList<T extends Item<U>, U>
|
|
|
140
140
|
: edgeOffset + list.index - list.data.length - 1;
|
|
141
141
|
const scrollTarget = list.index - visibleItems + offset + VISIBLE_ITEMS_OFFSET;
|
|
142
142
|
if (scrollTarget > this.controller.scrollIndex) {
|
|
143
|
-
this.controller.scroll(scrollTarget);
|
|
143
|
+
this.controller.scroll(scrollTarget, animate);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
private scrollToBackward(index: number) {
|
|
147
|
+
private scrollToBackward(index: number, animate?: boolean) {
|
|
148
148
|
const { edgeOffset } = this.props;
|
|
149
149
|
const list = this.base.current!;
|
|
150
150
|
list.index = index;
|
|
151
151
|
if (list.index <= this.controller.scrollIndex) {
|
|
152
|
-
this.controller.scroll(list.index < edgeOffset ? 0 : list.index - edgeOffset);
|
|
152
|
+
this.controller.scroll(list.index < edgeOffset ? 0 : list.index - edgeOffset, animate);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -96,12 +96,12 @@ export class FirstOnlyList<T extends Item<U>, U>
|
|
|
96
96
|
this.controller.focusCurrentItem(options);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
scrollTo(index: number) {
|
|
99
|
+
scrollTo(index: number, animate?: boolean) {
|
|
100
100
|
const list = this.base.current!;
|
|
101
101
|
const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
|
|
102
102
|
if (list.index === safeIndex) return;
|
|
103
103
|
list.index = safeIndex;
|
|
104
|
-
this.controller.scroll(list.index);
|
|
104
|
+
this.controller.scroll(list.index, animate);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
render() {
|
|
@@ -106,12 +106,12 @@ export class FirstOnlyVariedList<T extends Item<U>, U> extends Component<Props<T
|
|
|
106
106
|
this.controller.focusCurrentItem(options);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
scrollTo(index: number) {
|
|
109
|
+
scrollTo(index: number, animate?: boolean) {
|
|
110
110
|
const list = this.base.current!;
|
|
111
111
|
const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
|
|
112
112
|
if (list.index === safeIndex) return;
|
|
113
113
|
list.index = safeIndex;
|
|
114
|
-
this.controller.scroll(0);
|
|
114
|
+
this.controller.scroll(0, animate);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
render() {
|
|
@@ -99,12 +99,12 @@ export class FixedToEndList<T extends Item<U>, U>
|
|
|
99
99
|
this.controller.focusCurrentItem(options);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
scrollTo(index: number) {
|
|
102
|
+
scrollTo(index: number, animate?: boolean) {
|
|
103
103
|
const list = this.base.current!;
|
|
104
104
|
const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
|
|
105
105
|
if (list.index === safeIndex) return;
|
|
106
106
|
list.index = safeIndex;
|
|
107
|
-
this.controller.scroll(list.index);
|
|
107
|
+
this.controller.scroll(list.index, animate);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
render() {
|
|
@@ -12,7 +12,7 @@ export interface List<
|
|
|
12
12
|
controller: UnifiedListController<U>,
|
|
13
13
|
appendData(data: U[]): void,
|
|
14
14
|
prependData(data: U[]): void,
|
|
15
|
-
scrollTo(index: number): void,
|
|
15
|
+
scrollTo(index: number, animate?: boolean): void,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface VariedList<
|
|
@@ -22,7 +22,7 @@ export interface VariedList<
|
|
|
22
22
|
controller: UnifiedVariedListController<U>,
|
|
23
23
|
appendData(data: U[]): void,
|
|
24
24
|
prependData(data: U[]): void,
|
|
25
|
-
scrollTo(index: number): void,
|
|
25
|
+
scrollTo(index: number, animate?: boolean): void,
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface ListComponent<
|