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

@wostreaming/targeting-sdk

v2.0.0

Published

AmperWave Streaming JavaScript SDK for Targeting

Downloads

14

Readme

WideOrbit Streaming Targeting SDK

Installation

You must install the SDK from NPM even if you intend to include it directly as a <script> tag.

npm i @wostreaming/targeting-sdk

Quick Usage

const client = new WOSTargetingClient(1234, true);

function initializePlayer(params) {
	// Do something with `WOSTargetingParams` object
	const qs = params.toString({
		// ...Add extra parameters here if needed
	});

	// Notice that the `WOSTargetingParams` object can be
	// automatically cast to a string
	console.log(`?${qs}`);

	// Example output:
	// ?dnt=0&lptid=f412452b20820396319d8f35b14d96cb&ltids=99286%2C513599%2C513593%2C513421&privacypolicy=false&user-id=5a08398c-1b8f-5230-919f-a94dc36bb5b7
}

// NOTE: A call to `getTargetingParams()` should _always_ succeed, even if something goes really wrong
client.getTargetingParams().then(initializePlayer);

Including the SDK in your code

The provided SDK is built as a UMD module, making it compatible with any environment or development pattern. You can import or require the module in a bundled or transpiled Node app:

// ESM
import WOSTargetingClient from "@wostreaming/targeting-sdk";

// Node require
const WOSTargetingClient = require("@wostreaming/targeting-sdk");

Or if you prefer to use it as a standard <script> tag, that works too; but, you'll have to serve the script tag somehow. In the packaged release, it's available under the dist/wos-targeting-sdk.js path. You can serve it as a static file however you prefer.

Example express server

import express from "express";

const app = express();
app.use(
	"/static/js/wos-targeting-sdk.js",
	express.static(
		require.resolve("@wostreaming/targeting-sdk")
	)
);

app.listen(3000);

Example <script> tag

<script
	type="text/javascript"
	src="/static/js/wos-targeting-sdk.js">
</script>

When you include the script tag it will make a global variable accessible named WOSTargetingClient. The rest of the usage information applies regardless of how you include the SDK.

API

class WOSTargetingClient

# constructor(clientId: string, hasPrivacyPolicy: boolean)

  • clientId Your Lotame client ID as a string or int
  • hasPrivacyPolicy Have your users agreed to a privacy policy consenting to anonymized tracking and ad targeting?

# getAudienceInfo(): Promise

Returns a Promise that resolves with a Lotame Profile object containing the user's audience information for targeting. You generally shouldn't need to call this directly.

# getTargetingParams(): Promise

Returns a Promise that resolves with a WOSTargetingParams object for working with audience info parsed and managed by the WOS Targeting SDK.

NOTE: A call to getTargetingParams() should always succeed, even if something goes really wrong.


class WOSTargetingParams

# constructor(profile: Profile)

  • profile The Lotame Profile object

# toJSON(): Object -> getParams()

Alias of getParams()

# getParams(): Object

Returns an object of key -> value pairs representing the URL querystring parameters.

# setParams(paramsObj: Object = {})

Set additional parameters or override existing ones

# toString(additionalParams: Object = {})

Returns a URL encoded querystring with all the parameters managed by this object as well as optional additional parameters to override or add to the query string but not set on this object. This will properly filter out private information if dnt is overridden.