Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wostreaming/targeting-sdk

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wostreaming/targeting-sdk

AmperWave Streaming JavaScript SDK for Targeting

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 12 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc