@threekit/analytics
Advanced tools
Comparing version 0.1.96 to 0.1.97
@@ -1,2 +0,2 @@ | ||
import { ARStage, type AssetOption, Configuration, type Context, OptionInteractionType, OptionsType, type QuizOption, ShareType, type ThreekitAuthProps, type ValueOption, VisualInteractionType } from '@threekit/rest-api'; | ||
import { ARStage, type AssetOption, Configuration, type Context, OptionInteractionType, OptionsType, PlayerType, type QuizOption, ShareType, type ThreekitAuthProps, type ValueOption, VisualInteractionType } from '@threekit/rest-api'; | ||
export type SessionProps = { | ||
@@ -26,2 +26,4 @@ auth: ThreekitAuthProps; | ||
private sessionStart; | ||
private performance; | ||
private pageLoadTime; | ||
log: boolean; | ||
@@ -48,5 +50,4 @@ private isEnded; | ||
}): void; | ||
load({ loadType, loadDuration, downloadDuration, parseDuration, loadStartPageSeconds, prefetch, loadOptions, downloadSize, assetId, configuration, componentId }: { | ||
loadType: string; | ||
loadStartPageSeconds: number; | ||
load({ playerType, loadDuration, downloadDuration, parseDuration, prefetch, loadOptions, downloadSize, assetId, configuration, componentId }: { | ||
playerType: PlayerType; | ||
loadDuration: number; | ||
@@ -53,0 +54,0 @@ downloadDuration?: number; |
import { errorToString } from '@threekit/diagnostics'; | ||
import { AddToCartEvent, Analytics2, AREvent, ARStage, ChatPromptEvent, ChatResponseEvent, Configuration, CustomEvent, Event2Type, LeadEvent, LoadEvent, OptionInteractionEvent, OptionInteractionType, OptionsShowEvent, OptionsType, PurchaseEvent, QuoteEvent, ShareEvent, ShareType, StageEvent, VisualInteractionEvent, VisualInteractionType } from '@threekit/rest-api'; | ||
import { AddToCartEvent, Analytics2, AREvent, ARStage, ChatPromptEvent, ChatResponseEvent, Configuration, CustomEvent, Event2Type, LeadEvent, LoadEvent, OptionInteractionEvent, OptionInteractionType, OptionsShowEvent, OptionsType, PlayerType, PurchaseEvent, QuoteEvent, ShareEvent, ShareType, StageEvent, VisualInteractionEvent, VisualInteractionType } from '@threekit/rest-api'; | ||
import * as uuid from 'uuid'; | ||
@@ -17,2 +17,4 @@ import { roundTo } from '../math/roundTo.js'; | ||
sessionStart; | ||
performance; | ||
pageLoadTime = 0; | ||
log = false; | ||
@@ -28,2 +30,5 @@ isEnded = false; | ||
this.analytics = new Analytics2(auth); | ||
this.performance = globalThis.performance; | ||
const navigationTiming = this.performance.getEntriesByType('navigation')[0]; | ||
this.pageLoadTime = navigationTiming.startTime / 1000; | ||
this.sessionStart = new Date(); | ||
@@ -83,2 +88,3 @@ this.tryCatchBlock(() => { | ||
componentId, | ||
pageLoadOffset: this.performance.now() / 1000 - this.pageLoadTime, | ||
stageName: this.stageName, | ||
@@ -171,3 +177,3 @@ pageUrl: typeof window !== 'undefined' ? window.location.href : undefined | ||
} | ||
load({ loadType, loadDuration, downloadDuration, parseDuration, loadStartPageSeconds, prefetch, loadOptions, downloadSize, assetId, configuration, componentId }) { | ||
load({ playerType, loadDuration, downloadDuration, parseDuration, prefetch, loadOptions, downloadSize, assetId, configuration, componentId }) { | ||
this.tryCatchBlock(() => { | ||
@@ -181,3 +187,3 @@ const event = { | ||
eventType: Event2Type.Load, | ||
loadType, | ||
playerType, | ||
loadDuration: roundTo(loadDuration, 3), | ||
@@ -188,3 +194,2 @@ downloadDuration: downloadDuration !== undefined | ||
parseDuration: parseDuration !== undefined ? roundTo(parseDuration, 3) : undefined, | ||
loadStartPageSeconds: roundTo(loadStartPageSeconds, 3), | ||
prefetch: prefetch || false, | ||
@@ -191,0 +196,0 @@ loadOptions, |
{ | ||
"name": "@threekit/analytics", | ||
"version": "0.1.96", | ||
"version": "0.1.97", | ||
"type": "module", | ||
@@ -9,7 +9,7 @@ "main": "dist/index.js", | ||
"@threekit/diagnostics": "*", | ||
"@threekit/rest-api": "^0.1.96", | ||
"@threekit/rest-api": "^0.1.97", | ||
"uuid": "^9.0.1" | ||
}, | ||
"sideEffects": false, | ||
"gitHead": "9ae0e15577780e7b2098f9d00aa37e169555f86f" | ||
"gitHead": "46d7d2579b9c5e06ac71556225bafdd175ca7fa7" | ||
} |
@@ -21,2 +21,3 @@ import { errorToString } from '@threekit/diagnostics'; | ||
OptionsType, | ||
PlayerType, | ||
PurchaseEvent, | ||
@@ -66,2 +67,4 @@ type QuizOption, | ||
private sessionStart: Date; | ||
private performance: Performance; | ||
private pageLoadTime = 0; | ||
@@ -88,2 +91,8 @@ public log = false; | ||
this.performance = globalThis.performance; | ||
const navigationTiming = this.performance.getEntriesByType( | ||
'navigation' | ||
)[0] as PerformanceNavigationTiming; | ||
this.pageLoadTime = navigationTiming.startTime / 1000; | ||
this.sessionStart = new Date(); | ||
@@ -155,2 +164,3 @@ | ||
componentId, | ||
pageLoadOffset: this.performance.now() / 1000 - this.pageLoadTime, | ||
stageName: this.stageName, | ||
@@ -267,7 +277,6 @@ pageUrl: typeof window !== 'undefined' ? window.location.href : undefined | ||
load({ | ||
loadType, | ||
playerType, | ||
loadDuration, | ||
downloadDuration, | ||
parseDuration, | ||
loadStartPageSeconds, | ||
prefetch, | ||
@@ -280,4 +289,3 @@ loadOptions, | ||
}: { | ||
loadType: string; | ||
loadStartPageSeconds: number; | ||
playerType: PlayerType; | ||
loadDuration: number; | ||
@@ -301,3 +309,3 @@ downloadDuration?: number; | ||
eventType: Event2Type.Load, | ||
loadType, | ||
playerType, | ||
loadDuration: roundTo(loadDuration, 3), | ||
@@ -310,3 +318,2 @@ downloadDuration: | ||
parseDuration !== undefined ? roundTo(parseDuration, 3) : undefined, | ||
loadStartPageSeconds: roundTo(loadStartPageSeconds, 3), | ||
prefetch: prefetch || false, | ||
@@ -313,0 +320,0 @@ loadOptions, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
191573
1976
Updated@threekit/rest-api@^0.1.97