@24i/bigscreen-sdk 1.0.42-alpha.2710 → 1.0.42
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
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';
|
|
@@ -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
|
}
|