gemercheung 3 vuotta sitten
vanhempi
commit
4480c9c9c8

+ 1 - 1
packages/core/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@medici/core",
-  "version": "0.0.3",
+  "version": "0.0.4",
   "main": "dist/index",
   "types": "dist/index",
   "files": [

+ 8 - 2
packages/core/src/basicTrack.ts

@@ -18,13 +18,14 @@ export class BaseTrack implements IBaseAction, ICustomAction {
         this._endPoint = params.endPoint;
         this._trackEndPoint = params.trackEndPoint;
     }
-    public trackView(url: string, referrer: string, uuid: string): void {
+    public trackView(url: string, referrer: string, uuid: string): Promise<XMLHttpRequestResponseType> {
         console.log('BaseTrack-trackView', url, referrer, uuid);
         console.log('111-playload', this._history.playload);
         const payload = Object.assign(this._history.playload, {
             referrer: this._history.currentRef,
+            ...this._config,
         });
-        collect(this._endPoint, 'pageview', payload);
+        return collect(this._endPoint, 'pageview', payload);
     }
 
     public trackEvent(event_name: string, event_data: string, url?: string, uuid?: string): Promise<XMLHttpRequestResponseType> {
@@ -33,6 +34,7 @@ export class BaseTrack implements IBaseAction, ICustomAction {
             referrer: this._history.currentRef,
             event_name: event_name,
             event_data: event_data,
+            ...this._config,
         });
         return collect(this._endPoint, 'event', payload);
     }
@@ -43,6 +45,7 @@ export class BaseTrack implements IBaseAction, ICustomAction {
             referrer: this._history.currentRef,
             event_name: type,
             event_data: value,
+            ...this._config,
         });
         collect(this._endPoint, 'event', payload);
     }
@@ -52,6 +55,7 @@ export class BaseTrack implements IBaseAction, ICustomAction {
             referrer: this._history.currentRef,
             ...trackActionOption,
             trackActionName,
+            ...this._config,
         });
         collect(this._trackEndPoint, 'track', payload);
     }
@@ -61,6 +65,7 @@ export class BaseTrack implements IBaseAction, ICustomAction {
             referrer: this._history.currentRef,
             ...trackActionOption,
             trackActionName,
+            ...this._config,
         });
         collect(this._trackEndPoint, 'startTrack', payload);
         if (trackActionOption.maxWaitTime) {
@@ -76,6 +81,7 @@ export class BaseTrack implements IBaseAction, ICustomAction {
             referrer: this._history.currentRef,
             ...trackActionOption,
             trackActionName,
+            ...this._config,
         });
         collect(this._trackEndPoint, 'endTrack', payload);
     }

+ 10 - 0
packages/core/src/history.ts

@@ -42,6 +42,10 @@ export class IHistory {
         global.document.addEventListener('readystatechange', this.handleReadystatechange.bind(this), true);
         global.history.pushState = hook(global.history, 'pushState', this.handlePushState.bind(this));
         global.history.replaceState = hook(global.history, 'replaceState', this.handlePushState.bind(this));
+        this.initPlayload();
+    }
+
+    initPlayload(): void {
         const {
             screen: { width, height },
             navigator: { language, userAgent },
@@ -85,6 +89,9 @@ export class IHistory {
                 this._currentUrl = newUrl;
             }
             console.log('diff', this._currentUrl !== this._currentRef);
+            console.log('this._currentUrl', this._currentUrl);
+            console.log('this._currentRef', this._currentRef);
+
             if (this._currentUrl !== this._currentRef) {
                 console.log('trackView', data, unused, url);
                 this._sdk.trackView(this._currentUrl, this._currentRef, this._playload.website);
@@ -94,6 +101,9 @@ export class IHistory {
             console.log('error', error);
         }
     }
+    handleBackState(data: any, unused: string, url?: string | URL) {
+        console.log('handleBackState', data, unused, url);
+    }
     /**
      * observe Document css Event
      */

+ 1 - 1
packages/web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@medici/web",
-  "version": "0.0.3",
+  "version": "0.0.4",
   "main": "dist/index",
   "types": "dist/index",
   "files": [

+ 7 - 0
play/src/components/custom.vue

@@ -54,6 +54,7 @@ const twoTimeEndTrack = () => {
 </script>
 
 <template>
+<div class="custom">
     <h1>custom自定义Track</h1>
     1.一次消费埋点 <button @click="oneTimeTrack">点击触发</button>
     <highlightjs language="js" :code="test.t1" />
@@ -62,9 +63,15 @@ const twoTimeEndTrack = () => {
     <highlightjs language="js" :code="test.t2" />
     <button @click="twoTimeEndTrack">end点击触发</button>
     <highlightjs language="js" :code="test.t3" />
+</div>
+
 </template>
 
 <style scoped>
+.custom{
+text-align: left;
+
+}
 .read-the-docs {
     color: #888;
 }

+ 1 - 1
play/src/components/home.vue

@@ -5,7 +5,7 @@
     <div class="test">
         <router-link to="page1">page1</router-link>
         <router-link to="page2">page2</router-link>
-        <router-link to="page3" class="mdc--click--register">page3</router-link>
+        <router-link to="page3">page3</router-link>
         <router-link to="custom">自定义action</router-link>
         <a href="https://baidu.com">baidu.com 跳出</a>
         <div>

+ 2 - 1
play/src/router.ts

@@ -1,5 +1,6 @@
-import { createRouter, createWebHistory } from 'vue-router';
+import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
 export const routerHistory = createWebHistory();
+export const webHashHistory = createWebHashHistory();
 const Home = () => import('./components/home.vue');
 const Page1 = () => import('./components/page1.vue');
 const Page2 = () => import('./components/page2.vue');