|
@@ -2,6 +2,8 @@ import { IBaseAction, ICustomAction, TrackActionOption } from '@medici/types';
|
|
import type { SDKInitConfig, PlatformType, SDKConfigType } from './sdk';
|
|
import type { SDKInitConfig, PlatformType, SDKConfigType } from './sdk';
|
|
import type { IHistory } from './history';
|
|
import type { IHistory } from './history';
|
|
import { collect } from './collector';
|
|
import { collect } from './collector';
|
|
|
|
+import { cloneDeep } from 'lodash-es';
|
|
|
|
+
|
|
export class BaseTrack implements IBaseAction, ICustomAction {
|
|
export class BaseTrack implements IBaseAction, ICustomAction {
|
|
protected _platform: PlatformType;
|
|
protected _platform: PlatformType;
|
|
protected _config: SDKInitConfig;
|
|
protected _config: SDKInitConfig;
|
|
@@ -21,7 +23,8 @@ export class BaseTrack implements IBaseAction, ICustomAction {
|
|
public trackView(url: string, referrer: string, uuid: string): Promise<XMLHttpRequestResponseType> {
|
|
public trackView(url: string, referrer: string, uuid: string): Promise<XMLHttpRequestResponseType> {
|
|
console.log('BaseTrack-trackView', url, referrer, uuid);
|
|
console.log('BaseTrack-trackView', url, referrer, uuid);
|
|
this._history.playload.url = url;
|
|
this._history.playload.url = url;
|
|
- const payload = Object.assign(this._history.playload, {
|
|
|
|
|
|
+ const historyPlayload = cloneDeep(this._history.playload);
|
|
|
|
+ const payload = Object.assign(historyPlayload, {
|
|
...this._config,
|
|
...this._config,
|
|
referrer: this._history.currentRef,
|
|
referrer: this._history.currentRef,
|
|
url: url,
|
|
url: url,
|
|
@@ -33,7 +36,8 @@ export class BaseTrack implements IBaseAction, ICustomAction {
|
|
public trackEvent(event_name: string, event_data: string, url?: string, uuid?: string): Promise<XMLHttpRequestResponseType> {
|
|
public trackEvent(event_name: string, event_data: string, url?: string, uuid?: string): Promise<XMLHttpRequestResponseType> {
|
|
console.log('BaseTrack-TrackEvent', event_name, event_data, url, uuid);
|
|
console.log('BaseTrack-TrackEvent', event_name, event_data, url, uuid);
|
|
this._history.playload.url = url;
|
|
this._history.playload.url = url;
|
|
- const payload = Object.assign(this._history.playload, {
|
|
|
|
|
|
+ const historyPlayload = cloneDeep(this._history.playload);
|
|
|
|
+ const payload = Object.assign(historyPlayload, {
|
|
referrer: this._history.currentRef,
|
|
referrer: this._history.currentRef,
|
|
event_name: event_name,
|
|
event_name: event_name,
|
|
url: url,
|
|
url: url,
|
|
@@ -57,7 +61,8 @@ export class BaseTrack implements IBaseAction, ICustomAction {
|
|
}
|
|
}
|
|
|
|
|
|
public track(trackActionName: string, trackActionOption?: TrackActionOption): Promise<XMLHttpRequestResponseType> {
|
|
public track(trackActionName: string, trackActionOption?: TrackActionOption): Promise<XMLHttpRequestResponseType> {
|
|
- const payload = Object.assign(this._history.playload, {
|
|
|
|
|
|
+ const historyPlayload = cloneDeep(this._history.playload);
|
|
|
|
+ const payload = Object.assign(historyPlayload, {
|
|
referrer: this._history.currentRef,
|
|
referrer: this._history.currentRef,
|
|
...trackActionOption,
|
|
...trackActionOption,
|
|
trackActionName,
|
|
trackActionName,
|
|
@@ -67,12 +72,14 @@ export class BaseTrack implements IBaseAction, ICustomAction {
|
|
}
|
|
}
|
|
|
|
|
|
public startTrack(trackActionName: string, trackActionOption?: TrackActionOption): Promise<XMLHttpRequestResponseType> {
|
|
public startTrack(trackActionName: string, trackActionOption?: TrackActionOption): Promise<XMLHttpRequestResponseType> {
|
|
- const payload = Object.assign(this._history.playload, {
|
|
|
|
|
|
+ const historyPlayload = cloneDeep(this._history.playload);
|
|
|
|
+ const payload = Object.assign(historyPlayload, {
|
|
referrer: this._history.currentRef,
|
|
referrer: this._history.currentRef,
|
|
...trackActionOption,
|
|
...trackActionOption,
|
|
trackActionName,
|
|
trackActionName,
|
|
...this._config,
|
|
...this._config,
|
|
});
|
|
});
|
|
|
|
+
|
|
if (trackActionOption.maxWaitTime) {
|
|
if (trackActionOption.maxWaitTime) {
|
|
this._timeOut = setTimeout(() => {
|
|
this._timeOut = setTimeout(() => {
|
|
this.endTrack(trackActionName, trackActionOption);
|
|
this.endTrack(trackActionName, trackActionOption);
|
|
@@ -83,7 +90,8 @@ export class BaseTrack implements IBaseAction, ICustomAction {
|
|
|
|
|
|
public endTrack(trackActionName: string, trackActionOption?: TrackActionOption): Promise<XMLHttpRequestResponseType> {
|
|
public endTrack(trackActionName: string, trackActionOption?: TrackActionOption): Promise<XMLHttpRequestResponseType> {
|
|
clearTimeout(this._timeOut);
|
|
clearTimeout(this._timeOut);
|
|
- const payload = Object.assign(this._history.playload, {
|
|
|
|
|
|
+ const historyPlayload = cloneDeep(this._history.playload);
|
|
|
|
+ const payload = Object.assign(historyPlayload, {
|
|
referrer: this._history.currentRef,
|
|
referrer: this._history.currentRef,
|
|
...trackActionOption,
|
|
...trackActionOption,
|
|
trackActionName,
|
|
trackActionName,
|