14.0.0 • Published 1 year ago

@dfds-platform/tracking v14.0.0

Weekly downloads
360
License
UNLICENSED
Repository
-
Last release
1 year ago

@dfds-platform/tracking

Installation

npm install @dfds-platform/tracking
yarn add @dfds-platform/tracking

Setup Google Tag Manager

When using the Tracking Package client side, tracking events are being dispatched to the dataLayer which is where Google Tag Manager picks up events. You have to setup Google Tag Manager to pick up evnets automatically from the dataLayer. You can follow these instructions. Alternatively, you can use an existing package to set up GTM. For example you can use this plugin in a Gatsby applicaiton. **GTM-WZLN3V4** is the Google Tag Manager ID you should use in both development and production.

Tracking events

You can track events multiple ways:

  1. Use the general tracking function track<Event>( {event: 'eventName' ...payload })

  2. ⚠️ THIS METHOD IS BEING DEPRECATED Use the old server tracking functions found within ./src/server/tracking-methods/events see this

Creating a new tracking event

New events should be created by the following method:

  1. Create an event in Stoplight
  2. Export Tracking.json
  3. Overwrite DataContract.json with the downloaded .json
  4. Run yarn run compile:schema within packages/tracking
  5. Create PR; merge; and publish changes

This will update the general tracking function to accept the new event.

Data contract

The data contract is a JSON schema which represents all the events that is accepted. The goal is that no tracking event should ever be instantiated within DFDS which is not defined within this schema. The schema is compiled into a TypeScript function type signature. This can be done by running:

yarn run compile:schema # within packages/tracking

This type contract is only being, and should only be, used by the general tracking function in this repository.

General tracking function

The general tracking function is responsible for two tasks:

  1. Making sure that events being triggered are correctly formatted by using the TypeScript function type signature which is derived from the JSON schema data contract.
  2. Dispatching events to two locations:

In the future all events will be dispatched to Kafka as well.

See deprecation events through linting

Every library consuming the tracking package should have eslint-plugin-deprecation installed such that deprecated events will be shown as follows:

track<Event>({ event: 'fizz' })

The strikethrough will be accompanied with a message on when the event will be obsolete and how change it to complie with a new version of the event, if any.

Developing using yarn link

It can be handy to use developing functionality in the context of an existing app. yarn link can be used in that case.

webpack

If you are using webpack you can try setting resolve.symlinks to false in your webpack.config.js to only resolve dependencies from the apps node_modules folder.

Gatsby

Gatsby uses webpack under the hood, so in order to set resolve.symlinks add the following to the gatsby-node.js file

exports.onCreateWebpackConfig = ({ getConfig, actions, stage }) => {
  const config = getConfig()
  config.resolve.symlinks = false
  actions.replaceWebpackConfig(config)
}

Setting up the link

cd ./packages/tracking # Navigate to the packages/tracking folder
yarn run build # Run build which will create a dist folder
yarn run watch # Run watch to watch for changes and re-build
cd ./dist # Navigate into the dist folder
yarn link # Run `yarn link`

You are now ready to use the linked package from within you app while developing. Change to you app source folder, where the package.json file is located, and use the linked version of the @dfds-platform/tracking package

yarn link @dfds-platform/tracking

Publishing new releases

This should always be done the GitHub repositories release page. Create a release here and an automized pipeline will do the rest for you.

Cypress tests for verify tracking

See docs for testing tracking here

10.0.0

1 year ago

11.0.0

1 year ago

12.0.0

1 year ago

12.0.2

1 year ago

13.0.0

1 year ago

9.0.0

1 year ago

9.1.0

1 year ago

14.0.0

1 year ago

5.4.0

1 year ago

7.0.0

1 year ago

7.2.3

1 year ago

7.2.2

1 year ago

7.2.0

1 year ago

8.0.0

1 year ago

4.0.0

1 year ago

5.0.1

1 year ago

5.2.0

1 year ago

6.0.1

1 year ago

6.0.0

1 year ago

5.3.0

1 year ago

7.1.0

1 year ago

3.1.0

1 year ago

3.3.0

1 year ago

3.2.0

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.4.1

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.8

2 years ago

2.0.3

2 years ago

1.5.9

2 years ago

1.5.8

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.2

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.9

2 years ago

1.3.7

2 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.9.8

3 years ago

0.9.9

3 years ago

0.9.7

3 years ago

0.9.6

3 years ago

0.9.5

3 years ago

0.9.4

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.8.9

3 years ago

0.8.8

3 years ago

0.8.7

3 years ago

0.8.6

3 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.8.1

3 years ago

0.8.0

4 years ago

0.7.9

4 years ago

0.7.8

4 years ago

0.7.7

4 years ago

0.7.6

4 years ago

0.7.5

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.9

4 years ago

0.6.8

4 years ago

0.6.7

4 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.8

4 years ago

0.3.9

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.7

4 years ago

0.2.8

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago