@c15t/scripts 2.0.1 → 2.2.0-canary-20260727202135
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.
- package/AGENTS.md +62 -0
- package/README.md +41 -29
- package/dist/e2e-test-utils.cjs +51 -10
- package/dist/e2e-test-utils.js +37 -3
- package/dist/engine/compile.cjs +9 -5
- package/dist/engine/runtime.cjs +111 -17
- package/dist/engine/runtime.js +102 -12
- package/dist/registry.cjs +423 -0
- package/dist/registry.js +372 -0
- package/dist/resolve.cjs +9 -5
- package/dist/types.cjs +32 -10
- package/dist/types.js +10 -1
- package/dist/vendors/_shared/attributes.cjs +55 -0
- package/dist/vendors/_shared/attributes.js +14 -0
- package/dist/vendors/_shared/google-consent.cjs +69 -0
- package/dist/vendors/_shared/google-consent.js +27 -0
- package/dist/vendors/_shared/install-builders.cjs +59 -0
- package/dist/vendors/_shared/install-builders.js +21 -0
- package/dist/vendors/_shared/script-url.cjs +78 -0
- package/dist/vendors/_shared/script-url.js +28 -0
- package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +11 -7
- package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +206 -0
- package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
- package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +42 -21
- package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +151 -0
- package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +131 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
- package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +11 -7
- package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
- package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +15 -8
- package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
- package/dist/vendors/analytics/adobe-analytics.cjs +90 -0
- package/dist/vendors/analytics/adobe-analytics.js +49 -0
- package/dist/vendors/analytics/ahrefs-analytics.cjs +68 -0
- package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
- package/dist/vendors/analytics/amplitude.cjs +193 -0
- package/dist/vendors/analytics/amplitude.js +134 -0
- package/dist/vendors/analytics/clearbit.cjs +69 -0
- package/dist/vendors/analytics/clearbit.js +28 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.cjs +73 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
- package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +14 -10
- package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
- package/dist/vendors/analytics/fathom-analytics.cjs +76 -0
- package/dist/vendors/analytics/fathom-analytics.js +35 -0
- package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +18 -35
- package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
- package/dist/vendors/analytics/heap.cjs +181 -0
- package/dist/vendors/analytics/heap.js +134 -0
- package/dist/vendors/analytics/hightouch.cjs +153 -0
- package/dist/vendors/analytics/hightouch.js +109 -0
- package/dist/vendors/analytics/hotjar.cjs +85 -0
- package/dist/vendors/analytics/hotjar.js +44 -0
- package/dist/vendors/analytics/logrocket.cjs +99 -0
- package/dist/vendors/analytics/logrocket.js +58 -0
- package/dist/vendors/analytics/matomo-analytics.cjs +232 -0
- package/dist/vendors/analytics/matomo-analytics.js +191 -0
- package/dist/vendors/analytics/microsoft-clarity.cjs +138 -0
- package/dist/vendors/analytics/microsoft-clarity.js +97 -0
- package/dist/vendors/analytics/mixpanel-analytics.cjs +134 -0
- package/dist/vendors/analytics/mixpanel-analytics.js +93 -0
- package/dist/vendors/analytics/pirsch.cjs +108 -0
- package/dist/vendors/analytics/pirsch.js +67 -0
- package/dist/vendors/analytics/plausible-analytics.cjs +122 -0
- package/dist/vendors/analytics/plausible-analytics.js +81 -0
- package/dist/vendors/analytics/posthog.cjs +204 -0
- package/dist/vendors/analytics/posthog.js +163 -0
- package/dist/vendors/analytics/promptwatch.cjs +70 -0
- package/dist/vendors/analytics/promptwatch.js +29 -0
- package/dist/vendors/analytics/rudderstack.cjs +227 -0
- package/dist/vendors/analytics/rudderstack.js +183 -0
- package/dist/vendors/analytics/rybbit-analytics.cjs +104 -0
- package/dist/vendors/analytics/rybbit-analytics.js +63 -0
- package/dist/vendors/analytics/segment.cjs +97 -0
- package/dist/vendors/analytics/segment.js +56 -0
- package/dist/vendors/analytics/umami-analytics.cjs +80 -0
- package/dist/vendors/analytics/umami-analytics.js +39 -0
- package/dist/vendors/analytics/vercel-analytics.cjs +94 -0
- package/dist/vendors/analytics/vercel-analytics.js +53 -0
- package/dist/vendors/functional/crisp.cjs +143 -0
- package/dist/vendors/functional/crisp.js +102 -0
- package/dist/vendors/functional/intercom.cjs +89 -0
- package/dist/vendors/functional/intercom.js +45 -0
- package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +17 -34
- package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
- package/dist-types/__tests__/helpers.d.ts +141 -0
- package/dist-types/engine/runtime.d.ts +1 -1
- package/dist-types/registry.d.ts +440 -0
- package/dist-types/types.d.ts +53 -2
- package/dist-types/vendors/_shared/attributes.d.ts +35 -0
- package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
- package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
- package/dist-types/vendors/_shared/script-url.d.ts +75 -0
- package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +92 -0
- package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
- package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +45 -34
- package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
- package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
- package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +48 -33
- package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +34 -17
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
- package/dist-types/vendors/analytics/amplitude.d.ts +234 -0
- package/dist-types/vendors/analytics/clearbit.d.ts +60 -0
- package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
- package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +25 -25
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
- package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +21 -24
- package/dist-types/vendors/analytics/heap.d.ts +316 -0
- package/dist-types/vendors/analytics/hightouch.d.ts +285 -0
- package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
- package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +98 -0
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +113 -0
- package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
- package/dist-types/vendors/analytics/posthog.d.ts +154 -0
- package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
- package/dist-types/vendors/analytics/rudderstack.d.ts +330 -0
- package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
- package/dist-types/vendors/analytics/segment.d.ts +158 -0
- package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
- package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
- package/dist-types/vendors/functional/crisp.d.ts +78 -0
- package/dist-types/vendors/functional/intercom.d.ts +135 -0
- package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +22 -25
- package/docs/README.md +62 -0
- package/docs/frameworks/javascript/script-loader.md +354 -0
- package/docs/frameworks/next/script-loader.md +499 -0
- package/docs/frameworks/react/script-loader.md +553 -0
- package/docs/integrations/adobe-analytics.md +160 -0
- package/docs/integrations/ahrefs-analytics.md +157 -0
- package/docs/integrations/amplitude.md +230 -0
- package/docs/integrations/building-integrations.md +239 -0
- package/docs/integrations/clearbit.md +130 -0
- package/docs/integrations/cloudflare-web-analytics.md +126 -0
- package/docs/integrations/crisp.md +140 -0
- package/docs/integrations/databuddy.md +205 -0
- package/docs/integrations/fathom-analytics.md +150 -0
- package/docs/integrations/google-maps.md +263 -0
- package/docs/integrations/google-tag-manager.md +154 -0
- package/docs/integrations/google-tag.md +134 -0
- package/docs/integrations/heap.md +219 -0
- package/docs/integrations/hightouch.md +199 -0
- package/docs/integrations/hotjar.md +143 -0
- package/docs/integrations/intercom.md +144 -0
- package/docs/integrations/linkedin-insights.md +161 -0
- package/docs/integrations/logrocket.md +175 -0
- package/docs/integrations/matomo-analytics.md +171 -0
- package/docs/integrations/meta-pixel.md +412 -0
- package/docs/integrations/microsoft-clarity.md +173 -0
- package/docs/integrations/microsoft-uet.md +156 -0
- package/docs/integrations/mixpanel-analytics.md +130 -0
- package/docs/integrations/overview.md +149 -0
- package/docs/integrations/pirsch.md +142 -0
- package/docs/integrations/plausible-analytics.md +154 -0
- package/docs/integrations/posthog.md +258 -0
- package/docs/integrations/promptwatch.md +121 -0
- package/docs/integrations/reddit-pixel.md +241 -0
- package/docs/integrations/rudderstack.md +271 -0
- package/docs/integrations/rybbit-analytics.md +143 -0
- package/docs/integrations/segment.md +146 -0
- package/docs/integrations/snapchat-pixel.md +163 -0
- package/docs/integrations/tiktok-pixel.md +123 -0
- package/docs/integrations/umami-analytics.md +148 -0
- package/docs/integrations/vercel-analytics.md +141 -0
- package/docs/integrations/x-pixel.md +157 -0
- package/docs/integrations/youtube.md +193 -0
- package/docs/shared/react/guides/script-loader.md +309 -0
- package/package.json +223 -8
- package/readme.json +8 -4
- package/dist/meta-pixel.cjs +0 -129
- package/dist/meta-pixel.js +0 -89
- package/dist/posthog.cjs +0 -137
- package/dist/posthog.js +0 -100
- package/dist-types/linkedin-insights.d.ts +0 -79
- package/dist-types/meta-pixel.d.ts +0 -185
- package/dist-types/posthog.d.ts +0 -112
package/AGENTS.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @c15t/scripts
|
|
2
|
+
|
|
3
|
+
> Consent-aware script integration docs for analytics, advertising pixels, tag managers, widgets, and custom loaders.
|
|
4
|
+
|
|
5
|
+
These docs ship inside the package so coding agents can read them offline. Open the topic file you need from the list below — paths are relative to this file.
|
|
6
|
+
|
|
7
|
+
## Frameworks
|
|
8
|
+
|
|
9
|
+
Install and configure c15t in JavaScript, React, and Next.js applications.
|
|
10
|
+
|
|
11
|
+
- [Script Loader](./docs/frameworks/javascript/script-loader.md): Gate third-party scripts behind consent — load Google Analytics, Meta Pixel, and other tracking scripts only when users grant permission.
|
|
12
|
+
- [Script Loader](./docs/frameworks/next/script-loader.md): Gate third-party scripts behind consent in Next.js — load Google Analytics, Meta Pixel, and other tracking scripts only when users grant permission.
|
|
13
|
+
- [Script Loader](./docs/frameworks/react/script-loader.md): Gate third-party scripts behind consent in React — load Google Analytics, Meta Pixel, and other tracking scripts only when users grant permission.
|
|
14
|
+
|
|
15
|
+
## Integrations
|
|
16
|
+
|
|
17
|
+
Connect analytics, advertising, maps, media, and other third-party tools behind consent.
|
|
18
|
+
|
|
19
|
+
- [Adobe Analytics](./docs/integrations/adobe-analytics.md): Adobe Analytics loaded through an Adobe Experience Platform Data Collection Tags embed URL.
|
|
20
|
+
- [Ahrefs Analytics](./docs/integrations/ahrefs-analytics.md): Cookieless web analytics from Ahrefs with a prebuilt helper that wires the project key into a c15t-managed script.
|
|
21
|
+
- [Amplitude](./docs/integrations/amplitude.md): Load Amplitude Browser SDK 2 with c15t and gate product analytics behind measurement consent.
|
|
22
|
+
- [Build a Custom Script Integration](./docs/integrations/building-integrations.md): Learn when to use a raw Script, when to build a reusable manifest-backed integration, and how to debug and test custom consent-aware scripts in c15t.
|
|
23
|
+
- [Clearbit](./docs/integrations/clearbit.md): Visitor and company enrichment loaded with Clearbit's account-keyed tags.js snippet.
|
|
24
|
+
- [Cloudflare Web Analytics](./docs/integrations/cloudflare-web-analytics.md): Cookieless analytics from Cloudflare with a prebuilt helper that serializes the beacon config into the `data-cf-beacon` attribute.
|
|
25
|
+
- [Crisp](./docs/integrations/crisp.md): Load Crisp live chat with website ID, runtime, cookie, and session options.
|
|
26
|
+
- [Databuddy](./docs/integrations/databuddy.md): Databuddy is a privacy-focused analytics platform that helps you understand user behavior and track events. It supports cookieless tracking and manages consent automatically through c15t's consent state synchronization.
|
|
27
|
+
- [Fathom Analytics](./docs/integrations/fathom-analytics.md): Privacy-friendly cookieless analytics with a prebuilt helper that maps Fathom's data attributes into a c15t-managed script.
|
|
28
|
+
- [Google Maps](./docs/integrations/google-maps.md): Render Google Maps only after consent with one shared Maps JavaScript API loader and independently managed map instances.
|
|
29
|
+
- [GA4 + Google Ads (gtag.js)](./docs/integrations/google-tag.md): Send data to Google Analytics 4 and Google Ads with automatic Consent Mode v2 support.
|
|
30
|
+
- [Google Tag Manager](./docs/integrations/google-tag-manager.md): Deploy and manage marketing tags centrally with automatic consent state synchronization.
|
|
31
|
+
- [Heap](./docs/integrations/heap.md): Load Heap with c15t and gate autocapture product analytics behind measurement consent.
|
|
32
|
+
- [Hightouch](./docs/integrations/hightouch.md): Load Hightouch Events with c15t and gate the browser SDK behind measurement consent.
|
|
33
|
+
- [Hotjar](./docs/integrations/hotjar.md): Product analytics and behavior insights with a prebuilt helper that seeds Hotjar globals before loading the vendor bundle.
|
|
34
|
+
- [Intercom](./docs/integrations/intercom.md): Bootstrap Intercom settings and load the messenger widget bundle.
|
|
35
|
+
- [LinkedIn Insights](./docs/integrations/linkedin-insights.md): Track conversions and build matched audiences for LinkedIn advertising campaigns.
|
|
36
|
+
- [LogRocket](./docs/integrations/logrocket.md): Session replay and monitoring loaded after measurement consent with LogRocket's browser SDK.
|
|
37
|
+
- [Matomo Analytics](./docs/integrations/matomo-analytics.md): Load Matomo with c15t and keep Matomo's queue aligned with measurement consent.
|
|
38
|
+
- [Meta Pixel](./docs/integrations/meta-pixel.md): Track conversions and build audiences for Facebook and Instagram advertising campaigns.
|
|
39
|
+
- [Microsoft Clarity](./docs/integrations/microsoft-clarity.md): Session replay and behavior analytics with a prebuilt helper that keeps Clarity consent synchronized with c15t measurement state.
|
|
40
|
+
- [Microsoft UET](./docs/integrations/microsoft-uet.md): Track conversions and measure performance for Microsoft Advertising and Bing Ads.
|
|
41
|
+
- [Mixpanel Analytics](./docs/integrations/mixpanel-analytics.md): Load Mixpanel with c15t and let Mixpanel's own opt-in and opt-out APIs follow measurement consent.
|
|
42
|
+
- [Integrations](./docs/integrations/overview.md): Load analytics, pixels, tag managers, and widgets through c15t so consent state controls when they run, update, and appear in your consent UI.
|
|
43
|
+
- [Pirsch](./docs/integrations/pirsch.md): Privacy-friendly, cookieless analytics loaded with Pirsch's fixed script id and identification-code attributes.
|
|
44
|
+
- [Plausible Analytics](./docs/integrations/plausible-analytics.md): Privacy-friendly cookieless analytics with a prebuilt helper that preserves Plausible's queue bootstrap and loader attributes.
|
|
45
|
+
- [PostHog](./docs/integrations/posthog.md): PostHog is an open-source product analytics platform for tracking user behavior, session replays, feature flags, and A/B testing. It supports cookieless tracking, allowing analytics to continue even without cookie consent.
|
|
46
|
+
- [Promptwatch](./docs/integrations/promptwatch.md): Promptwatch analyzes traffic on your site for Artificial Intelligence (AI) traffic and usage insights. Data is stored in the EU without user-identifiable information.
|
|
47
|
+
- [Reddit Pixel](./docs/integrations/reddit-pixel.md): Track conversions and build retargeting audiences for Reddit advertising campaigns.
|
|
48
|
+
- [RudderStack](./docs/integrations/rudderstack.md): Load RudderStack's JavaScript SDK with c15t and gate the browser SDK behind measurement consent.
|
|
49
|
+
- [Rybbit Analytics](./docs/integrations/rybbit-analytics.md): Privacy-friendly analytics with script-tag configuration via Rybbit's data attributes.
|
|
50
|
+
- [Segment](./docs/integrations/segment.md): Load Segment Analytics.js with c15t and gate it behind measurement consent.
|
|
51
|
+
- [Snapchat Pixel](./docs/integrations/snapchat-pixel.md): Measure Snapchat ad performance and build remarketing audiences with a prebuilt pixel helper.
|
|
52
|
+
- [TikTok Pixel](./docs/integrations/tiktok-pixel.md): Measure ad performance and build audiences for TikTok advertising campaigns.
|
|
53
|
+
- [Umami Analytics](./docs/integrations/umami-analytics.md): Open-source, cookieless analytics with a prebuilt helper that maps Umami's data attributes into a c15t-managed script.
|
|
54
|
+
- [Vercel Analytics](./docs/integrations/vercel-analytics.md): Bootstrap Vercel Analytics with a declarative queue and script attributes.
|
|
55
|
+
- [X Pixel (Twitter Pixel)](./docs/integrations/x-pixel.md): Track conversions and build audiences for advertising campaigns on X (formerly Twitter).
|
|
56
|
+
- [YouTube](./docs/integrations/youtube.md): Keep YouTube iframes unmounted until consent with a privacy-enhanced, lazy-loaded React or Next.js embed.
|
|
57
|
+
|
|
58
|
+
## Reference
|
|
59
|
+
|
|
60
|
+
Concepts, legal templates, open-source policies, and contributor documentation.
|
|
61
|
+
|
|
62
|
+
- [Script Loader](./docs/shared/react/guides/script-loader.md): Reference page for script loader.
|
package/README.md
CHANGED
|
@@ -1,69 +1,81 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://c15t.com?utm_source=
|
|
2
|
+
<a href="https://c15t.com?utm_source=npm&utm_medium=readme&utm_campaign=oss_readme&utm_content=%40c15t%2Fscripts" target="_blank" rel="noopener noreferrer">
|
|
3
3
|
<picture>
|
|
4
4
|
<source media="(prefers-color-scheme: dark)" srcset="../../docs/assets/c15t-banner-readme-dark.svg" type="image/svg+xml">
|
|
5
5
|
<img src="../../docs/assets/c15t-banner-readme-light.svg" alt="c15t Banner" type="image/svg+xml">
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
|
-
<br />
|
|
9
|
-
<h1 align="center">@c15t/scripts: Prebuilt Consent Scripts</h1>
|
|
10
8
|
</p>
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
[](https://github.com/c15t/c15t/actions/workflows/ci.yml)
|
|
14
|
-
[](https://github.com/c15t/c15t/blob/main/LICENSE.md)
|
|
15
|
-
[](https://c15t.link/discord)
|
|
16
|
-
[](https://www.npmjs.com/package/@c15t/scripts)
|
|
17
|
-
[](https://github.com/c15t/c15t)
|
|
18
|
-
[](https://github.com/c15t/c15t/commits/main)
|
|
19
|
-
[](https://github.com/c15t/c15t/issues)
|
|
10
|
+
# @c15t/scripts: Prebuilt Consent Scripts
|
|
20
11
|
|
|
21
|
-
|
|
12
|
+
<p>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@c15t/scripts"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/npm/%40c15t%2Fscripts.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/npm/%40c15t%2Fscripts.svg?variant=outline&mode=light" alt="Latest NPM Version"></picture></a>
|
|
14
|
+
<a href="https://github.com/c15t/c15t"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/github/c15t/c15t/stars.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/github/c15t/c15t/stars.svg?variant=outline&mode=light" alt="Stars"></picture></a>
|
|
15
|
+
<a href="https://github.com/c15t/c15t/blob/main/LICENSE.md"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/github/c15t/c15t/license.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/github/c15t/c15t/license.svg?variant=outline&mode=light" alt="License"></picture></a>
|
|
16
|
+
<a href="https://c15t.link/discord"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/discord/1312171102268690493.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/discord/1312171102268690493.svg?variant=outline&mode=light" alt="Discord"></picture></a>
|
|
17
|
+
<a href="https://skills.sh/c15t/skills/c15t"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/skills/c15t/skills/c15t.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/skills/c15t/skills/c15t.svg?variant=outline&mode=light" alt="Skills"></picture></a>
|
|
18
|
+
<a href="https://inth.com?utm_source=npm&utm_medium=readme&utm_campaign=oss_readme&utm_content=%40c15t%2Fscripts"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/badge/Made%20By-Inth-ffc803.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAzOTMgNDAwIj48cGF0aCBmaWxsPSIjMDAwIiBkPSJNMTgyLjY2MiAwdjM2Ljg5NWgtNTkuMDMxdjgyLjczM2g1OS4wMzF2MzYuODkzSDI3LjQ4MnYtMzYuODkzaDU5LjAzVjM2Ljg5NWgtNTkuMDNWMHpNMzIxLjk0MSA4OS44NVYwaDM1LjM1NXYxNTYuNTIxaC0yNS43MTNsLTg2LjEzNy05MC4zNjR2OTAuMzY0aC0zNS4zNTVWMGgyNi4zNTV6Ii8%2BPHBhdGggZmlsbD0iIzAwMCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzE4LjU3MSAxODUuNzE0aDc0LjI4NlY0MDBIMFYxODUuNzE0aDI3Mi44NTd2LTQ3LjE0M3ptLTI5MS4wOSAyOC45Njl2MzcuMTE4aDU4LjEzN3YxMTkuNjI4aDM2Ljg5NVYyNTEuODAxaDU4LjU4NHYtMzcuMTE4em0xODIuNjEuMjI0djE1Ni41MjJoMzYuODk0VjMxMy41OWg3My4zNDF2NTcuODM5aDM3LjExOFYyMTQuOTA3aC0zNy4xMTh2NjEuNzg4aC03My4zNDF2LTYxLjc4OHoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg%3D%3D&color=ffc803&labelTextColor=000000&valueColor=000000&mode=dark"><img src="https://shieldcn.dev/badge/Made%20By-Inth-ffc803.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAzOTMgNDAwIj48cGF0aCBmaWxsPSIjMDAwIiBkPSJNMTgyLjY2MiAwdjM2Ljg5NWgtNTkuMDMxdjgyLjczM2g1OS4wMzF2MzYuODkzSDI3LjQ4MnYtMzYuODkzaDU5LjAzVjM2Ljg5NWgtNTkuMDNWMHpNMzIxLjk0MSA4OS44NVYwaDM1LjM1NXYxNTYuNTIxaC0yNS43MTNsLTg2LjEzNy05MC4zNjR2OTAuMzY0aC0zNS4zNTVWMGgyNi4zNTV6Ii8%2BPHBhdGggZmlsbD0iIzAwMCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzE4LjU3MSAxODUuNzE0aDc0LjI4NlY0MDBIMFYxODUuNzE0aDI3Mi44NTd2LTQ3LjE0M3ptLTI5MS4wOSAyOC45Njl2MzcuMTE4aDU4LjEzN3YxMTkuNjI4aDM2Ljg5NVYyNTEuODAxaDU4LjU4NHYtMzcuMTE4em0xODIuNjEuMjI0djE1Ni41MjJoMzYuODk0VjMxMy41OWg3My4zNDF2NTcuODM5aDM3LjExOFYyMTQuOTA3aC0zNy4xMTh2NjEuNzg4aC03My4zNDF2LTYxLjc4OHoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg%3D%3D&color=ffc803&labelTextColor=000000&valueColor=000000&mode=light" alt="Made by Inth"></picture></a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
Consent-aware script integrations for Google Tag Manager, Google Consent Mode v2, GA4, Google Ads, Meta Pixel, analytics tools, pixels, tag managers, and widgets.
|
|
22
22
|
|
|
23
23
|
## Key Features
|
|
24
24
|
|
|
25
|
-
- Prebuilt script
|
|
25
|
+
- Prebuilt script loaders for popular analytics, advertising, marketing, and functional tools
|
|
26
|
+
- Google Tag Manager support with Google Consent Mode v2 defaults and consent updates
|
|
27
|
+
- Google Analytics 4 and Google Ads support through gtag.js
|
|
28
|
+
- Consent-gated Meta Pixel and conversion pixel loading
|
|
26
29
|
- Easy integration with c15t's script loader
|
|
27
30
|
- Configuration options for each supported vendor
|
|
28
|
-
- Supported vendors include Google Tag Manager, Meta Pixel, PostHog, TikTok Pixel, LinkedIn Insights, Microsoft UET,
|
|
31
|
+
- Supported vendors include Google Tag Manager, Meta Pixel, Amplitude, Heap, PostHog, TikTok Pixel, LinkedIn Insights, Microsoft UET, X Pixel, Reddit Pixel, Snapchat Pixel, Intercom, Crisp, and more
|
|
29
32
|
|
|
30
33
|
## Documentation
|
|
31
34
|
|
|
32
35
|
For further information, guides, and examples visit the [reference documentation](https://c15t.com/docs/integrations).
|
|
33
36
|
|
|
34
|
-
##
|
|
37
|
+
## Integrations
|
|
38
|
+
|
|
39
|
+
- **Google Tag Manager**: Loads with Google Consent Mode v2 defaults set to denied; GTM-managed tags fire only once matching consent is granted ([guide](https://c15t.com/docs/integrations/google-tag-manager))
|
|
40
|
+
- **Google Analytics 4 + Google Ads (gtag.js)**: Consent Mode v2 defaults and consent updates when users make a choice ([guide](https://c15t.com/docs/integrations/google-tag))
|
|
41
|
+
- **Conversion pixels**: Meta Pixel, TikTok Pixel, LinkedIn Insights, Microsoft UET (Microsoft Ads), X Pixel, Reddit Pixel, Snapchat Pixel
|
|
42
|
+
- **Analytics**: PostHog, Amplitude, Heap, Segment, RudderStack, Hightouch, Mixpanel, Microsoft Clarity, Hotjar, Plausible, Fathom, Matomo, Umami, Vercel Analytics
|
|
43
|
+
- **Chat widgets**: Intercom, Crisp
|
|
44
|
+
|
|
45
|
+
## Example
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { googleTagManager } from '@c15t/scripts/google-tag-manager'
|
|
49
|
+
import { metaPixel } from '@c15t/scripts/meta-pixel'
|
|
35
50
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- [LinkedIn Insights](https://c15t.link/linkedin-insights)
|
|
42
|
-
- [Microsoft UET](https://c15t.link/microsoft-uet)
|
|
43
|
-
- [X Pixel](https://c15t.link/x-pixel)
|
|
51
|
+
const scripts = [
|
|
52
|
+
googleTagManager({ id: 'GTM-XXXXXX' }),
|
|
53
|
+
metaPixel({ pixelId: '000000000000000' }),
|
|
54
|
+
]
|
|
55
|
+
```
|
|
44
56
|
|
|
45
57
|
## Support
|
|
46
58
|
|
|
47
59
|
- Join our [Discord community](https://c15t.link/discord)
|
|
48
60
|
- Open an issue on our [GitHub repository](https://github.com/c15t/c15t/issues)
|
|
49
|
-
- Visit [
|
|
50
|
-
- Contact our support team via email [support@
|
|
61
|
+
- Visit [inth.com](https://inth.com) and use the chat widget
|
|
62
|
+
- Contact our support team via email [support@inth.com](mailto:support@inth.com)
|
|
51
63
|
|
|
52
64
|
## Contributing
|
|
53
65
|
|
|
54
|
-
- We're open to all community contributions
|
|
66
|
+
- We're open to all community contributions.
|
|
55
67
|
- Read our [Contribution Guidelines](https://c15t.com/docs/oss/contributing)
|
|
56
68
|
- Review our [Code of Conduct](https://c15t.com/docs/oss/code-of-conduct)
|
|
57
69
|
- Fork the repository
|
|
58
70
|
- Create a new branch for your feature
|
|
59
71
|
- Submit a pull request
|
|
60
|
-
- **All contributions, big or small, are welcome and appreciated
|
|
72
|
+
- **All contributions, big or small, are welcome and appreciated.**
|
|
61
73
|
|
|
62
74
|
## Security
|
|
63
75
|
|
|
64
76
|
If you believe you have found a security vulnerability in c15t, we encourage you to **_responsibly disclose this and NOT open a public issue_**. We will investigate all legitimate reports.
|
|
65
77
|
|
|
66
|
-
Our preference is that you make use of GitHub's private vulnerability reporting feature to disclose potential security vulnerabilities in our
|
|
78
|
+
Our preference is that you make use of GitHub's private vulnerability reporting feature to disclose potential security vulnerabilities in our open-source software. To do this, please visit [https://github.com/c15t/c15t/security](https://github.com/c15t/c15t/security) and click the "Report a vulnerability" button.
|
|
67
79
|
|
|
68
80
|
### Security Policy
|
|
69
81
|
|
|
@@ -78,4 +90,4 @@ Our preference is that you make use of GitHub's private vulnerability reporting
|
|
|
78
90
|
|
|
79
91
|
---
|
|
80
92
|
|
|
81
|
-
**Built by [Inth](https://inth.com?utm_source=
|
|
93
|
+
**Built by [Inth](https://inth.com?utm_source=npm&utm_medium=readme&utm_campaign=oss_readme&utm_content=%40c15t%2Fscripts)**
|
package/dist/e2e-test-utils.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -25,14 +29,15 @@ var __webpack_exports__ = {};
|
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
31
|
deniedConsents: ()=>deniedConsents,
|
|
32
|
+
grantedMarketingConsents: ()=>grantedMarketingConsents,
|
|
28
33
|
grantedMeasurementConsents: ()=>grantedMeasurementConsents,
|
|
29
34
|
installBodyProbe: ()=>installBodyProbe,
|
|
30
|
-
loadScripts: ()=>script_loader_namespaceObject.loadScripts,
|
|
31
|
-
registerVendorContractCleanup: ()=>registerVendorContractCleanup,
|
|
32
35
|
installHeadProbe: ()=>installHeadProbe,
|
|
33
36
|
isArgumentsPayload: ()=>isArgumentsPayload,
|
|
37
|
+
loadScripts: ()=>script_loader_namespaceObject.loadScripts,
|
|
38
|
+
registerVendorContractCleanup: ()=>registerVendorContractCleanup,
|
|
34
39
|
toArgs: ()=>toArgs,
|
|
35
|
-
|
|
40
|
+
updateScripts: ()=>script_loader_namespaceObject.updateScripts
|
|
36
41
|
});
|
|
37
42
|
const external_vitest_namespaceObject = require("vitest");
|
|
38
43
|
const script_loader_namespaceObject = require("../../core/src/libs/script-loader");
|
|
@@ -76,19 +81,53 @@ function resetVendorGlobals() {
|
|
|
76
81
|
for (const key of [
|
|
77
82
|
'TiktokAnalyticsObject',
|
|
78
83
|
'UET',
|
|
84
|
+
'$crisp',
|
|
85
|
+
'CRISP_COOKIE_DOMAIN',
|
|
86
|
+
'CRISP_COOKIE_EXPIRE',
|
|
87
|
+
'CRISP_RUNTIME_CONFIG',
|
|
88
|
+
'CRISP_TOKEN_ID',
|
|
89
|
+
'CRISP_WEBSITE_ID',
|
|
90
|
+
'Intercom',
|
|
79
91
|
'_linkedin_data_partner_ids',
|
|
80
92
|
'_linkedin_partner_id',
|
|
81
93
|
'_fbq',
|
|
94
|
+
'_hjSettings',
|
|
95
|
+
'_paq',
|
|
96
|
+
'_satellite',
|
|
97
|
+
'_snaptr',
|
|
98
|
+
'adobeDataLayer',
|
|
99
|
+
'amplitude',
|
|
100
|
+
'analytics',
|
|
101
|
+
'clarity',
|
|
82
102
|
'dataLayer',
|
|
83
103
|
'databuddy',
|
|
84
104
|
'databuddyConfig',
|
|
85
105
|
'fbq',
|
|
86
106
|
'google_tag_data',
|
|
107
|
+
'heap',
|
|
108
|
+
'heapReadyCb',
|
|
109
|
+
'htevents',
|
|
110
|
+
'hj',
|
|
111
|
+
'intercomSettings',
|
|
87
112
|
'lintrk',
|
|
113
|
+
'LogRocket',
|
|
114
|
+
'mixpanel',
|
|
115
|
+
'pirsch',
|
|
116
|
+
'pirschClearSession',
|
|
117
|
+
'pirschInit',
|
|
118
|
+
'pirschNotFound',
|
|
119
|
+
'plausible',
|
|
88
120
|
'posthog',
|
|
121
|
+
'rdt',
|
|
122
|
+
'rudderanalytics',
|
|
123
|
+
'rudderAnalyticsBuildType',
|
|
124
|
+
'RudderSnippetVersion',
|
|
125
|
+
'snaptr',
|
|
89
126
|
'ttq',
|
|
90
127
|
'twq',
|
|
91
|
-
'uetq'
|
|
128
|
+
'uetq',
|
|
129
|
+
'va',
|
|
130
|
+
'vaq'
|
|
92
131
|
])delete win[key];
|
|
93
132
|
}
|
|
94
133
|
function registerVendorContractCleanup() {
|
|
@@ -109,6 +148,7 @@ exports.isArgumentsPayload = __webpack_exports__.isArgumentsPayload;
|
|
|
109
148
|
exports.loadScripts = __webpack_exports__.loadScripts;
|
|
110
149
|
exports.registerVendorContractCleanup = __webpack_exports__.registerVendorContractCleanup;
|
|
111
150
|
exports.toArgs = __webpack_exports__.toArgs;
|
|
151
|
+
exports.updateScripts = __webpack_exports__.updateScripts;
|
|
112
152
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
113
153
|
"deniedConsents",
|
|
114
154
|
"grantedMarketingConsents",
|
|
@@ -118,7 +158,8 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
118
158
|
"isArgumentsPayload",
|
|
119
159
|
"loadScripts",
|
|
120
160
|
"registerVendorContractCleanup",
|
|
121
|
-
"toArgs"
|
|
161
|
+
"toArgs",
|
|
162
|
+
"updateScripts"
|
|
122
163
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
123
164
|
Object.defineProperty(exports, '__esModule', {
|
|
124
165
|
value: true
|
package/dist/e2e-test-utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterEach, vi } from "vitest";
|
|
2
|
-
import { clearAllScripts, loadScripts } from "../../core/src/libs/script-loader";
|
|
2
|
+
import { clearAllScripts, loadScripts, updateScripts } from "../../core/src/libs/script-loader";
|
|
3
3
|
const deniedConsents = {
|
|
4
4
|
necessary: true,
|
|
5
5
|
functionality: false,
|
|
@@ -40,19 +40,53 @@ function resetVendorGlobals() {
|
|
|
40
40
|
for (const key of [
|
|
41
41
|
'TiktokAnalyticsObject',
|
|
42
42
|
'UET',
|
|
43
|
+
'$crisp',
|
|
44
|
+
'CRISP_COOKIE_DOMAIN',
|
|
45
|
+
'CRISP_COOKIE_EXPIRE',
|
|
46
|
+
'CRISP_RUNTIME_CONFIG',
|
|
47
|
+
'CRISP_TOKEN_ID',
|
|
48
|
+
'CRISP_WEBSITE_ID',
|
|
49
|
+
'Intercom',
|
|
43
50
|
'_linkedin_data_partner_ids',
|
|
44
51
|
'_linkedin_partner_id',
|
|
45
52
|
'_fbq',
|
|
53
|
+
'_hjSettings',
|
|
54
|
+
'_paq',
|
|
55
|
+
'_satellite',
|
|
56
|
+
'_snaptr',
|
|
57
|
+
'adobeDataLayer',
|
|
58
|
+
'amplitude',
|
|
59
|
+
'analytics',
|
|
60
|
+
'clarity',
|
|
46
61
|
'dataLayer',
|
|
47
62
|
'databuddy',
|
|
48
63
|
'databuddyConfig',
|
|
49
64
|
'fbq',
|
|
50
65
|
'google_tag_data',
|
|
66
|
+
'heap',
|
|
67
|
+
'heapReadyCb',
|
|
68
|
+
'htevents',
|
|
69
|
+
'hj',
|
|
70
|
+
'intercomSettings',
|
|
51
71
|
'lintrk',
|
|
72
|
+
'LogRocket',
|
|
73
|
+
'mixpanel',
|
|
74
|
+
'pirsch',
|
|
75
|
+
'pirschClearSession',
|
|
76
|
+
'pirschInit',
|
|
77
|
+
'pirschNotFound',
|
|
78
|
+
'plausible',
|
|
52
79
|
'posthog',
|
|
80
|
+
'rdt',
|
|
81
|
+
'rudderanalytics',
|
|
82
|
+
'rudderAnalyticsBuildType',
|
|
83
|
+
'RudderSnippetVersion',
|
|
84
|
+
'snaptr',
|
|
53
85
|
'ttq',
|
|
54
86
|
'twq',
|
|
55
|
-
'uetq'
|
|
87
|
+
'uetq',
|
|
88
|
+
'va',
|
|
89
|
+
'vaq'
|
|
56
90
|
])delete win[key];
|
|
57
91
|
}
|
|
58
92
|
function registerVendorContractCleanup() {
|
|
@@ -64,4 +98,4 @@ function registerVendorContractCleanup() {
|
|
|
64
98
|
resetVendorGlobals();
|
|
65
99
|
});
|
|
66
100
|
}
|
|
67
|
-
export { deniedConsents, grantedMarketingConsents, grantedMeasurementConsents, installBodyProbe, installHeadProbe, isArgumentsPayload, loadScripts, registerVendorContractCleanup, toArgs };
|
|
101
|
+
export { deniedConsents, grantedMarketingConsents, grantedMeasurementConsents, installBodyProbe, installHeadProbe, isArgumentsPayload, loadScripts, registerVendorContractCleanup, toArgs, updateScripts };
|
package/dist/engine/compile.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
package/dist/engine/runtime.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -27,7 +31,18 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
31
|
resolvedManifestToScript: ()=>resolvedManifestToScript
|
|
28
32
|
});
|
|
29
33
|
const external_c15t_namespaceObject = require("c15t");
|
|
34
|
+
const external_types_cjs_namespaceObject = require("../types.cjs");
|
|
35
|
+
function isRuntimeValue(value) {
|
|
36
|
+
if (null === value || 'object' != typeof value || Array.isArray(value)) return false;
|
|
37
|
+
const candidate = value;
|
|
38
|
+
return candidate.kind === external_types_cjs_namespaceObject.RUNTIME_VALUE_KIND && ('date' === candidate.value || 'timestamp' === candidate.value);
|
|
39
|
+
}
|
|
40
|
+
function resolveRuntimeValue(value) {
|
|
41
|
+
if ('date' === value.value) return new Date();
|
|
42
|
+
return Date.now();
|
|
43
|
+
}
|
|
30
44
|
function cloneStepValue(value) {
|
|
45
|
+
if (isRuntimeValue(value)) return resolveRuntimeValue(value);
|
|
31
46
|
if (value instanceof Date) return new Date(value);
|
|
32
47
|
if (Array.isArray(value)) return value.map((item)=>cloneStepValue(item));
|
|
33
48
|
if (null !== value && 'object' == typeof value) return Object.fromEntries(Object.entries(value).map(([key, nestedValue])=>[
|
|
@@ -138,12 +153,36 @@ function executeStep(step) {
|
|
|
138
153
|
{
|
|
139
154
|
const target = win[step.target];
|
|
140
155
|
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
156
|
+
if (!step.queue && !Array.isArray(target)) break;
|
|
141
157
|
const targetRecord = target;
|
|
142
158
|
for (const methodName of step.methods)targetRecord[methodName] = (...args)=>{
|
|
143
159
|
const queueTarget = resolveQueueTarget(win, step.queue ?? {
|
|
144
160
|
global: step.target
|
|
145
161
|
}, targetRecord);
|
|
146
162
|
if (!queueTarget) return;
|
|
163
|
+
if ('methodCall' === step.queueFormat || 'wrappedMethodCall' === step.queueFormat || 'voidMethodCall' === step.queueFormat) {
|
|
164
|
+
const promise = new Promise((resolve)=>{
|
|
165
|
+
queueTarget.push({
|
|
166
|
+
name: methodName,
|
|
167
|
+
args,
|
|
168
|
+
resolve
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
if ('wrappedMethodCall' === step.queueFormat) return {
|
|
172
|
+
promise
|
|
173
|
+
};
|
|
174
|
+
if ('voidMethodCall' === step.queueFormat) return;
|
|
175
|
+
return promise;
|
|
176
|
+
}
|
|
177
|
+
if ('callback' === step.queueFormat) return void queueTarget.push({
|
|
178
|
+
name: methodName,
|
|
179
|
+
fn: ()=>{
|
|
180
|
+
const latestTarget = win[step.target];
|
|
181
|
+
if (null === latestTarget || 'object' != typeof latestTarget && 'function' != typeof latestTarget) return;
|
|
182
|
+
const method = latestTarget[methodName];
|
|
183
|
+
if ('function' == typeof method) method.apply(latestTarget, args);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
147
186
|
queueTarget.push([
|
|
148
187
|
methodName,
|
|
149
188
|
...args
|
|
@@ -151,6 +190,26 @@ function executeStep(step) {
|
|
|
151
190
|
};
|
|
152
191
|
break;
|
|
153
192
|
}
|
|
193
|
+
case 'defineQueueClass':
|
|
194
|
+
{
|
|
195
|
+
const target = win[step.target];
|
|
196
|
+
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
197
|
+
const queueProperty = step.queueProperty ?? '_q';
|
|
198
|
+
const QueueClass = function() {
|
|
199
|
+
this[queueProperty] = [];
|
|
200
|
+
};
|
|
201
|
+
const prototype = QueueClass.prototype;
|
|
202
|
+
for (const methodName of step.methods)prototype[methodName] = function(...args) {
|
|
203
|
+
const queueTarget = this[queueProperty];
|
|
204
|
+
if (Array.isArray(queueTarget)) queueTarget.push({
|
|
205
|
+
name: methodName,
|
|
206
|
+
args
|
|
207
|
+
});
|
|
208
|
+
return this;
|
|
209
|
+
};
|
|
210
|
+
target[step.name] = QueueClass;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
154
213
|
case 'defineGlobalMethods':
|
|
155
214
|
{
|
|
156
215
|
const target = win[step.target];
|
|
@@ -250,22 +309,57 @@ function mapConsentState(mapping, consents) {
|
|
|
250
309
|
}
|
|
251
310
|
return result;
|
|
252
311
|
}
|
|
312
|
+
function partitionConsentIds(mapping, consents) {
|
|
313
|
+
const allowedConsentIds = [];
|
|
314
|
+
const deniedConsentIds = [];
|
|
315
|
+
for (const [c15tCategory, consentIds] of Object.entries(mapping)){
|
|
316
|
+
const isGranted = consents[c15tCategory];
|
|
317
|
+
for (const consentId of consentIds)(isGranted ? allowedConsentIds : deniedConsentIds).push(consentId);
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
allowedConsentIds,
|
|
321
|
+
deniedConsentIds
|
|
322
|
+
};
|
|
323
|
+
}
|
|
253
324
|
function getConsentSignalSteps(resolvedManifest, mode, consents) {
|
|
254
325
|
if (!resolvedManifest.consentMapping || !resolvedManifest.consentSignal) return [];
|
|
255
|
-
const mapped = mapConsentState(resolvedManifest.consentMapping, consents);
|
|
256
326
|
switch(resolvedManifest.consentSignal){
|
|
257
327
|
case 'gtag':
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
'
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
328
|
+
{
|
|
329
|
+
const mapped = mapConsentState(resolvedManifest.consentMapping, consents);
|
|
330
|
+
return [
|
|
331
|
+
{
|
|
332
|
+
type: 'callGlobal',
|
|
333
|
+
global: resolvedManifest.consentSignalTarget ?? 'gtag',
|
|
334
|
+
args: [
|
|
335
|
+
'consent',
|
|
336
|
+
mode,
|
|
337
|
+
mapped
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
];
|
|
341
|
+
}
|
|
342
|
+
case 'rudderstack':
|
|
343
|
+
{
|
|
344
|
+
const partition = partitionConsentIds(resolvedManifest.consentMapping, consents);
|
|
345
|
+
return [
|
|
346
|
+
{
|
|
347
|
+
type: 'callGlobal',
|
|
348
|
+
global: resolvedManifest.consentSignalTarget ?? 'rudderanalytics',
|
|
349
|
+
method: 'consent',
|
|
350
|
+
args: [
|
|
351
|
+
{
|
|
352
|
+
consentManagement: {
|
|
353
|
+
enabled: true,
|
|
354
|
+
provider: 'custom',
|
|
355
|
+
allowedConsentIds: partition.allowedConsentIds,
|
|
356
|
+
deniedConsentIds: partition.deniedConsentIds
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
];
|
|
362
|
+
}
|
|
269
363
|
}
|
|
270
364
|
}
|
|
271
365
|
function resolvedManifestToScript(resolvedManifest) {
|