Skip to content

Commit

Permalink
1.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
yujuiting committed Dec 14, 2020
1 parent e82fe78 commit 912a3d9
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 7 deletions.
5 changes: 5 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ interface BasePayload {
timestamp?: string;
codename?: string;
guestSessionId?: string;
sourceUrl?: string;
componentId?: string;
componentType?: string;
traceId?: string;
}
interface ClickButtonEventPayload extends BasePayload {
action: "ButtonClick";
Expand Down Expand Up @@ -247,6 +251,7 @@ declare class MatomoAgent extends Agent {
readonly config: MatomoAgentConfig;
private get client();
private trackPageViewTimer;
private currentScene;
constructor(config: MatomoAgentConfig);
doInitialize(): Promise<void>;
report(event: SpyEvent): void;
Expand Down
5 changes: 5 additions & 0 deletions dist/index.esm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ interface BasePayload {
timestamp?: string;
codename?: string;
guestSessionId?: string;
sourceUrl?: string;
componentId?: string;
componentType?: string;
traceId?: string;
}
interface ClickButtonEventPayload extends BasePayload {
action: "ButtonClick";
Expand Down Expand Up @@ -247,6 +251,7 @@ declare class MatomoAgent extends Agent {
readonly config: MatomoAgentConfig;
private get client();
private trackPageViewTimer;
private currentScene;
constructor(config: MatomoAgentConfig);
doInitialize(): Promise<void>;
report(event: SpyEvent): void;
Expand Down
7 changes: 7 additions & 0 deletions dist/index.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.esm.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@
"affectsGlobalScope": false
},
"../src/trackingevent.ts": {
"version": 1,
"signature": "69949727099",
"version": 2,
"signature": "80457106564",
"affectsGlobalScope": false
},
"../src/types.ts": {
Expand Down Expand Up @@ -193,7 +193,7 @@
},
"../src/agent.ts": {
"version": 1,
"signature": "-31951521637",
"signature": "-57266381044",
"affectsGlobalScope": false
},
"../node_modules/@types/history/domutils.d.ts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "17media-browser-spy",
"version": "1.0.12",
"version": "1.0.15",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"license": "MIT",
Expand Down
8 changes: 7 additions & 1 deletion src/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { loadScript, loadScripts } from 'utils/loadScript';
import * as object from 'utils/object';
import { TrackingEvent, TransitionEvent, LoginEvent, SpyEvent } from 'types';
import { TrackingEvent, TransitionEvent, LoginEvent, SpyEvent, Scene } from 'types';
import type { analytics } from 'firebase';
import { isTrackingEvent as isV2TrackingEvent, TrackingEvent as V2TrackingEvent } from './TrackingEvent';
import * as params from './utils/param';
Expand Down Expand Up @@ -136,6 +136,8 @@ export class MatomoAgent extends Agent {

private trackPageViewTimer = 0;

private currentScene: Scene | null = null;

constructor(readonly config: MatomoAgentConfig) {
super();
}
Expand Down Expand Up @@ -178,11 +180,15 @@ export class MatomoAgent extends Agent {
this.requestTrackPageView();
this.client.push(['enableLinkTracking']);
this.client.push(['trackAllContentImpressions']);
this.currentScene = toScene;
}

private track(event: TrackingEvent | V2TrackingEvent) {
if (isV2TrackingEvent(event)) {
const { category, action, name } = event;
if (this.currentScene) {
event.payload.sourceUrl = this.currentScene.pathname;
}
const dimensions = params.createMatomoCustomDimensions(event);
this.client.push(['trackEvent', category, action, name, '', dimensions]);
return;
Expand Down
4 changes: 4 additions & 0 deletions src/TrackingEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export interface BasePayload {
timestamp?: string;
codename?: string;
guestSessionId?: string;
sourceUrl?: string;
componentId?: string;
componentType?: string;
traceId?: string;
}

interface ClickButtonEventPayload extends BasePayload {
Expand Down

0 comments on commit 912a3d9

Please sign in to comment.