Skip to main content

Orion Context

Below you will find the various contexts Orion uses in the client side run time. At this time this is the only method to relay these values to Orion so this data must be exposed client side and provided to the Orion library either via any of the calls below. In addition to the fields below Orion tracks additional data automatically.


const implementationContext = {
// your context here
};

orion.init({context: implementationContext });
// or
orion.setConfig({ context: implementationContext });
// or
orion.setContext(implementationContext);

Page Metadata

Top Level Key: page

The Page Context represents the desired page context for the current page in Orion.

Properties

  • contentId (type: string | null, optional): The ID of the content from the client/customer database.
  • pageType (type: string | null, optional): The page type of the current page view. Generally, this will be a unique designation for the content type (e.g., "home", "article", "video", "gallery", etc.).
  • datePosted (type: string | Date | null, optional): The date the current content was posted/published. This value will be used to determine the age of the content. Important: This value should be in UTC time.
  • dateModified (type: string | Date | null, optional): The date the current content was last modified. Important: This value should be in UTC time.
  • wordCount (type: number | null, optional): The word count of the content in the current page view.
  • premium (type: boolean | null, optional): Designation for the content as paid or free.
  • primaryCategory (type: (type: Term | null, optional): The primary category of the current page view. This value will be used to determine the primary category of the content.
  • categories (type: (type: Term[] | null, optional): The categories for the current page view. This should include the primary category as well.
  • keywords (type: Term[] | null, optional): The tags/keywords for the current page view.

Term

The Term context represents a single taxonomy term.

Properties
  • id (type: string): The ID of the term from the client/customer database.
  • name (type: string): The display name of the term from the client/customer database.

Channel

Top Level Key: channel

Channel represents the desired channel context for the current page in Orion. It allows customized breakdowns for data related to a page on a site. The values for each channel are defined by the implementation. The custom channel structure is divided into a maximum of 4 hierarchical rank parts.

Read more about the channel context here.

For simplicity Orion will automatically parse channel strings delimitted by slashes. Example:

orion.setContext("channel", "sports/football/nfl/patriots");
// or
orion.setContext({channel: "sports/football/nfl/patriots"});

console.log(orion.getContext("channel"));
/*
{
hr1: {slug: 'sports'},
hr2: {slug: 'football'},
hr3: {slug: 'nfl' },
hr4: {slug: 'patriots' }
}
**/
Properties ( if as object )
  • hr1 (type: Channel Part): Channel part with the highest hierarchical rank of 1.
  • hr2 (type: Channel Part): Channel part with the second highest hierarchical rank of 2.
  • hr3 (type: Channel Part): Channel part with the 3rd highest hierarchical rank of 3.
  • hr4 (type: Channel Part): Channel part with the lowest hierarchical rank of 4.

Channel Part

The Channel Part type alias represents a channel part, which can be a string or an expanded structure. The default value is null.

Possible Types
  • string: A channel part represented as a string.
  • Channel Part Expanded: An expanded structure for a channel part.
  • null: The default value.

Channel Part Expanded

The Channel Part Expanded represents an expanded object structure for a channel part.

Properties

  • slug (type: string): The slug of the channel part.

Network

Top Level Key: network

The Network context is used to identify the current site and parent entities. This breakdown is used to provide access controls to data within the Spiny app. Read more about the network context here.

Properties

  • network (type: string, optional): The network ID used to identify the current network. This should be the topmost breakout of a site's parent entity/org.
  • subnetwork (type: string, optional): The subnetwork is an optional breakout for when a domain's parent entity is part of a suborganization.
  • domain (type: string, optional): The domain used to identify the current site. This should be the top-level domain of the current page without any subdomain.
  • subproperty (type: string, optional): The subproperty is an optional breakout for when a site is a subdomain or a separate entity as part of a parent site.

Here's the markdown documentation for the additional interfaces:

Author

Top Level Key: author

The Author context represents information about the author from the client/customer database.

Properties
  • authorId (type: number | null, optional): The ID of the author from the client/customer database.
  • authorName (type: string | null, optional): The username of the author from the client/customer database.

User

Top Level Key: user

The User context represents information about the user from the client/customer database.

Properties
  • userStatus (type: string | null, optional): The status of the user from the client/customer database. Generally, this is used to indicate subscription tiers, guest, and registered status.

Subscriptions

Top Level Key: subscriptions

The Subscriptions context represents a subscription object used to pass the current subscription context to Orion.

Properties

  • planId (type: string | null, optional): The ID of the subscription from the client/customer database.
  • name (type: string | null, optional): The name of the current user's subscription. Example values include Platinum, Gold, etc.
  • active (type: boolean | null, optional): The active state of the current user's subscription.
  • attributes (type: null | { freeTrial?: boolean | null; error?: boolean | null; errorId?: string | null; cancelled?: boolean | null; expired?: boolean | null; }, optional): Attributes of the current user's subscription.
  • term (type: string | null, optional): The type of the current user's subscription. Example values include monthly, annual, etc.
  • price (type: string | number | null, optional): The price of the current user's subscription without any discounts applied.
  • actualPrice (type: string | number | null, optional): The price of the current user's subscription with discounts applied.
  • currency (type: string | null, optional): The currency of the current user's subscription.
  • packages (type: Package[] | null, optional): The packages included in the current user's subscription.
  • promotions (type: Promotion[] | null, optional): The promotions available to the current user.

Promotion

The Promotion context represents a promotion object to track promotions available to the current user.

Properties
  • name (type: string | null, optional): The name of the promotion.
  • id (type: string | null, optional): The ID of the promotion from the client/customer database.
  • active (type: boolean | null, optional): Whether the promotion is currently active or not.
  • attributes (type: null | { expired?: boolean | null; eligible?: boolean | null; activeOnSignup?: boolean | null; error?: boolean | null; errorId?: string | null; }, optional): Attributes belonging to the promotion.

Package

The Package context represents a package object to track the current user's packages.

Properties
  • id (type: string | null, optional): The ID of the package from the client/customer database.
  • name (type: string | null, optional): The name of the package from the client/customer database.

Custom Test

Top Level Key: customtest

The Custom Test represents a custom AB Test object used to track a site-side AB test.

Properties

  • tests (type: Array<{ id: string; category?: string; subcategory?: string; test?: boolean; control?: boolean; }>) : Array of AB tests.

Example

A full context example can be seen below.

orion.setContext({
page: {
contentId: "42", // ID of the content from the client/customer database
pageType: "article", // Page type of the current page view, representing a spaceship article
datePosted: "2023-06-27T17:00:00.000Z", // Date the content was posted/published
dateModified: "2023-06-28T12:00:00.000Z", // Date the content was last modified
wordCount: 5000, // Word count of the content (long and detailed article)
premium: false, // Designation for the content as free
primaryCategory: { // Primary category of the current page view
id: "cat456", // ID of the category from the client/customer database
name: "Interstellar Travel" // Display name of the category
},
categories: [ // Categories for the current page view (including primary category)
{ id: "cat456", name: "Interstellar Travel" },
{ id: "cat789", name: "Alien Encounters" }
],
keywords: [ // Tags/keywords for the current page view
{ id: "tag123", name: "Warp Drive" },
{ id: "tag456", name: "Exoplanets" },
{ id: "tag789", name: "Extraterrestrial Life" }
]
},
user: {
userStatus: "subscriber", // Status of the user from the client/customer database
},
author: {
authorId: 1234, // ID of the author from the client/customer database
authorName: "greedo" // Username of the author from the client/customer database (a skilled wordsmith in the galaxy)
},
channel: "technology/spaceships/aliens",
network: {
network: "galacticfederation", // The network ID representing the current network (Galactic Federation)
subnetwork: "earthdivision", // The subnetwork representing the Earth division within the Galactic Federation
domain: "spaceshipacademy.com", // The domain representing the current site (Spaceship Academy)
subproperty: null // The subproperty representing a subdomain or separate entity (no value)
},
customtest: {
tests: [
{
id: "test001", // Unique ID of the AB test in the customer's system
category: "teleportation", // Optional category of the AB test
subcategory: "advanced", // Optional subcategory of the AB test
test: true, // Boolean indicating the user is in the test
control: false // Boolean indicating the user is not in the control
},
{
id: "test002",
category: "timeTravel",
test: false,
control: true
}
]
},
subscriptions: [
{
planId: "ultimateplan", // ID of the subscription from the client/customer database
name: "Infinity Plus", // Name of the current user's subscription
active: true, // Active state of the current user's subscription
attributes: {
freeTrial: false, // Whether the current user's subscription is a free trial or not
error: false, // Whether the current user's subscription has an error or not
errorId: null, // The ID of the error for the current user's subscription (no error)
cancelled: false, // Whether the current user's subscription has been cancelled or not
expired: false // Whether the current user's subscription has expired or not
},
term: "annual", // Type of the current user's subscription (annual)
price: 99.99, // Price of the current user's subscription without any discounts applied
actualPrice: 79.99, // Price of the current user's subscription with discounts applied
currency: "USD", // Currency of the current user's subscription (US Dollars)
packages: [
{ id: "pkg001", name: "Space Explorer" }, // Package included in the current user's subscription
{ id: "pkg002", name: "Stellar Navigator" }
],
promotions: [
{ name: "Galaxy Plus", id: "promo001", active: true }, // Promotions available to the current user
{ name: "Celestial Deluxe", id: "promo002", active: false }
]
}
]
})