@c15t/scripts 2.0.0 → 2.1.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 (110) hide show
  1. package/README.md +9 -9
  2. package/dist/e2e-test-utils.cjs +125 -0
  3. package/dist/e2e-test-utils.js +67 -0
  4. package/dist/engine/runtime.cjs +19 -9
  5. package/dist/engine/runtime.js +19 -9
  6. package/dist/registry.cjs +338 -0
  7. package/dist/registry.js +292 -0
  8. package/dist/types.cjs +18 -0
  9. package/dist/types.js +10 -1
  10. package/dist/vendors/_shared/attributes.cjs +51 -0
  11. package/dist/vendors/_shared/attributes.js +14 -0
  12. package/dist/vendors/_shared/google-consent.cjs +64 -0
  13. package/dist/vendors/_shared/google-consent.js +27 -0
  14. package/dist/vendors/_shared/install-builders.cjs +55 -0
  15. package/dist/vendors/_shared/install-builders.js +21 -0
  16. package/dist/vendors/_shared/script-url.cjs +74 -0
  17. package/dist/vendors/_shared/script-url.js +28 -0
  18. package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +2 -2
  19. package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
  20. package/dist/vendors/ads-and-pixels/meta-pixel.cjs +202 -0
  21. package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
  22. package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +31 -14
  23. package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
  24. package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +147 -0
  25. package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
  26. package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +127 -0
  27. package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
  28. package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +2 -2
  29. package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
  30. package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +6 -3
  31. package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
  32. package/dist/vendors/analytics/ahrefs-analytics.cjs +64 -0
  33. package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
  34. package/dist/vendors/analytics/cloudflare-web-analytics.cjs +69 -0
  35. package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
  36. package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +3 -3
  37. package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
  38. package/dist/vendors/analytics/fathom-analytics.cjs +72 -0
  39. package/dist/vendors/analytics/fathom-analytics.js +35 -0
  40. package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +7 -28
  41. package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
  42. package/dist/vendors/analytics/hotjar.cjs +81 -0
  43. package/dist/vendors/analytics/hotjar.js +44 -0
  44. package/dist/vendors/analytics/matomo-analytics.cjs +228 -0
  45. package/dist/vendors/analytics/matomo-analytics.js +191 -0
  46. package/dist/vendors/analytics/microsoft-clarity.cjs +110 -0
  47. package/dist/vendors/analytics/microsoft-clarity.js +73 -0
  48. package/dist/vendors/analytics/mixpanel-analytics.cjs +119 -0
  49. package/dist/vendors/analytics/mixpanel-analytics.js +82 -0
  50. package/dist/vendors/analytics/plausible-analytics.cjs +118 -0
  51. package/dist/vendors/analytics/plausible-analytics.js +81 -0
  52. package/dist/{posthog.cjs → vendors/analytics/posthog.cjs} +69 -6
  53. package/dist/vendors/analytics/posthog.js +163 -0
  54. package/dist/vendors/analytics/promptwatch.cjs +66 -0
  55. package/dist/vendors/analytics/promptwatch.js +29 -0
  56. package/dist/vendors/analytics/rybbit-analytics.cjs +100 -0
  57. package/dist/vendors/analytics/rybbit-analytics.js +63 -0
  58. package/dist/vendors/analytics/segment.cjs +93 -0
  59. package/dist/vendors/analytics/segment.js +56 -0
  60. package/dist/vendors/analytics/umami-analytics.cjs +76 -0
  61. package/dist/vendors/analytics/umami-analytics.js +39 -0
  62. package/dist/vendors/analytics/vercel-analytics.cjs +90 -0
  63. package/dist/vendors/analytics/vercel-analytics.js +53 -0
  64. package/dist/vendors/functional/crisp.cjs +139 -0
  65. package/dist/vendors/functional/crisp.js +102 -0
  66. package/dist/vendors/functional/intercom.cjs +85 -0
  67. package/dist/vendors/functional/intercom.js +45 -0
  68. package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +6 -27
  69. package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
  70. package/dist-types/__tests__/helpers.d.ts +141 -0
  71. package/dist-types/engine/runtime.d.ts +1 -1
  72. package/dist-types/registry.d.ts +368 -0
  73. package/dist-types/types.d.ts +13 -0
  74. package/dist-types/vendors/_shared/attributes.d.ts +35 -0
  75. package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
  76. package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
  77. package/dist-types/vendors/_shared/script-url.d.ts +75 -0
  78. package/dist-types/{linkedin-insights.d.ts → vendors/ads-and-pixels/linkedin-insights.d.ts} +22 -9
  79. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
  80. package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +21 -10
  81. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
  82. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
  83. package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +20 -5
  84. package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +21 -4
  85. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
  86. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
  87. package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
  88. package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +5 -8
  89. package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
  90. package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
  91. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +86 -0
  92. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +101 -0
  93. package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
  94. package/dist-types/{posthog.d.ts → vendors/analytics/posthog.d.ts} +47 -5
  95. package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
  96. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
  97. package/dist-types/vendors/analytics/segment.d.ts +158 -0
  98. package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
  99. package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
  100. package/dist-types/vendors/functional/crisp.d.ts +78 -0
  101. package/dist-types/vendors/functional/intercom.d.ts +135 -0
  102. package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +5 -8
  103. package/package.json +166 -5
  104. package/dist/meta-pixel.cjs +0 -129
  105. package/dist/meta-pixel.js +0 -89
  106. package/dist/posthog.js +0 -100
  107. package/dist-types/engine.test.d.ts +0 -1
  108. package/dist-types/helpers.test.d.ts +0 -1
  109. package/dist-types/meta-pixel.d.ts +0 -185
  110. /package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +0 -0
