From af4c6efc9fa413d24c2fe46051b154524c35bf28 Mon Sep 17 00:00:00 2001 From: Alexey Zhigulev Date: Thu, 21 Dec 2023 16:44:44 +0100 Subject: [PATCH 1/3] hot-fix-release/v1.0.3 --- src/builders/event.builder.ts | 5 ++++- src/components/TwaAnalyticsProvider.tsx | 3 ++- src/helpers/date.helper.ts | 3 +++ src/types/event.ts | 1 + src/utils/create-event.ts | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/helpers/date.helper.ts diff --git a/src/builders/event.builder.ts b/src/builders/event.builder.ts index 4337c4e..083eea6 100755 --- a/src/builders/event.builder.ts +++ b/src/builders/event.builder.ts @@ -6,6 +6,7 @@ import { } from '../constants'; import { EventType } from '../enum/event-type.enum'; import { EventPushHandler } from '../event-push-handler'; +import { getCurrentUTCTimestamp } from '../helpers/date.helper'; import { encryptMessage } from '../helpers/encryption.helper'; import { IEventBuilder } from '../interfaces'; import { TelegramWebAppData } from '../models'; @@ -115,6 +116,7 @@ export class EventBuilder implements IEventBuilder { async track( eventName: string, eventProperties: Record, + sessionIdentifier?: string, ): Promise { if (eventName === null) { throw new Error('Event name is not set.'); @@ -147,9 +149,10 @@ export class EventBuilder implements IEventBuilder { this.data.platform, this.data.chat_type || 'N/A', this.data.chat_instance || '0', - Math.floor(Date.now() / 1000).toString(), + getCurrentUTCTimestamp(), eventName.startsWith(DEFAULT_SYSTEM_EVENT_PREFIX), eventProperties.wallet || undefined, + sessionIdentifier, ); return this.pushHandler.push(event); diff --git a/src/components/TwaAnalyticsProvider.tsx b/src/components/TwaAnalyticsProvider.tsx index 7e95ed2..cd1d823 100755 --- a/src/components/TwaAnalyticsProvider.tsx +++ b/src/components/TwaAnalyticsProvider.tsx @@ -10,6 +10,7 @@ import { EventBuilder } from '../builders'; import { loadTelegramWebAppData } from '../telegram/telegram'; import { TonConnectStorageData } from '../models/tonconnect-storage-data'; import { EventType } from '../enum/event-type.enum'; +import { getCurrentUTCTimestamp } from '../helpers/date.helper'; export type TwaAnalyticsProviderOptions = { projectId: string; @@ -64,7 +65,7 @@ const TwaAnalyticsProvider: FunctionComponent = ({ const locationPath = location.pathname; eventBuilder.track(`${EventType.PageView} ${locationPath}`, { path: locationPath, - }); + }, getCurrentUTCTimestamp()); }, []); useEffect(() => { diff --git a/src/helpers/date.helper.ts b/src/helpers/date.helper.ts new file mode 100644 index 0000000..704bcdb --- /dev/null +++ b/src/helpers/date.helper.ts @@ -0,0 +1,3 @@ +export const getCurrentUTCTimestamp = (): string => { + return Math.floor(Date.now() / 1000).toString(); +} \ No newline at end of file diff --git a/src/types/event.ts b/src/types/event.ts index 8da50fc..99ea81e 100644 --- a/src/types/event.ts +++ b/src/types/event.ts @@ -25,4 +25,5 @@ export interface BaseEvent { timestamp: string; isAutocapture: boolean; wallet: string | undefined; + sessionIdentifier?: string; } diff --git a/src/utils/create-event.ts b/src/utils/create-event.ts index 386b00b..666a4a5 100644 --- a/src/utils/create-event.ts +++ b/src/utils/create-event.ts @@ -13,6 +13,7 @@ export const createEvent = ( timestamp: string, isAutocapture: boolean, wallet: string | undefined, + sessionIdentifier?: string, ): BaseEvent => { return { eventType: eventName, @@ -27,5 +28,6 @@ export const createEvent = ( timestamp, isAutocapture, wallet, + sessionIdentifier, }; }; From dabed835c24a247a9698794a7d4071a0854515fa Mon Sep 17 00:00:00 2001 From: Alexey Zhigulev Date: Thu, 21 Dec 2023 16:46:21 +0100 Subject: [PATCH 2/3] release/v1.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82e3fd6..f819d43 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tonsolutions/analytics-react", - "version": "1.0.3", + "version": "1.0.4", "main": "./lib/index.сjs", "module": "./lib/index.mjs", "types": "./lib/index.d.ts", From 65dc9f84473d94700d8ea4755b71ab84f9399a87 Mon Sep 17 00:00:00 2001 From: Alexey Zhigulev Date: Thu, 21 Dec 2023 16:48:03 +0100 Subject: [PATCH 3/3] formatting --- src/components/TwaAnalyticsProvider.tsx | 10 +++++++--- src/helpers/date.helper.ts | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/TwaAnalyticsProvider.tsx b/src/components/TwaAnalyticsProvider.tsx index cd1d823..f533125 100755 --- a/src/components/TwaAnalyticsProvider.tsx +++ b/src/components/TwaAnalyticsProvider.tsx @@ -63,9 +63,13 @@ const TwaAnalyticsProvider: FunctionComponent = ({ useEffect(() => { const locationPath = location.pathname; - eventBuilder.track(`${EventType.PageView} ${locationPath}`, { - path: locationPath, - }, getCurrentUTCTimestamp()); + eventBuilder.track( + `${EventType.PageView} ${locationPath}`, + { + path: locationPath, + }, + getCurrentUTCTimestamp(), + ); }, []); useEffect(() => { diff --git a/src/helpers/date.helper.ts b/src/helpers/date.helper.ts index 704bcdb..464de83 100644 --- a/src/helpers/date.helper.ts +++ b/src/helpers/date.helper.ts @@ -1,3 +1,3 @@ -export const getCurrentUTCTimestamp = (): string => { - return Math.floor(Date.now() / 1000).toString(); -} \ No newline at end of file +export const getCurrentUTCTimestamp = (): string => { + return Math.floor(Date.now() / 1000).toString(); +};