Comparing version 1.7.3 to 1.8.0
{ | ||
"name": "zmp-ga4", | ||
"version": "1.7.3", | ||
"version": "1.8.0", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Nguyễn Hồng Phát", |
@@ -65,3 +65,2 @@ "use strict"; | ||
this.collect = function () { | ||
var _a; | ||
if (_this.userId) { | ||
@@ -71,12 +70,5 @@ if (_this.eventQueue.length) { | ||
method: "POST", | ||
mode: "cors", | ||
body: JSON.stringify({ | ||
client_id: (_a = _this.options.clientId) !== null && _a !== void 0 ? _a : _this.propertyId, | ||
events: _this.eventQueue.map(function (_a) { | ||
var name = _a.name, params = _a.params; | ||
return ({ | ||
name: name, | ||
params: __assign(__assign({}, params), { session_id: _this.userId }) | ||
}); | ||
}) | ||
client_id: _this.userId, | ||
events: _this.eventQueue | ||
}) | ||
@@ -93,2 +85,3 @@ })["catch"](); | ||
this.getVisitorID().then(function (visitorId) { return (_this.userId = visitorId); }); | ||
this.sessionId = this.uuidv4(); | ||
window.addEventListener("beforeunload", this.collect); | ||
@@ -197,3 +190,3 @@ var handleLocationChange = function () { | ||
name: action, | ||
params: __assign({ engagement_time_msec: String(Math.round(performance.now() - this.startTime)), protocol: location.protocol }, params) | ||
params: __assign({ session_id: this.sessionId, engagement_time_msec: String(Math.round(performance.now() - this.startTime)), protocol: location.protocol }, params) | ||
}); | ||
@@ -200,0 +193,0 @@ clearTimeout(this.timeout); |
export class AdaptiveAnalytics { | ||
private userId: string; | ||
private sessionId: string; | ||
private startTime = performance.now(); | ||
@@ -14,3 +15,2 @@ private eventQueue: { | ||
private options: { | ||
clientId?: string; | ||
useMeasurementProtocolWhen: () => boolean; | ||
@@ -26,2 +26,3 @@ gtagConfig?: Record<string, unknown>; | ||
this.getVisitorID().then((visitorId) => (this.userId = visitorId)); | ||
this.sessionId = this.uuidv4(); | ||
window.addEventListener("beforeunload", this.collect); | ||
@@ -135,12 +136,5 @@ | ||
method: "POST", | ||
mode: "cors", | ||
body: JSON.stringify({ | ||
client_id: this.options.clientId ?? this.propertyId, | ||
events: this.eventQueue.map(({ name, params }) => ({ | ||
name, | ||
params: { | ||
...params, | ||
session_id: this.userId, | ||
}, | ||
})), | ||
client_id: this.userId, | ||
events: this.eventQueue, | ||
}), | ||
@@ -161,2 +155,3 @@ } | ||
params: { | ||
session_id: this.sessionId, | ||
engagement_time_msec: String( | ||
@@ -163,0 +158,0 @@ Math.round(performance.now() - this.startTime) |
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
17438
368