Skip to content

Commit

Permalink
feat(tracking): changing referrer type and allowing it into be set vi…
Browse files Browse the repository at this point in the history
…a a parameter for tracking purposes

- Change Referrer to string type
- Allow parameters passed to tracking to change referrer, otherwise fallback on window.document.referrer
  • Loading branch information
weilintuye95 authored Aug 24, 2022
1 parent 3551842 commit 28b7a19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/tracking/src/events/track.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getClientType } from '../integrations/device';
/* eslint-disable no-console */
import type {
BaseEventData,
EventDataTypes,
TrackingOptions,
UserClickData,
Expand Down Expand Up @@ -48,7 +49,7 @@ export const createTracker = ({ apiBaseUrl, verbose }: TrackerOptions) => {
const event = <
Category extends keyof EventDataTypes,
Event extends string & keyof EventDataTypes[Category],
Data extends EventDataTypes[Category][Event]
Data extends EventDataTypes[Category][Event] & BaseEventData
>(
category: Category,
event: Event,
Expand All @@ -62,7 +63,7 @@ export const createTracker = ({ apiBaseUrl, verbose }: TrackerOptions) => {
path: window.location.pathname,
title: window.document.title,
url: window.location.href,
referrer: window.document.referrer,
referrer: userData.referrer || window.document.referrer,
client: getClientType(),
};

Expand Down
2 changes: 1 addition & 1 deletion packages/tracking/src/events/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export type BaseEventData = {
path?: null;
title?: null;
url?: null;
referrer?: null;
referrer?: string | null;

// properties set in the backend
id?: null; // maps to user id
Expand Down

0 comments on commit 28b7a19

Please sign in to comment.