Gathering detailed insights and metrics for @parameter1/base-cms-marko-web-native-x
Gathering detailed insights and metrics for @parameter1/base-cms-marko-web-native-x
Gathering detailed insights and metrics for @parameter1/base-cms-marko-web-native-x
Gathering detailed insights and metrics for @parameter1/base-cms-marko-web-native-x
npm install @parameter1/base-cms-marko-web-native-x
Typescript
Module System
Node Version
NPM Version
JavaScript (45.61%)
Vue (21.08%)
Marko (18.22%)
SCSS (14.7%)
HTML (0.19%)
Dockerfile (0.1%)
Shell (0.1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
10,653 Commits
9 Forks
4 Watchers
16 Branches
13 Contributors
Updated on Dec 09, 2024
Latest Version
4.80.0
Package Id
@parameter1/base-cms-marko-web-native-x@4.80.0
Unpacked Size
58.79 kB
Size
14.15 kB
File Count
51
NPM Version
lerna/6.5.1/node@v20.12.0+arm64 (darwin)
Node Version
20.12.0
Published on
Nov 15, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
NativeX components for BaseCMS/Marko websites.
All NativeX components rely upon an instance of the NativeXConfiguration class being provided. For ease of use, this configuration is typically set into the Express app locals via the start-server utility, but must be provided when querying for an advertisement or a story. This configuration defines (at minimum) the NativeX instance URI and the default template alias. If website section-based templates are in use, they must be defined after creation:
1const NativeXConfiguration = require('@parameter1/base-cms-marko-web-native-x/config');
2
3const config = new NativeXConfiguration('https://example.native-x.parameter1.com',
4 {
5 enabled: true,
6 defaultAlias: 'default',
7 }
8);
9
10// Configure a placement
11config.setPlacement({
12 alias: 'default',
13 name: 'default',
14 id: '5d4b04769f69b200013ab109',
15});
16
17// Configure multiple placements for an alias
18config.setAliasPlacements('my-custom-alias', [
19 { name: 'custom-placement-1', id: '95d4b04769f69b200013ab10' },
20 { name: 'custom-placement-2', id: '095d4b04769f69b200013ab1' },
21]);
22
23module.exports = config;
Rendering NativeX advertisements is typically done by using the <marko-web-native-x-render>
component. If NativeX is enabled, this component then uses the <marko-web-native-x-retrieve>
component to query NativeX for an advertisement. When an advertisement is available, the content node will be replaced by the ad details.
The render component requires the following properties:
config
: An instance of the NativeXConfiguration class.name
: The name of the placement to use (as defined by setPlacement
and setAliasPlacements
)aliases
: An array of active aliases to use. (See aliases below)node
: The content node that may become a NativeX ad.when
: A boolean. When truthy, the content node will be replaced by the ad (if available)sectionName
: Used by the conversion utilities. Because ads do not have website context, indicate the name of the primary section of the "content" (the ad, once replaced)When registering an placement, you must specify an alias. If you are not using any alias-aware placements, you should use the value default
for the alias field. This is the most common!
In an atypical website deployment, multiple NativeX placements may be used to further segment NativeX metrics. When a placement is requested, the supplied aliases are checked against registered placements. If a more specific placement exists, it is used preferentially over the default
placement with a matching name
.
For example, consider the following:
1const config = new NativeXConfiguration(...); 2 3// The default placement 4config.setPlacement({ alias: 'default', name: 'default', id: '5d4b04769f69b200013ab109' }); 5config.setPlacement({ alias: 'section-1', name: 'default', id: '95d4b04769f69b200013ab10' }); 6config.setPlacement({ alias: 'section-2', name: 'default', id: '095d4b04769f69b200013ab1' }); 7 8const aliases = ['section-1/child-section/grand-child', 'section-1/child-section', 'section-1']; 9 10const placement = config.getPlacement({ name: 'default', aliases }); 11console.log(placement.id); 12// 95d4b04769f69b200013ab10
To render a NativeX story in a consuming application, import the with-story
middleware. This middleware requires a NativeX configuration and a Marko template to render a response. It also supports sending a custom queryFragment
to return additional fields, if needed.
An Express route
1// my-site/routes/native-x-story.js
2const withNativeXStory = require('@parameter1/base-cms-marko-web-native-x/middleware/with-story.js');
3const config = require('../config/native-x');
4const template = require('../templates/native-x-story');
5
6module.exports = (app) => {
7 app.use('/some-path/:id', withNativeXStory({
8 config, // Required. An instance of the NativeXConfiguration class.
9 template, // Required. A Marko template used to render the story.
10 queryFragment, // Optional. A GraphQL query fragment specifying included fields.
11 }));
12};
A minimal Marko template
1<!-- my-site/templates/native-x-story.marko --> 2$ const { document } = out.global; 3$ const { story } = input; 4 5<${document}> 6 <@container> 7 <@page> 8 <if(imgSrc)> 9 <marko-web-img class="img-fluid" src=story.primaryImage.src /> 10 </if> 11 <h1>${story.title}</h1> 12 <if(story.teaser)> 13 <p>${story.teaser}</p> 14 </if> 15 <hr> 16 $!{story.body} 17 </@page> 18 </@container> 19</>
A GraphQL fragment definition
1// my-site/graphql/fragments/story.js 2 3const gql = require('graphql-tag'); 4 5module.exports = gql` 6 fragment MyCustomStoryFragment on Story { 7 id 8 title 9 campaigns { 10 totalCount 11 edges { 12 id 13 name 14 } 15 } 16 } 17`; 18
To utilize NativeX's story analytics, you must use the event tracking utility functions to send events to the NativeX GTM container.
The GTM container can be initialized by including the <marko-web-native-x-gtm-init>
component within your document
's <head>
:
1<${document}> 2 <@head> 3 <marko-web-native-x-gtm-init /> 4 </@head> 5</>
Before sending any events, make sure to include the <marko-web-native-x-story-track-init>
component. This component initializes the data layer with the story data that other events rely upon.
1<${document}> 2 <@head> 3 <marko-web-native-x-gtm-init /> 4 </@head> 5 <@page> 6 <marko-web-native-x-story-track-init story=story /> 7 </@page> 8</>
See examples of available events below. By default, including the <marko-web-native-x-story-track-page-view>
component will populate the datalayer with the story details. To disable this behavior, send the push=false
parameter when including the component. All other story components assume this has already happened -- to force population of the data layer, send the push=true
parameter when including the relevant component.
To send a page view, include the <marko-web-native-x-story-track-page-view>
and pass the story
property through (from the Nx middleware):
1$ const { story } = input; 2 3<${document}> 4 <@head> 5 <marko-web-native-x-gtm-init /> 6 </@head> 7 <@page> 8 <marko-web-native-x-story-track-page-view /> 9 <h1>${story.title}</h1> 10 </@page> 11</>
To automatically track outbound links, include the <marko-web-native-x-story-track-outbound-links>
component. This component requires a DOM selector in order to limit the tracking to a subset of links:
1$ const { story } = input; 2 3<${document}> 4 <@head> 5 <marko-web-native-x-gtm-init /> 6 </@head> 7 <@page> 8 <h1>${story.title}</h1> 9 <div id="my-story-body"> 10 <a href="https://google.com">This will be tracked when clicked!</a> 11 </div> 12 <marko-web-native-x-story-track-outbound-links container="#my-story-body" /> 13 </@page> 14</>
If using the marko-web-social-sharing package, you can automatically track any share attempts by including the <marko-web-native-x-story-track-social-share>
component in your story template:
1$ const { story } = input; 2 3<${document}> 4 <@head> 5 <marko-web-native-x-gtm-init /> 6 </@head> 7 <@page> 8 <marko-web-native-x-story-track-social-share /> 9 <h1>${story.title}</h1> 10 <marko-web-social-sharing path=story.url providers=["facebook", "email"] /> 11 </@page> 12</>
To automatically track when the user reaches the bottom of the page, include the <marko-web-native-x-story-track-end-of-content>
component below your story. This event will fire when the element comes into view:
1$ const { story } = input; 2 3<${document}> 4 <@head> 5 <marko-web-native-x-gtm-init /> 6 </@head> 7 <@page> 8 <h1>${story.title}</h1> 9 <p>...</p> 10 <p>...</p> 11 <p>...</p> 12 <marko-web-native-x-story-track-end-of-content /> 13 </@page> 14</>
You can also send an event directly by using one of the available utility functions:
1<script> 2import { endOfContent } from "@parameter1/base-cms-marko-web-native-x/utils/gtm-events"; 3 4export default { 5 created() { 6 endOfContent(); 7 } 8}; 9</script>
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
packaging workflow detected
Details
Reason
SAST tool is run on all commits
Details
Reason
Found 3/14 approved changesets -- score normalized to 2
Reason
project is archived
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
61 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More