Skip to content

Releases: Swetrix/swetrix-js

v3.1.0

06 May 20:38
Compare
Choose a tag to compare

Changelog:
1. Introducing Error tracking! This release adds 2 new methods: trackErrors and trackError which allow you to track client-side errors on your websites.
2. Updated a few misc dependencies.

v3.0.3

31 Jan 22:44
Compare
Choose a tag to compare

Changelog:

  • Fix types for the v3.0.2 release.

For full v3 release notes see https://github.com/Swetrix/swetrix-js/releases/tag/v3.0.0

v3.0.2

31 Jan 22:39
Compare
Choose a tag to compare

Changelog:

  • trackViews callback - updated return type from IPageViewPayload to Partial<IPageViewPayload>

For full v3 release notes see https://github.com/Swetrix/swetrix-js/releases/tag/v3.0.0

v3.0.1

29 Jan 22:44
Compare
Choose a tag to compare

Changelog:

  • Fixed IPageViewPayload pg type

For full v3 release notes see https://github.com/Swetrix/swetrix-js/releases/tag/v3.0.0

v3.0.0

29 Jan 21:56
Compare
Choose a tag to compare

Changelog:

  • [BREAKING] Removed the noUserFlow, doNotAnonymise, ignore and noHeartbeat parameters for the trackViews function.
  • [BREAKING] The debug parameter for the init function has been removed. Instead, devMode is introduced. The only difference between debug and devMode is that messages are no longer printed to the console.
  • Introducing new trackViews optional parameter - callback. The callback is supposed to replace ignore parameter and give you more control over what data is tracked.
    The callback accepts the following object as it's only parameter:
interface IPageViewPayload {
  lc: string | undefined
  tz: string | undefined
  ref: string | undefined
  so: string | undefined
  me: string | undefined
  ca: string | undefined
  pg: string
  prev: string | null | undefined
}

The callback should return one of the following:

  • true - to send the pageview event as-is.
  • false - to prevent sending the payload.
  • An IPageViewPayload-like object - the object should contain the edited fields that will be assigned to the payload. For example, if your pg has some sensitive information (like /account/54345345), you can replace it with /account/redacted and return it as a callback result to be sent to the API. Note that the Swetrix script will append the callback result to an already existing payload, so if you're only returning pg - all the other parameters will be sent as is, if you'd like to overwrite them - you'll need to explicitly return them in the callback object.

Migration guide:

No changes in Swetrix config are needed unless you've been using the ignore parameter in the trackViews function.
If you were using ignore parameter in past - you may need to replace it with the callback instead. Here's an example on how you can do that.

Before upgrading to that version of Swetrix, your setup may look like this:

Swetrix.trackViews({
  ignore: [
    /^\/users\/(?!new$)[^/]+$/i,
    /^\/share/i,
    'some-other-page',
  ],
  heartbeatOnBackground: true,
  // any other parameters
})

After upgrading, you'll need to replace ignore with a callback and here's an example on how you can do that:

const checkIgnore = (path, ignore = []) => {
  for (let i = 0; i < ignore.length; ++i) {
    if (ignore[i] === path) return true
    if (ignore[i] instanceof RegExp && ignore[i].test(path)) return true
  }
 
  return false
}
 
const pathsToIgnore = [/^\/users\/(?!new$)[^/]+$/i, /^\/share/i, 'some-other-page']
 
Swetrix.trackViews({
  callback: ({ pg, prev }) => {
    const result = {
      pg,
      prev,
    }
 
    if (checkIgnore(pg, pathsToIgnore)) {
      // or you can return any other value to ignore this page
      // for example, returning null will display REDACTED for this page in your dashboard
      // but instead you can return something like 'users/:id' to group all users pages together
      result.pg = null
    }
 
    if (checkIgnore(prev, pathsToIgnore)) {
      // same as above
      result.prev = null
    }
 
    return result
  },
  heartbeatOnBackground: true,
})

v2.4.0

17 Oct 21:48
Compare
Choose a tag to compare

Changelog:

  • Added support for hash and search based routing (#10)
  • Exposing a new trackPageview function to manually track pageviews. (77ce797)

v2.3.1

14 Oct 02:35
Compare
Choose a tag to compare

Changelog:

  • (feature) Now you can track metadata with custom events by passing meta object into the track() funciton. (#8)

v2.3.0 - the 5 September 2023 Release

05 Sep 20:13
Compare
Choose a tag to compare

Changelog:

  • Added a doNotAnonymise parameter to trackViews function. It allows to not send paths from ignore list to API. If set to false, the page view information will be sent to the Swetrix API, but the page will be displayed as a 'Redacted page' in the dashboard.
  • Updated a few dependencies.

v2.2.1 - the 27 April 2023 Release

27 Apr 17:26
Compare
Choose a tag to compare

Changelog:

  • Fixed a bug when previous page was sent without validating it with ignore parameter first.

v2.2.0 - the 26 April 2023 Release

26 Apr 20:55
480ecfa
Compare
Choose a tag to compare

Changelog:

  • Added support for tracking user flow (by sending the previous page user was on to the server).
  • Added noUserFlow boolean parameter to PageViewsOptions. If you want to disable user flow tracking, just set this parameter to true. By default it's false which means that the user flow tracking is enabled.