npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@s-ui/ij-segment-wrapper

v2.6.0

Published

[![Build Status](https://travis.mpi-internal.com/scmspain/frontend-ij--segment-wrapper.svg?token=weuzuyzw6juAMe8gcwxy&branch=master)](https://travis.mpi-internal.com/scmspain/frontend-ij--segment-wrapper) ![](https://img.shields.io/badge/automatic-release

Downloads

2,569

Readme

Build Status

Jobs segment wrapper

Description

This wrapper sets up all needed tracking configurations

Features

Infojobs' Visitor ID

This library is in charge of loading the id used at infojobs to use as Adobes' Marketing Cloud Visitor Id integration when sending an event through Segment. This id is created here if it doesn't exist before and is saved in a cookie in order to be shared with the backend so they can reuse it. Check out the source code for deeper understanding of what it does exactly but the main idea is that the first time it will wait until adobes' visitor api is loaded and that id is used and cached.

if infojobs' visitor id saved in cookie
  return infojobs' visitor id cookie
otherwise
  wait while adobe's visitor api is loading
  if adobe's visitor api timed out or crashed
    generate uuid
    return generated uuid
  otherwise
    save adobe's visitor api id as infojob's visitor id cookie
    return adobe's visitor api id

Segment middlewares

Google Tag Manager Only

As the backend tracks user events after its second visit but we still want to send that information towards Google's Tag Manager we implemented a middleware. This middleware acts as a proxy, activating and deactivating destinations depending on the times the user has visited the page, the consents the user has given and if it is a event already tracked by the backend or not.

The output of each variation has been written down in this table:

https://docs.google.com/spreadsheets/d/1TSZkBXg1TdOaZmHFtseVwf9Dzz_AN0zE5tZkY9kk0SY/edit#gid=0

Usage

Load the script as first script in your page

<html>
<head>
  <script src="https://unpkg.com/@s-ui/ij-segment-wrapper/umd/index.js"></script>
</head>
<body>
  
</body>
</html>

Local dev

  1. Create new umd
> npm run umd:dev
  1. Open a http server serving the umd folder

⚠️ make sure the server runs in port 5000

> npx serve umd
  1. Open the production page and block the https://unpkg.com/@s-ui/ij-segment-wrapper/umd/index.js file

  2. Run this script to load this packages

var script = document.createElement('script');
script.src = 'http://localhost:5000/index.js'
body.append(script)

You can also test the library by publishing a new beta version. In order to do that:

  1. Put the -beta.0 suffix to your version
"version": "1.50.0-beta.0",
  1. Execute the publish command
> npm publish --tag beta
  1. Check this url https://unpkg.com/@s-ui/ij-segment-wrapper@beta/umd/index.js. In few minutes, it should be redirect to your beta version. In our case:
https://unpkg.com/@s-ui/ij-segment-wrapper@beta/umd/index.js

Release a new version

Once you have merged your changes, the @s-ui/ci tool will automatically release your component. Once this step is completed https://unpkg.com/@s-ui/ij-segment-wrapper/umd/index.js will need up to 20 minutes to update its cdn's cache and start deliver the new version.

Migration to v2

In the v2 version, the entryPoint is not automatically invoked inside the library, but you need to import and call it when loading your app.

import {entryPoint, makeGtmMiddleware} from '@s-ui/ij-segment-wrapper'

if (process.env.NODE_ENV !== 'test') {
  entryPoint({customSourceMiddlewares})
}

In some cases, you may want to also apply custom source middlewares. In this case, it is possible to pass an array of custom middlewares (be careful, custom destination middlewares are not supported yet in this library version) as shown in this example:

import {entryPoint, makeGtmMiddleware} from '@s-ui/ij-segment-wrapper'

const customSourceMiddlewares = [makeGtmMiddleware()]

if (process.env.NODE_ENV !== 'test') {
  entryPoint({customSourceMiddlewares})
}

The makeGtmMiddleware is a factory function that applies a gtmMiddleware, which forwards events only to the Google Tag Manager destination under specific conditions (you probably won't need to use it). In case of exceptional need, is possible to whitelist some events with this middleware and threat them as usual:

import {entryPoint, makeGtmMiddleware} from '@s-ui/ij-segment-wrapper'

const whitelist = [
  'MyCv Experience Form Viewed'
]

const customSourceMiddlewares = [makeGtmMiddleware({whitelist})]

if (process.env.NODE_ENV !== 'test') {
  entryPoint({customSourceMiddlewares})
}

Breaking changes

  • The entrypoint is not automatically invoked, you need to import it from the library and call it manually to initialize the segment wrapper.