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

@evolv-delivery/audience

v1.0.2

Published

Allows audience filters to be populated from datalayer, cookie, fetch and dom

Downloads

23

Readme

Audience

The audience integration supports populating the Evolv context object with values that are extracted from the browser via several mechanisms.

Note: This package will no longer be supported

Please use @evolv-delivery/metrics instead. The metrics package includes all the features as the audience package and represents the future direction for this integration.

Setup in the Evolv Manager

Adding an integration to the Evolv Manager

Setting up the config json

The main requirements for the config are objects indexed by a context attribute where the objects contain source and key.

Top Level Structure

The top level keys of the json config indicate one of two things and both have object values.

  • The attribute key (to use in context) if the object value contains a source and key field that have string values.
  • A top level grouping if the object does not contain a source and key field. This will results in each attribute of the object representing a context attribute.

Context attribute objects

The following is a table showing the different types for the attributes:

| Source | Key (usage) | Description | | ---------- | ------------------------ | ------------------------------------------------------------------------------------------------------ | | query | name of query parameter | The value of the query parameter within th url | | expression | js expression | The experssion usually | | cookie | cookie name | Return value of cookie | | localStorage | localStorage key | Return value of localStorage key | | sessionStorage | sessionStorage key | Return value of sessionStorage key | | dom | css selector | Returns found if dom element exists on page | | jqdom | jqery selector | Returns found if dom element exists on page | | extension | name of extension | Currenty only one extension distribution: tracks a random value between 0-100 that persists for user | | fetch | url | This also includes additional data |

Other attribute options

page

If a page is specified, it's value represents a regex on the current url that if specified, the attribute will only be evaluated upon the page matching. This helps to focus page specific attributes that may be slow in retrieval.

type

If a type attribute is specified, it's value represents the type of the value of the attribute. By default, the type is assumed to be string. The following are the types available:

  • boolean
  • float
  • int
  • string
  • array

map

The map is represented as an array of objects that allows the value of the attribute to be transformed. Those mappings have one of 3 json keys:

  • when - a regex for testing the attribute value against
  • result - the new value to be bound to the attribute when conditional is met
  • default - default can be used as result as the last map value. There should be no when value for default.

storage

The storage is an object indicating that the value should be cached with the following options:

  • key - a required key that indicates the key to store and retrieve from storage (The integration will prefix this key with evolv: )
  • type - (local|session) indicating localStorage or sessionStorage (defaults to session)
  • resolveWith - (new|cached|union) indicates how to resolve which value to use when there is both a new value and a cached value. (defaults to new)

spa

If the spa value is set to true, the attribute will be reevaluated upon any spa based navigation.

poll

If a value is not imediately available when the integration is processed, a poll can be specified to periodically reevaluate the attribute until it is detected or poll duration expires.

default

This allows a value to be specified that will be added to the context imediately if the attribute is not available yet. It will be overriden if the poll is set and the value becomes available.

The config is read top to bottom. If a match is found, it stops. No fall-through, so in the example below if the path of the page starts with /home/, nothing will happen, because the statements block is an empty array.

Example

The following shows examples of each of the type and options available.


{
    "ctas": {
        "placeOrder": {
            "page": "sales/digital/expressCheckout",
            "source": "dom",
            "key": "button[aria-label*='Place order']",
            "poll": {
                "interval": 100,
                "duration": 5000
            }
        }
    },
    "omni": {
        "visitorId": {
            "source": "expression",
            "key": "window._satellite.getVisitorId()._fields.MCMID"
        }
    },
    "recognizedUser": {
        "source": "cookie",
        "key": "user",
        "type": "boolean",
        "default": false,
        "map": [
            {
                "result": true,
                "when": ".+"
            }
        ]
    },
    "campaign": {
        "source": {
            "source": "query",
            "key": "utm_source"
        },
        "medium": {
            "source": "query",
            "key": "utm_medium"
        }
    },
    "page": {
            "landingTag": {
                "source": "expression",
                "key": "location.pathname",
                "default": "none",
                "storage": {
                    "type": "session",
                    "key": "landingTag",
                    "resolveWith": "cached"
                },
                "map": [
                {
                    "result": "products",
                    "when": "/products/"
                }
                ]
            }
    }
}