@@ -0,0 +1,153 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { buildQueuePixelInstall } from "../_shared/install-builders.js";
4
+ import { resolveScriptUrl } from "../_shared/script-url.js";
5
+ const metaPixelManifest = {
6
+ ...vendorManifestContract,
7
+ vendor: 'meta-pixel',
8
+ category: 'marketing',
9
+ persistAfterConsentRevoked: true,
10
+ bootstrap: [
11
+ {
12
+ type: 'defineStubFunction',
13
+ name: 'fbq',
14
+ queue: {
15
+ property: 'queue'
16
+ },
17
+ dispatchProperty: 'callMethod',
18
+ selfReferences: [
19
+ 'push'
20
+ ],
21
+ aliases: [
22
+ '_fbq'
23
+ ],
24
+ properties: {
25
+ loaded: true,
26
+ version: '2.0'
27
+ },
28
+ ifUndefined: true
29
+ }
30
+ ],
31
+ install: [
32
+ {
33
+ type: 'callGlobal',
34
+ global: 'fbq',
35
+ args: [
36
+ 'consent',
37
+ 'grant'
38
+ ]
39
+ },
40
+ {
41
+ type: 'callGlobal',
42
+ global: 'fbq',
43
+ args: [
44
+ 'init',
45
+ '{{pixelId}}'
46
+ ]
47
+ },
48
+ {
49
+ type: 'callGlobal',
50
+ global: 'fbq',
51
+ args: [
52
+ 'track',
53
+ 'PageView'
54
+ ]
55
+ },
56
+ {
57
+ type: 'loadScript',
58
+ src: "{{scriptSrc}}",
59
+ async: true
60
+ }
61
+ ],
62
+ onConsentGranted: [
63
+ {
64
+ type: 'callGlobal',
65
+ global: 'fbq',
66
+ args: [
67
+ 'consent',
68
+ 'grant'
69
+ ]
70
+ }
71
+ ],
72
+ onConsentDenied: [
73
+ {
74
+ type: 'callGlobal',
75
+ global: 'fbq',
76
+ args: [
77
+ 'consent',
78
+ 'revoke'
79
+ ]
80
+ }
81
+ ]
82
+ };
83
+ function metaPixel({ pixelId, initOptions, trackPageView = true, dataProcessingOptions, scriptSrc }) {
84
+ const install = buildMetaPixelInstall({
85
+ hasInitOptions: void 0 !== initOptions,
86
+ trackPageView,
87
+ dataProcessingOptions
88
+ });
89
+ const manifest = {
90
+ ...metaPixelManifest,
91
+ install
92
+ };
93
+ const resolved = resolveManifest(manifest, {
94
+ pixelId,
95
+ initOptions,
96
+ scriptSrc: resolveScriptUrl(scriptSrc, 'https://connect.facebook.net/en_US/fbevents.js')
97
+ });
98
+ return resolved;
99
+ }
100
+ function buildMetaPixelInstall({ hasInitOptions, trackPageView, dataProcessingOptions }) {
101
+ const initArgs = [
102
+ 'init',
103
+ '{{pixelId}}'
104
+ ];
105
+ if (hasInitOptions) initArgs.push('{{initOptions}}');
106
+ const install = buildQueuePixelInstall({
107
+ global: 'fbq',
108
+ initArgs,
109
+ trackStep: getMetaPixelPageViewStep(trackPageView),
110
+ scriptPlaceholder: "{{scriptSrc}}"
111
+ });
112
+ if (void 0 !== dataProcessingOptions) install.unshift({
113
+ type: 'callGlobal',
114
+ global: 'fbq',
115
+ args: getMetaPixelDataProcessingArgs(dataProcessingOptions)
116
+ });
117
+ install.unshift({
118
+ type: 'callGlobal',
119
+ global: 'fbq',
120
+ args: [
121
+ 'consent',
122
+ 'grant'
123
+ ]
124
+ });
125
+ return install;
126
+ }
127
+ function getMetaPixelDataProcessingArgs({ options, country, state }) {
128
+ const args = [
129
+ 'dataProcessingOptions',
130
+ options
131
+ ];
132
+ if (void 0 !== country || void 0 !== state) args.push(country ?? 0, state ?? 0);
133
+ return args;
134
+ }
135
+ function getMetaPixelPageViewStep(trackPageView) {
136
+ if (trackPageView) return {
137
+ args: [
138
+ 'track',
139
+ 'PageView'
140
+ ]
141
+ };
142
+ }
143
+ function resolveMetaPixelEventOptions(eventOptions) {
144
+ if ('string' == typeof eventOptions) return {
145
+ eventID: eventOptions
146
+ };
147
+ return eventOptions;
148
+ }
149
+ const metaPixelEvent = (eventName, params, eventOptions)=>window.fbq('track', eventName, params, resolveMetaPixelEventOptions(eventOptions));
150
+ const metaPixelCustomEvent = (eventName, params, eventOptions)=>window.fbq('trackCustom', eventName, params, resolveMetaPixelEventOptions(eventOptions));
151
+ const metaPixelSingleEvent = (pixelId, eventName, params, eventOptions)=>window.fbq('trackSingle', pixelId, eventName, params, resolveMetaPixelEventOptions(eventOptions));
152
+ const metaPixelSingleCustomEvent = (pixelId, eventName, params, eventOptions)=>window.fbq('trackSingleCustom', pixelId, eventName, params, resolveMetaPixelEventOptions(eventOptions));
153
+ export { metaPixel, metaPixelCustomEvent, metaPixelEvent, metaPixelManifest, metaPixelSingleCustomEvent, metaPixelSingleEvent };
@@ -27,12 +27,13 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  microsoftUetManifest: ()=>microsoftUetManifest,
28
28
  microsoftUet: ()=>microsoftUet
