@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.42-alpha.2710",
3
+ "version": "1.0.42",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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, SceneInfo } from '../../interface';
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
- event, triggerName, {
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(engagementTime: number | undefined): Promise<SessionInfo> {
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
  }
@@ -38,6 +38,7 @@ export type SessionInfo = {
38
38
  referrer: string,
39
39
  engagementTime: number | undefined,
40
40
  sessionStarted: boolean,
41
+ isAuthenticated: '0' | '1',
41
42
  firstEvent: boolean,
42
43
  firstVisit: boolean,
43
44
  };
@@ -8,6 +8,7 @@ const map: Record<string, string> = {
8
8
  referrer: 'dr',
9
9
  sceneId: 'dl',
10
10
  sceneName: 'dt',
11
+ isAuthenticated: 'up.is_authenticated',
11
12
  };
12
13
 
13
14
  export const mapEventParamsToUrlParams = (eventParams: Record<string, any>)