Comparing version 1.9.1 to 1.10.0
{ | ||
"name": "zmp-ga4", | ||
"version": "1.9.1", | ||
"version": "1.10.0", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Nguyễn Hồng Phát", |
@@ -1,2 +0,2 @@ | ||
export {}; | ||
export { }; | ||
@@ -12,5 +12,5 @@ declare global { | ||
callback: (result: { error_code: number; data: string }) => void | ||
); | ||
): void; | ||
}; | ||
} | ||
} |
@@ -51,2 +51,3 @@ "use strict"; | ||
exports.AdaptiveAnalytics = void 0; | ||
require("./declare"); | ||
var AdaptiveAnalytics = /** @class */ (function () { | ||
@@ -64,4 +65,10 @@ function AdaptiveAnalytics(propertyId, apiSecretKey, options) { | ||
this.options = options; | ||
this.userId = ''; | ||
this.sessionId = ''; | ||
this.startTime = performance.now(); | ||
this.eventQueue = []; | ||
this.timeout = 0; | ||
this.referer = ''; | ||
this.screenResolution = ''; | ||
this.viewportSize = ''; | ||
this.collect = function () { | ||
@@ -192,5 +199,8 @@ if (_this.userId) { | ||
if (this.isMeasurementProtocolRequired()) { | ||
var endTime = performance.now(); | ||
var engagement_time_msec = String(Math.round(endTime - this.startTime)); | ||
this.startTime = endTime; | ||
this.eventQueue.unshift({ | ||
name: action, | ||
params: __assign({ session_id: this.sessionId, engagement_time_msec: String(Math.round(performance.now() - this.startTime)), protocol: location.protocol, user_agent: navigator.userAgent, document_referrer: this.referer, screen_resolution: this.screenResolution, viewport_size: this.viewportSize }, params) | ||
params: __assign({ session_id: this.sessionId, engagement_time_msec: engagement_time_msec, protocol: location.protocol, user_agent: navigator.userAgent, document_referrer: this.referer, screen_resolution: this.screenResolution, viewport_size: this.viewportSize }, params) | ||
}); | ||
@@ -197,0 +207,0 @@ clearTimeout(this.timeout); |
@@ -0,4 +1,6 @@ | ||
import "./declare"; | ||
export class AdaptiveAnalytics { | ||
private userId: string; | ||
private sessionId: string; | ||
private userId = ''; | ||
private sessionId = ''; | ||
private startTime = performance.now(); | ||
@@ -9,6 +11,6 @@ private eventQueue: { | ||
}[] = []; | ||
private timeout: number; | ||
private referer: string; | ||
private screenResolution: string; | ||
private viewportSize: string; | ||
private timeout = 0; | ||
private referer = ''; | ||
private screenResolution = ''; | ||
private viewportSize = ''; | ||
@@ -23,5 +25,5 @@ constructor( | ||
} = { | ||
useMeasurementProtocolWhen: () => | ||
["http:", "https:"].indexOf(window.location.protocol) === -1, | ||
} | ||
useMeasurementProtocolWhen: () => | ||
["http:", "https:"].indexOf(window.location.protocol) === -1, | ||
} | ||
) { | ||
@@ -59,3 +61,3 @@ if (this.isMeasurementProtocolRequired()) { | ||
history.pushState = function () { | ||
originalPushState.apply(this, arguments); | ||
originalPushState.apply(this, arguments as unknown as Parameters<typeof history.pushState>); | ||
window.dispatchEvent(new Event("pushstate")); | ||
@@ -66,3 +68,3 @@ }; | ||
history.replaceState = function () { | ||
originalReplaceState.apply(this, arguments); | ||
originalReplaceState.apply(this, arguments as unknown as Parameters<typeof history.replaceState>); | ||
window.dispatchEvent(new Event("replacestate")); | ||
@@ -160,2 +162,7 @@ }; | ||
if (this.isMeasurementProtocolRequired()) { | ||
const endTime = performance.now(); | ||
const engagement_time_msec = String( | ||
Math.round(endTime - this.startTime) | ||
); | ||
this.startTime = endTime; | ||
this.eventQueue.unshift({ | ||
@@ -165,5 +172,3 @@ name: action, | ||
session_id: this.sessionId, | ||
engagement_time_msec: String( | ||
Math.round(performance.now() - this.startTime) | ||
), | ||
engagement_time_msec, | ||
protocol: location.protocol, | ||
@@ -170,0 +175,0 @@ user_agent: navigator.userAgent, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18969
398