Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Add 'pushInstuction' method to useMatomo #242

Merged
merged 1 commit into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ Prefix the change with one of these keywords:
- _Fixed_: for any bug fixes.
- _Security_: in case of vulnerabilities.


## [Unreleased]

- Fixed: Made `trackPageView` `params` argument optional
- Fixed: The `params` argument for the `trackPageView` method is now optional
- Fixed: The `pushInstruction` method is now exposed through `useMatomo`

## [0.2.0]

Expand Down
1 change: 1 addition & 0 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface MatomoInstance {
trackPageView?: MatomoTracker['trackPageView']
trackSiteSearch?: MatomoTracker['trackSiteSearch']
trackLink?: MatomoTracker['trackLink']
pushInstruction?: MatomoTracker['pushInstruction']
}

export type InstanceParams = types.UserOptions
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/useMatomo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ function useMatomo() {

const enableLinkTracking = () => useOutboundClickListener(instance)

const pushInstruction = (name: string, ...args: any[]) => {
if (instance.pushInstruction) {
instance.pushInstruction(name, ...args)
}
}

return {
trackEvent,
trackEvents,
trackPageView,
trackSiteSearch,
trackLink,
enableLinkTracking,
pushInstruction,
}
}

Expand Down