@mindful-web/marko-web-native-x 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.eslintignore +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +243 -0
  4. package/apollo/create-client.js +42 -0
  5. package/apollo/graphql/fragments/image.js +12 -0
  6. package/apollo/graphql/fragments/publisher-stories.js +20 -0
  7. package/apollo/graphql/fragments/related-stories.js +20 -0
  8. package/apollo/graphql/fragments/story.js +24 -0
  9. package/apollo/graphql/queries/publisher-stories.js +19 -0
  10. package/apollo/graphql/queries/related-stories.js +19 -0
  11. package/apollo/graphql/queries/story.js +15 -0
  12. package/browser/.eslintrc.js +1 -0
  13. package/browser/index.js +10 -0
  14. package/browser/track-end-of-content.vue +20 -0
  15. package/browser/track-outbound-links.vue +26 -0
  16. package/browser/track-social-share.vue +23 -0
  17. package/components/fetch-elements.marko +21 -0
  18. package/components/fetch-elements.marko.js +58 -0
  19. package/components/gtm-init.marko +21 -0
  20. package/components/gtm-init.marko.js +60 -0
  21. package/components/init.marko +35 -0
  22. package/components/init.marko.js +63 -0
  23. package/components/marko.json +72 -0
  24. package/components/publisher-stories.marko +64 -0
  25. package/components/publisher-stories.marko.js +96 -0
  26. package/components/render.marko +33 -0
  27. package/components/render.marko.js +75 -0
  28. package/components/retrieve.marko +44 -0
  29. package/components/retrieve.marko.js +94 -0
  30. package/components/story/advertiser-related-stories.marko +51 -0
  31. package/components/story/advertiser-related-stories.marko.js +84 -0
  32. package/components/story/track-end-of-content.marko +1 -0
  33. package/components/story/track-end-of-content.marko.js +30 -0
  34. package/components/story/track-init.marko +13 -0
  35. package/components/story/track-init.marko.js +45 -0
  36. package/components/story/track-outbound-links.marko +3 -0
  37. package/components/story/track-outbound-links.marko.js +32 -0
  38. package/components/story/track-page-view.marko +1 -0
  39. package/components/story/track-page-view.marko.js +32 -0
  40. package/components/story/track-social-share.marko +1 -0
  41. package/components/story/track-social-share.marko.js +30 -0
  42. package/config.js +94 -0
  43. package/marko.json +6 -0
  44. package/middleware/with-story.js +35 -0
  45. package/package.json +32 -0
  46. package/services/fetch-elements.js +22 -0
  47. package/utils/convert-ad-to-content.js +39 -0
  48. package/utils/convert-ad-to-node.js +6 -0
  49. package/utils/convert-story-to-content.js +44 -0
  50. package/utils/create-headers.js +7 -0
  51. package/utils/gtm-events.js +20 -0
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ *.marko.js
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Parameter1 LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,243 @@
1
+ # Mindful Web Marko Web NativeX Components
2
+ NativeX components for Mindful Web/Marko websites.
3
+
4
+ ## Configuration
5
+
6
+ All NativeX components rely upon an instance of the [NativeXConfiguration](config.js) class being provided. For ease of use, this configuration is typically set into the Express app locals via the [start-server](../marko-web/start-server.js) 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:
7
+ ```js
8
+ const NativeXConfiguration = require('@mindful-web/marko-web-native-x/config');
9
+
10
+ const config = new NativeXConfiguration('https://example.native-x.parameter1.com',
11
+ {
12
+ enabled: true,
13
+ defaultAlias: 'default',
14
+ }
15
+ );
16
+
17
+ // Configure a placement
18
+ config.setPlacement({
19
+ alias: 'default',
20
+ name: 'default',
21
+ id: '5d4b04769f69b200013ab109',
22
+ });
23
+
24
+ // Configure multiple placements for an alias
25
+ config.setAliasPlacements('my-custom-alias', [
26
+ { name: 'custom-placement-1', id: '95d4b04769f69b200013ab10' },
27
+ { name: 'custom-placement-2', id: '095d4b04769f69b200013ab1' },
28
+ ]);
29
+
30
+ module.exports = config;
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ### Advertisements
36
+
37
+ 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.
38
+
39
+ The render component requires the following properties:
40
+ - `config`: An instance of the NativeXConfiguration class.
41
+ - `name`: The name of the placement to use (as defined by `setPlacement` and `setAliasPlacements`)
42
+ - `aliases`: An array of active aliases to use. (See aliases below)
43
+ - `node`: The content node that may become a NativeX ad.
44
+ - `when`: A boolean. When truthy, the content node will be replaced by the ad (if available)
45
+ - `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)
46
+
47
+ #### Aliases
48
+
49
+ 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!
50
+
51
+ 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`.
52
+
53
+ For example, consider the following:
54
+ ```js
55
+ const config = new NativeXConfiguration(...);
56
+
57
+ // The default placement
58
+ config.setPlacement({ alias: 'default', name: 'default', id: '5d4b04769f69b200013ab109' });
59
+ config.setPlacement({ alias: 'section-1', name: 'default', id: '95d4b04769f69b200013ab10' });
60
+ config.setPlacement({ alias: 'section-2', name: 'default', id: '095d4b04769f69b200013ab1' });
61
+
62
+ const aliases = ['section-1/child-section/grand-child', 'section-1/child-section', 'section-1'];
63
+
64
+ const placement = config.getPlacement({ name: 'default', aliases });
65
+ console.log(placement.id);
66
+ // 95d4b04769f69b200013ab10
67
+ ```
68
+
69
+
70
+ ### Stories
71
+
72
+ 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.
73
+
74
+ An Express route
75
+ ```js
76
+ // my-site/routes/native-x-story.js
77
+ const withNativeXStory = require('@mindful-web/marko-web-native-x/middleware/with-story.js');
78
+ const config = require('../config/native-x');
79
+ const template = require('../templates/native-x-story');
80
+
81
+ module.exports = (app) => {
82
+ app.use('/some-path/:id', withNativeXStory({
83
+ config, // Required. An instance of the NativeXConfiguration class.
84
+ template, // Required. A Marko template used to render the story.
85
+ queryFragment, // Optional. A GraphQL query fragment specifying included fields.
86
+ }));
87
+ };
88
+ ```
89
+
90
+ A minimal Marko template
91
+ ```marko
92
+ <!-- my-site/templates/native-x-story.marko -->
93
+ $ const { document } = out.global;
94
+ $ const { story } = input;
95
+
96
+ <${document}>
97
+ <@container>
98
+ <@page>
99
+ <if(imgSrc)>
100
+ <marko-web-img class="img-fluid" src=story.primaryImage.src />
101
+ </if>
102
+ <h1>${story.title}</h1>
103
+ <if(story.teaser)>
104
+ <p>${story.teaser}</p>
105
+ </if>
106
+ <hr>
107
+ $!{story.body}
108
+ </@page>
109
+ </@container>
110
+ </>
111
+ ```
112
+
113
+ A GraphQL fragment definition
114
+ ```js
115
+ // my-site/graphql/fragments/story.js
116
+
117
+ const gql = require('graphql-tag');
118
+
119
+ module.exports = gql`
120
+ fragment MyCustomStoryFragment on Story {
121
+ id
122
+ title
123
+ campaigns {
124
+ totalCount
125
+ edges {
126
+ id
127
+ name
128
+ }
129
+ }
130
+ }
131
+ `;
132
+
133
+ ```
134
+ #### Event Tracking and analytics
135
+
136
+ To utilize NativeX's story analytics, you must use the event tracking [utility functions](utils/gtm-events) to send events to the NativeX GTM container.
137
+
138
+ The GTM container can be initialized by including the `<marko-web-native-x-gtm-init>` component within your `document`'s `<head>`:
139
+ ```marko
140
+ <${document}>
141
+ <@head>
142
+ <marko-web-native-x-gtm-init />
143
+ </@head>
144
+ </>
145
+ ```
146
+ 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.
147
+ ```marko
148
+ <${document}>
149
+ <@head>
150
+ <marko-web-native-x-gtm-init />
151
+ </@head>
152
+ <@page>
153
+ <marko-web-native-x-story-track-init story=story />
154
+ </@page>
155
+ </>
156
+ ```
157
+
158
+ 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.
159
+
160
+ ##### Page View
161
+ 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):
162
+ ```marko
163
+ $ const { story } = input;
164
+
165
+ <${document}>
166
+ <@head>
167
+ <marko-web-native-x-gtm-init />
168
+ </@head>
169
+ <@page>
170
+ <marko-web-native-x-story-track-page-view />
171
+ <h1>${story.title}</h1>
172
+ </@page>
173
+ </>
174
+ ```
175
+
176
+ ##### Outbound Links
177
+ 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:
178
+ ```marko
179
+ $ const { story } = input;
180
+
181
+ <${document}>
182
+ <@head>
183
+ <marko-web-native-x-gtm-init />
184
+ </@head>
185
+ <@page>
186
+ <h1>${story.title}</h1>
187
+ <div id="my-story-body">
188
+ <a href="https://google.com">This will be tracked when clicked!</a>
189
+ </div>
190
+ <marko-web-native-x-story-track-outbound-links container="#my-story-body" />
191
+ </@page>
192
+ </>
193
+ ```
194
+
195
+ ##### Social Sharing
196
+ If using the [marko-web-social-sharing](../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:
197
+ ```marko
198
+ $ const { story } = input;
199
+
200
+ <${document}>
201
+ <@head>
202
+ <marko-web-native-x-gtm-init />
203
+ </@head>
204
+ <@page>
205
+ <marko-web-native-x-story-track-social-share />
206
+ <h1>${story.title}</h1>
207
+ <marko-web-social-sharing path=story.url providers=["facebook", "email"] />
208
+ </@page>
209
+ </>
210
+ ```
211
+
212
+ ##### End of content
213
+ 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:
214
+ ```marko
215
+ $ const { story } = input;
216
+
217
+ <${document}>
218
+ <@head>
219
+ <marko-web-native-x-gtm-init />
220
+ </@head>
221
+ <@page>
222
+ <h1>${story.title}</h1>
223
+ <p>...</p>
224
+ <p>...</p>
225
+ <p>...</p>
226
+ <marko-web-native-x-story-track-end-of-content />
227
+ </@page>
228
+ </>
229
+ ```
230
+
231
+ ##### Manual/advanced implementations
232
+ You can also send an event directly by using one of the available utility functions:
233
+ ```vue
234
+ <script>
235
+ import { endOfContent } from "@mindful-web/marko-web-native-x/utils/gtm-events";
236
+
237
+ export default {
238
+ created() {
239
+ endOfContent();
240
+ }
241
+ };
242
+ </script>
243
+ ```
@@ -0,0 +1,42 @@
1
+ const fetch = require('node-fetch');
2
+ const { get } = require('@mindful-web/object-path');
3
+
4
+ const getOperationName = (string) => {
5
+ const matches = /query\s+([a-z0-9]+)[(]?.+{/gi.exec(string);
6
+ if (matches && matches[1]) return matches[1];
7
+ return undefined;
8
+ };
9
+
10
+ module.exports = (uri) => Object.create({
11
+ query: async ({ query, variables, headers }) => {
12
+ const body = JSON.stringify({
13
+ operationName: getOperationName(query),
14
+ variables,
15
+ query: get(query, 'loc.source.body', query),
16
+ });
17
+
18
+ const res = await fetch(uri, {
19
+ method: 'POST',
20
+ headers: {
21
+ ...headers,
22
+ 'content-type': 'application/json',
23
+ },
24
+ body,
25
+ });
26
+ const json = await res.json();
27
+ if (!res.ok || (json && json.errors)) {
28
+ if (!json || !json.errors) {
29
+ const err = new Error(`An unknown, fatal GraphQL error was encountered (${res.status})`);
30
+ err.statusCode = res.status;
31
+ throw err;
32
+ }
33
+ const [networkError] = json.errors;
34
+ const err = new Error(networkError.message);
35
+ const { extensions } = networkError;
36
+ if (extensions) err.code = extensions.code;
37
+ if (extensions && extensions.exception) err.statusCode = extensions.exception.statusCode;
38
+ throw err;
39
+ }
40
+ return json;
41
+ },
42
+ });
@@ -0,0 +1,12 @@
1
+ const gql = require('graphql-tag');
2
+
3
+ module.exports = gql`
4
+ fragment ImageFragment on Image {
5
+ id
6
+ src
7
+ focalPoint {
8
+ x
9
+ y
10
+ }
11
+ }
12
+ `;
@@ -0,0 +1,20 @@
1
+ const gql = require('graphql-tag');
2
+ const imageFragment = require('./image');
3
+
4
+ module.exports = gql`
5
+ fragment DefaultPublishedStoriesFragment on Story {
6
+ id
7
+ title
8
+ teaser
9
+ url
10
+ publishedAt
11
+ primaryImage {
12
+ ...ImageFragment
13
+ }
14
+ advertiser {
15
+ id
16
+ name
17
+ }
18
+ }
19
+ ${imageFragment}
20
+ `;
@@ -0,0 +1,20 @@
1
+ const gql = require('graphql-tag');
2
+ const imageFragment = require('./image');
3
+
4
+ module.exports = gql`
5
+ fragment DefaultRelatedStoryFragment on Story {
6
+ id
7
+ title
8
+ teaser
9
+ url
10
+ publishedAt
11
+ primaryImage {
12
+ ...ImageFragment
13
+ }
14
+ advertiser {
15
+ id
16
+ name
17
+ }
18
+ }
19
+ ${imageFragment}
20
+ `;
@@ -0,0 +1,24 @@
1
+ const gql = require('graphql-tag');
2
+ const imageFragment = require('./image');
3
+
4
+ module.exports = gql`
5
+ fragment DefaultStoryFragment on Story {
6
+ id
7
+ title
8
+ teaser
9
+ body
10
+ url
11
+ publishedAt
12
+ primaryImage {
13
+ ...ImageFragment
14
+ }
15
+ advertiser {
16
+ id
17
+ name
18
+ logo {
19
+ ...ImageFragment
20
+ }
21
+ }
22
+ }
23
+ ${imageFragment}
24
+ `;
@@ -0,0 +1,19 @@
1
+ const { extractFragmentData } = require('@mindful-web/web-common/utils');
2
+ const gql = require('graphql-tag');
3
+
4
+ module.exports = (queryFragment) => {
5
+ const { spreadFragmentName, processedFragment } = extractFragmentData(queryFragment);
6
+ return gql`
7
+ query MarkoWebPublisherStories($input: PublisherStoriesInput!, $pagination: PaginationInput, $sort: StorySortInput) {
8
+ publisherStories(input: $input, pagination: $pagination, sort: $sort) {
9
+ edges {
10
+ node {
11
+ id
12
+ ${spreadFragmentName}
13
+ }
14
+ }
15
+ }
16
+ }
17
+ ${processedFragment}
18
+ `;
19
+ };
@@ -0,0 +1,19 @@
1
+ const { extractFragmentData } = require('@mindful-web/web-common/utils');
2
+ const gql = require('graphql-tag');
3
+
4
+ module.exports = (queryFragment) => {
5
+ const { spreadFragmentName, processedFragment } = extractFragmentData(queryFragment);
6
+ return gql`
7
+ query MarkoWebRelatedAdvertiserStories($input: AdvertiserStoriesInput!) {
8
+ advertiserStories(input: $input) {
9
+ edges {
10
+ node {
11
+ id
12
+ ${spreadFragmentName}
13
+ }
14
+ }
15
+ }
16
+ }
17
+ ${processedFragment}
18
+ `;
19
+ };
@@ -0,0 +1,15 @@
1
+ const { extractFragmentData } = require('@mindful-web/web-common/utils');
2
+ const gql = require('graphql-tag');
3
+
4
+ module.exports = (queryFragment) => {
5
+ const { spreadFragmentName, processedFragment } = extractFragmentData(queryFragment);
6
+ return gql`
7
+ query MarkoWebStoryPage($input: PublishedStoryInput!) {
8
+ publishedStory(input: $input) {
9
+ id
10
+ ${spreadFragmentName}
11
+ }
12
+ }
13
+ ${processedFragment}
14
+ `;
15
+ };
@@ -0,0 +1 @@
1
+ module.exports = require('../../../eslintrc.browser');
@@ -0,0 +1,10 @@
1
+ const NativeXTrackEndOfContent = () => import(/* webpackChunkName: "native-x-track-end-of-content" */ './track-end-of-content.vue');
2
+ const NativeXTrackSocialShare = () => import(/* webpackChunkName: "native-x-track-social-share" */ './track-social-share.vue');
3
+ const NativeXTrackOutboundLinks = () => import(/* webpackChunkName: "native-x-track-outbound-links" */ './track-outbound-links.vue');
4
+
5
+ export default (Browser) => {
6
+ const { EventBus } = Browser;
7
+ Browser.register('NativeXTrackEndOfContent', NativeXTrackEndOfContent);
8
+ Browser.register('NativeXTrackSocialShare', NativeXTrackSocialShare, { provide: { EventBus } });
9
+ Browser.register('NativeXTrackOutboundLinks', NativeXTrackOutboundLinks);
10
+ };
@@ -0,0 +1,20 @@
1
+ <template>
2
+ <div id="native-x-end-of-content" />
3
+ </template>
4
+
5
+ <script>
6
+ import { endOfContent } from '../utils/gtm-events';
7
+
8
+ export default {
9
+ created() {
10
+ this.observer = new IntersectionObserver((event) => {
11
+ if (event[0].isIntersecting) {
12
+ endOfContent();
13
+ }
14
+ });
15
+ },
16
+ mounted() {
17
+ this.observer.observe(this.$el);
18
+ },
19
+ };
20
+ </script>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <div />
3
+ </template>
4
+
5
+ <script>
6
+ import { outboundLink } from '../utils/gtm-events';
7
+
8
+ export default {
9
+ props: {
10
+ container: {
11
+ type: String,
12
+ required: true,
13
+ },
14
+ },
15
+ created() {
16
+ const elements = document.querySelectorAll(`${this.container} a[href]`);
17
+ elements.forEach((element) => {
18
+ const url = element.getAttribute('href');
19
+ element.addEventListener('click', (e) => {
20
+ e.preventDefault();
21
+ outboundLink(url);
22
+ });
23
+ });
24
+ },
25
+ };
26
+ </script>
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <div />
3
+ </template>
4
+
5
+ <script>
6
+ import { share } from '../utils/gtm-events';
7
+
8
+ export default {
9
+ inject: ['EventBus'],
10
+ props: {
11
+ eventName: {
12
+ type: String,
13
+ default: 'social-share-open',
14
+ },
15
+ },
16
+ created() {
17
+ this.EventBus.$on(this.eventName, (event) => {
18
+ const provider = event && event.provider && event.provider.name ? event.provider.name : null;
19
+ if (provider) share(provider);
20
+ });
21
+ },
22
+ };
23
+ </script>
@@ -0,0 +1,21 @@
1
+ import { warn } from "@mindful-web/utils";
2
+ import fetchElements from "../services/fetch-elements";
3
+
4
+ $ const { req } = out.global;
5
+
6
+ $ const { uri, id, opts } = input;
7
+ $ const args = {
8
+ uri,
9
+ placementId: id,
10
+ opts,
11
+ req,
12
+ };
13
+
14
+ <if(uri && id)>
15
+ <marko-web-resolve|{ resolved }| promise=fetchElements(args)>
16
+ <${input.renderBody} ads=resolved.ads />
17
+ </marko-web-resolve>
18
+ </if>
19
+ <else>
20
+ $ warn('Unable to fetch elements from NativeX: a uri and placement ID are required.');
21
+ </else>
@@ -0,0 +1,58 @@
1
+ // Compiled using marko@4.20.2 - DO NOT EDIT
2
+ "use strict";
3
+
4
+ var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
+ marko_componentType = "/@mindful-web/marko-web-native-x$1.0.0/components/fetch-elements.marko",
6
+ marko_component = require("./fetch-elements.marko"),
7
+ marko_renderer = require("marko/dist/runtime/components/renderer"),
8
+ module_utils_module = require("@mindful-web/utils"),
9
+ utils_module = module_utils_module.default || module_utils_module,
10
+ warn = module_utils_module.warn,
11
+ module_fetchElements = require("../services/fetch-elements"),
12
+ fetchElements = module_fetchElements.default || module_fetchElements,
13
+ marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
14
+ marko_web_resolve_template = require("@mindful-web/marko-core/components/resolve.marko"),
15
+ marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
16
+ marko_web_resolve_tag = marko_loadTag(marko_web_resolve_template);
17
+
18
+ function render(input, out, __component, component, state) {
19
+ var data = input;
20
+
21
+ const { req } = out.global;
22
+
23
+ const { uri, id, opts } = input;
24
+
25
+ const args = {
26
+ uri,
27
+ placementId: id,
28
+ opts,
29
+ req,
30
+ };
31
+
32
+ if (uri && id) {
33
+ marko_web_resolve_tag({
34
+ promise: fetchElements(args),
35
+ renderBody: function(out, { resolved }) {
36
+ marko_dynamicTag(out, input.renderBody, function() {
37
+ return {
38
+ ads: resolved.ads
39
+ };
40
+ }, null, null, null, __component, "1");
41
+ }
42
+ }, out, __component, "0");
43
+ } else {
44
+ warn('Unable to fetch elements from NativeX: a uri and placement ID are required.');
45
+ }
46
+ }
47
+
48
+ marko_template._ = marko_renderer(render, {
49
+ e_: marko_componentType
50
+ }, marko_component);
51
+
52
+ marko_template.meta = {
53
+ id: "/@mindful-web/marko-web-native-x$1.0.0/components/fetch-elements.marko",
54
+ component: "./fetch-elements.marko",
55
+ tags: [
56
+ "@mindful-web/marko-core/components/resolve.marko"
57
+ ]
58
+ };
@@ -0,0 +1,21 @@
1
+ import defaultValue from "@mindful-web/marko-core/utils/default-value";
2
+ import { get, getAsObject } from "@mindful-web/object-path";
3
+
4
+ $ const { req } = out.global;
5
+ $ const story = getAsObject(input, "story");
6
+ $ const on = defaultValue(input.on, "load");
7
+ $ const requestFrame = defaultValue(input.requestFrame, true);
8
+ $ const targetTag = defaultValue(input.targetTag, "body");
9
+ $ const containerId = "GTM-MNQH25L";
10
+
11
+ <marko-web-gtm-init
12
+ name="dataLayerNativeX"
13
+ container-id=containerId
14
+ on=on
15
+ request-frame=requestFrame
16
+ target-tag=targetTag
17
+ start=true
18
+ push=input.push
19
+ />
20
+
21
+ <marko-web-gtm-noscript container-id=containerId />