29
29
  });
30
- const external_resolve_cjs_namespaceObject = require("./resolve.cjs");
31
- const external_types_cjs_namespaceObject = require("./types.cjs");
30
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
32
32
  const microsoftUetManifest = {
33
33
  ...external_types_cjs_namespaceObject.vendorManifestContract,
34
34
  vendor: 'microsoft-uet',
35
35
  category: 'marketing',
36
+ alwaysLoad: true,
36
37
  persistAfterConsentRevoked: true,
37
38
  bootstrap: [
38
39
  {
@@ -42,6 +43,34 @@ const microsoftUetManifest = {
42
43
  ifUndefined: true
43
44
  }
44
45
  ],
46
+ onBeforeLoadGranted: [
47
+ {
48
+ type: 'callGlobal',
49
+ global: 'uetq',
50
+ method: 'push',
51
+ args: [
52
+ 'consent',
53
+ 'default',
54
+ {
55
+ ad_storage: 'granted'
56
+ }
57
+ ]
58
+ }
59
+ ],
60
+ onBeforeLoadDenied: [
61
+ {
62
+ type: 'callGlobal',
63
+ global: 'uetq',
64
+ method: 'push',
65
+ args: [
66
+ 'consent',
67
+ 'default',
68
+ {
69
+ ad_storage: 'denied'
70
+ }
71
+ ]
72
+ }
73
+ ],
45
74
  install: [
46
75
  {
47
76
  type: 'loadScript',
@@ -69,18 +98,6 @@ const microsoftUetManifest = {
69
98
  args: [
70
99
  'pageLoad'
71
100
  ]
72
- },
73
- {
74
- type: 'callGlobal',
75
- global: 'uetq',
76
- method: 'push',
77
- args: [
78
- 'consent',
79
- 'default',
80
- {
81
- ad_storage: 'granted'
82
- }
83
- ]
84
101
  }
85
102
  ],
86
103
  onConsentGranted: [
@@ -1,9 +1,10 @@
1
- import { resolveManifest } from "./resolve.js";
2
- import { vendorManifestContract } from "./types.js";
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
3
  const microsoftUetManifest = {
4
4
  ...vendorManifestContract,
5
5
  vendor: 'microsoft-uet',
6
6
  category: 'marketing',
7
+ alwaysLoad: true,
7
8
  persistAfterConsentRevoked: true,
8
9
  bootstrap: [
9
10
  {
@@ -13,6 +14,34 @@ const microsoftUetManifest = {
13
14
  ifUndefined: true
14
15
  }
15
16
  ],
17
+ onBeforeLoadGranted: [
18
+ {
19
+ type: 'callGlobal',
20
+ global: 'uetq',
21
+ method: 'push',
22
+ args: [
23
+ 'consent',
24
+ 'default',
25
+ {
26
+ ad_storage: 'granted'
27
+ }
28
+ ]
29
+ }
30
+ ],
31
+ onBeforeLoadDenied: [
32
+ {
33
+ type: 'callGlobal',
34
+ global: 'uetq',
35
+ method: 'push',
36
+ args: [
37
+ 'consent',
38
+ 'default',
39
+ {
40
+ ad_storage: 'denied'
41
+ }
42
+ ]
43
+ }
44
+ ],
16
45
  install: [
17
46
  {
18
47
  type: 'loadScript',
@@ -40,18 +69,6 @@ const microsoftUetManifest = {
40
69
  args: [
41
70
  'pageLoad'
42
71
  ]
43
- },
44
- {
45
- type: 'callGlobal',
46
- global: 'uetq',
47
- method: 'push',
48
- args: [
49
- 'consent',
50
- 'default',
51
- {
52
- ad_storage: 'granted'
53
- }
54
- ]
55
72
  }
56
73
  ],
57
74
  onConsentGranted: [
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ redditPixel: ()=>redditPixel,
28
+ redditPixelEvent: ()=>redditPixelEvent,
29
+ redditPixelManifest: ()=>redditPixelManifest
30
+ });
31
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
32
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
33
+ const install_builders_cjs_namespaceObject = require("../_shared/install-builders.cjs");
34
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
35
+ const redditPixelManifest = {
36
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
37
+ vendor: 'reddit-pixel',
38
+ category: 'marketing',
39
+ persistAfterConsentRevoked: true,
40
+ bootstrap: [
41
+ {
42
+ type: 'defineStubFunction',
43
+ name: 'rdt',
44
+ queue: {
45
+ property: 'callQueue'
46
+ },
47
+ dispatchProperty: 'sendEvent',
48
+ queueFormat: 'array',
49
+ ifUndefined: true
50
+ }
51
+ ],
52
+ install: [
53
+ {
54
+ type: 'callGlobal',
55
+ global: 'rdt',
56
+ args: [
57
+ 'init',
58
+ '{{pixelId}}'
59
+ ]
60
+ },
61
+ {
62
+ type: 'callGlobal',
63
+ global: 'rdt',
64
+ args: [
65
+ 'track',
66
+ 'PageVisit'
67
+ ]
68
+ },
69
+ {
70
+ type: 'loadScript',
71
+ src: "{{scriptUrl}}",
72
+ async: true
73
+ }
74
+ ],
75
+ onConsentGranted: [
76
+ {
77
+ type: 'callGlobal',
78
+ global: 'rdt',
79
+ args: [
80
+ 'enableFirstPartyCookies'
81
+ ]
82
+ }
83
+ ],
84
+ onConsentDenied: [
85
+ {
86
+ type: 'callGlobal',
87
+ global: 'rdt',
88
+ args: [
89
+ 'disableFirstPartyCookies'
90
+ ]
91
+ }
92
+ ]
93
+ };
94
+ function redditPixel({ pixelId, trackPageVisit = true, initOptions, disableFirstPartyCookies, scriptUrl }) {
95
+ let trackStep;
96
+ if (trackPageVisit) trackStep = {
97
+ args: [
98
+ 'track',
99
+ 'PageVisit'
100
+ ]
101
+ };
102
+ const resolvedInitOptions = getRedditPixelInitOptions({
103
+ initOptions,
104
+ disableFirstPartyCookies
105
+ });
106
+ const initArgs = [
107
+ 'init',
108
+ '{{pixelId}}'
109
+ ];
110
+ if (void 0 !== resolvedInitOptions) initArgs.push('{{initOptions}}');
111
+ const install = (0, install_builders_cjs_namespaceObject.buildQueuePixelInstall)({
112
+ global: 'rdt',
113
+ initArgs,
114
+ trackStep
115
+ });
116
+ const manifest = {
117
+ ...redditPixelManifest,
118
+ install
119
+ };
120
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
121
+ pixelId,
122
+ initOptions: resolvedInitOptions,
123
+ scriptUrl: (0, script_url_cjs_namespaceObject.resolveScriptUrl)(scriptUrl, 'https://www.redditstatic.com/ads/pixel.js')
124
+ });
125
+ }
126
+ function getRedditPixelInitOptions({ initOptions, disableFirstPartyCookies }) {
127
+ if (void 0 === disableFirstPartyCookies) return initOptions;
128
+ return {
129
+ ...initOptions,
130
+ disableFirstPartyCookies
131
+ };
132
+ }
133
+ const redditPixelEvent = (eventName, metadata)=>{
134
+ if ("u" < typeof window || 'function' != typeof window.rdt) return;
135
+ window.rdt('track', eventName, metadata);
136
+ };
137
+ exports.redditPixel = __webpack_exports__.redditPixel;
138
+ exports.redditPixelEvent = __webpack_exports__.redditPixelEvent;
139
+ exports.redditPixelManifest = __webpack_exports__.redditPixelManifest;
140
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
141
+ "redditPixel",
142
+ "redditPixelEvent",
143
+ "redditPixelManifest"
144
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
145
+ Object.defineProperty(exports, '__esModule', {
146
+ value: true
147
+ });
@@ -0,0 +1,107 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { buildQueuePixelInstall } from "../_shared/install-builders.js";
4
+ import { resolveScriptUrl } from "../_shared/script-url.js";
5
+ const redditPixelManifest = {
6
+ ...vendorManifestContract,
7
+ vendor: 'reddit-pixel',
8
+ category: 'marketing',
9
+ persistAfterConsentRevoked: true,
10
+ bootstrap: [
11
+ {
12
+ type: 'defineStubFunction',
13
+ name: 'rdt',
14
+ queue: {
15
+ property: 'callQueue'
16
+ },
17
+ dispatchProperty: 'sendEvent',
18
+ queueFormat: 'array',
19
+ ifUndefined: true
20
+ }
21
+ ],
22
+ install: [
23
+ {
24
+ type: 'callGlobal',
25
+ global: 'rdt',
26
+ args: [
27
+ 'init',
28
+ '{{pixelId}}'
29
+ ]
30
+ },
31
+ {
32
+ type: 'callGlobal',
33
+ global: 'rdt',
34
+ args: [
35
+ 'track',
36
+ 'PageVisit'
37
+ ]
38
+ },
39
+ {
40
+ type: 'loadScript',
41
+ src: "{{scriptUrl}}",
42
+ async: true
43
+ }
44
+ ],
45
+ onConsentGranted: [
46
+ {
47
+ type: 'callGlobal',
48
+ global: 'rdt',
49
+ args: [
50
+ 'enableFirstPartyCookies'
51
+ ]
52
+ }
53
+ ],
54
+ onConsentDenied: [
55
+ {
56
+ type: 'callGlobal',
57
+ global: 'rdt',
58
+ args: [
59
+ 'disableFirstPartyCookies'
60
+ ]
61
+ }
62
+ ]
63
+ };
64
+ function redditPixel({ pixelId, trackPageVisit = true, initOptions, disableFirstPartyCookies, scriptUrl }) {
65
+ let trackStep;
66
+ if (trackPageVisit) trackStep = {
67
+ args: [
68
+ 'track',
69
+ 'PageVisit'
70
+ ]
71
+ };
72
+ const resolvedInitOptions = getRedditPixelInitOptions({
73
+ initOptions,
74
+ disableFirstPartyCookies
75
+ });
76
+ const initArgs = [
77
+ 'init',
78
+ '{{pixelId}}'
79
+ ];
80
+ if (void 0 !== resolvedInitOptions) initArgs.push('{{initOptions}}');
81
+ const install = buildQueuePixelInstall({
82
+ global: 'rdt',
83
+ initArgs,
84
+ trackStep
85
+ });
86
+ const manifest = {
87
+ ...redditPixelManifest,
88
+ install
89
+ };
90
+ return resolveManifest(manifest, {
91
+ pixelId,
92
+ initOptions: resolvedInitOptions,
93
+ scriptUrl: resolveScriptUrl(scriptUrl, 'https://www.redditstatic.com/ads/pixel.js')
94
+ });
95
+ }
96
+ function getRedditPixelInitOptions({ initOptions, disableFirstPartyCookies }) {
97
+ if (void 0 === disableFirstPartyCookies) return initOptions;
98
+ return {
99
+ ...initOptions,
100
+ disableFirstPartyCookies
101
+ };
102
+ }
103
+ const redditPixelEvent = (eventName, metadata)=>{
104
+ if ("u" < typeof window || 'function' != typeof window.rdt) return;
105
+ window.rdt('track', eventName, metadata);
106
+ };
107
+ export { redditPixel, redditPixelEvent, redditPixelManifest };
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ snapchatPixel: ()=>snapchatPixel,
28
+ snapchatPixelManifest: ()=>snapchatPixelManifest,
29
+ snapchatPixelEvent: ()=>snapchatPixelEvent
30
+ });
31
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
32
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
33
+ const install_builders_cjs_namespaceObject = require("../_shared/install-builders.cjs");
34
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
35
+ const snapchatPixelManifest = {
36
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
37
+ vendor: 'snapchat-pixel',
38
+ category: 'marketing',
39
+ bootstrap: [
40
+ {
41
+ type: 'defineStubFunction',
42
+ name: 'snaptr',
43
+ queue: {
44
+ property: 'queue'
45
+ },
46
+ dispatchProperty: 'handleRequest',
47
+ queueFormat: 'array',
48
+ aliases: [
49
+ '_snaptr'
50
+ ],
51
+ selfReferences: [
52
+ 'push'
53
+ ],
54
+ properties: {
55
+ loaded: true,
56
+ version: '1.0'
57
+ },
58
+ ifUndefined: true
59
+ }
60
+ ],
61
+ install: [
62
+ {
63
+ type: 'callGlobal',
64
+ global: 'snaptr',
65
+ args: [
66
+ 'init',
67
+ '{{pixelId}}'
68
+ ]
69
+ },
70
+ {
71
+ type: 'callGlobal',
72
+ global: 'snaptr',
73
+ args: [
74
+ 'track',
75
+ 'PAGE_VIEW'
76
+ ]
77
+ },
78
+ {
79
+ type: 'loadScript',
80
+ src: "{{scriptUrl}}",
81
+ async: true
82
+ }
83
+ ]
84
+ };
85
+ function snapchatPixel({ pixelId, initOptions, trackPageView = true, scriptUrl }) {
86
+ const initArgs = [
87
+ 'init',
88
+ '{{pixelId}}'
89
+ ];
90
+ if (void 0 !== initOptions) initArgs.push('{{initOptions}}');
91
+ let trackStep;
92
+ if (trackPageView) trackStep = {
93
+ args: [
94
+ 'track',
95
+ 'PAGE_VIEW'
96
+ ]
97
+ };
98
+ const install = (0, install_builders_cjs_namespaceObject.buildQueuePixelInstall)({
99
+ global: 'snaptr',
100
+ initArgs,
101
+ trackStep
102
+ });
103
+ const manifest = {
104
+ ...snapchatPixelManifest,
105
+ install
106
+ };
107
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
108
+ pixelId,
109
+ initOptions,
110
+ scriptUrl: (0, script_url_cjs_namespaceObject.resolveScriptUrl)(scriptUrl, 'https://sc-static.net/scevent.min.js')
111
+ });
112
+ }
113
+ const snapchatPixelEvent = (eventName, properties)=>{
114
+ if ("u" < typeof window || 'function' != typeof window.snaptr) return;
115
+ window.snaptr('track', eventName, properties);
116
+ };
117
+ exports.snapchatPixel = __webpack_exports__.snapchatPixel;
118
+ exports.snapchatPixelEvent = __webpack_exports__.snapchatPixelEvent;
119
+ exports.snapchatPixelManifest = __webpack_exports__.snapchatPixelManifest;
120
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
121
+ "snapchatPixel",
122
+ "snapchatPixelEvent",
123
+ "snapchatPixelManifest"
124
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
125
+ Object.defineProperty(exports, '__esModule', {
126
+ value: true
127
+ });