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

Commit

Permalink
Add 'pushInstuction' method to useMatomo
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops committed Sep 2, 2020
1 parent fef83ef commit 68245b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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

0 comments on commit 68245b5

Please sign in to comment.