@epigraph/epigraph-std-lib 4.2.0 → 4.3.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.
package/README.md
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
# INTRODUCTION
|
|
2
|
-
|
|
3
|
-
Epigraph Standard Library or epigraph-std-lib is a collection of standards that we follow across our solutions. The idea is to have a single source of truth across solutions while ensuring that the dependencies are always up to date with the industry standards.
|
|
4
|
-
|
|
5
|
-
### EPIGRAPH
|
|
6
|
-
A global object that must only be initialized once per session and provides some common functionalities across solutions in that session.
|
|
7
|
-
|
|
8
|
-
### EPIGRAPH LIBRARY EXPORTS
|
|
9
|
-
|
|
10
|
-
| Name | Description |
|
|
11
|
-
|---|---|
|
|
12
|
-
| EpigraphBaseSolutionHtmlElement | A base class intended to enforce some common functionalities across our solutions, built by extending the HTMLElement |
|
|
13
|
-
| EpigraphBaseSolutionLitElement | A base class intended to enforce some common functionalities across our solutions, built by extending the LitElement |
|
|
14
|
-
| EpigraphLogger | A logger class that provides a convenient way for logging info, warning or errors in any given session |
|
|
15
|
-
| EpigraphQrCoreGenerator | A Utility class that allows the generation of a QR code from a give string input |
|
|
16
|
-
| EpigraphUnitsConverter | |
|
|
17
|
-
| EpigraphUrlProcessor | |
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# HOW TO:
|
|
21
|
-
|
|
22
|
-
### Add a new EpigraphLibrary:
|
|
23
|
-
1. Create a new directory under lib/EpigraphLibs/`<MyEpigraphLibrary>`
|
|
24
|
-
2. Create the module file/s. Ensure that the names of these files are in camelCase.
|
|
25
|
-
3. Write a test for this Library under tests/<MyEpigraphLibrary.test.ts>
|
|
26
|
-
4. Add the module that you wish to export as an entry in vite.config.ts > defineConfig > build > entry, similar to other entries in there. This will bundle the new module on build.
|
|
27
|
-
5. Go to package.json:
|
|
28
|
-
- Add the new module entry under exports similar to other entries in that field.
|
|
29
|
-
- Add the new module entry under typesVersions similar to other entries in that field.
|
|
30
|
-
|
|
31
|
-
### Use the library
|
|
32
|
-
This library exports the module into submodules to allow for better tree shaking when bundling the final product. Here is how you can import the submodules individually.
|
|
33
|
-
|
|
34
|
-
```javascript
|
|
35
|
-
// Epigraph Object
|
|
36
|
-
import { Epigraph } from "@epigraph/epigraph-std-lib/dist/Epigraph/epigraph";
|
|
37
|
-
|
|
38
|
-
// Epigraph libs
|
|
39
|
-
import { EpigraphAnalytics } from "@epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphAnalytics";
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Exported Submodules:
|
|
44
|
-
| Name | Description |
|
|
45
|
-
|---|---|
|
|
46
|
-
| @epigraph/epigraph-std-lib/dist/Epigraph/epigraph | A base class intended to enforce some common functionalities across our solutions, built by extending the HTMLElement |
|
|
47
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphAnalytics | An Analytics modules that exports handy ways to log analytics across our solutions |
|
|
48
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphLogger | A Logger modules that exports handy ways to log across our solutions |
|
|
49
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphNexusApi | A Nexus API modules that exports handy ways to interact with the Nexus API across our solutions |
|
|
50
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphQrCodeGenerator | A QR Code generator modules that exports handy ways to generate QR Codes across our solutions |
|
|
51
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphResultFactory | A Result Factory modules that exports handy ways to generate Result objects across our solutions |
|
|
52
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphUnitsConverter | A Utility class that allows conversion between different standard unit, including but not limited to Distance, Color, etc. |
|
|
53
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphUrlProcessor | A Utility class that provides various methods to generate, process, manipulate URLs |
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Write a test:
|
|
57
|
-
We use [vitest](https://vitest.dev/guide/) to write tests in this repository using [happy-dom](https://www.npmjs.com/package/happy-dom) to support some but not all browser functionalities. In order to write a new test:
|
|
58
|
-
|
|
59
|
-
1. Create a new file for a specific test under tests/ as `<MyEpigraphLibrary>`.test.ts
|
|
60
|
-
2. Write a test following the instructions and samples [here](https://vitest.dev/guide/#writing-tests)
|
|
61
|
-
3. Make sure to import the library from "../dist/epigraph-std-lib" to avoid any issues that might come up after bundling.
|
|
62
|
-
4. Open a terminal and execute "npm run test". This will build all the libraries under dist/ and then run tests using those.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# REFERENCES
|
|
66
|
-
A huge thanks to everyone who inspired the setup for this repository:
|
|
67
|
-
1. [Andreas Riedmuller's Article](https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma)
|
|
68
|
-
2. [Vitest Docs](https://vitest.dev/guide/)
|
|
1
|
+
# INTRODUCTION
|
|
2
|
+
|
|
3
|
+
Epigraph Standard Library or epigraph-std-lib is a collection of standards that we follow across our solutions. The idea is to have a single source of truth across solutions while ensuring that the dependencies are always up to date with the industry standards.
|
|
4
|
+
|
|
5
|
+
### EPIGRAPH
|
|
6
|
+
A global object that must only be initialized once per session and provides some common functionalities across solutions in that session.
|
|
7
|
+
|
|
8
|
+
### EPIGRAPH LIBRARY EXPORTS
|
|
9
|
+
|
|
10
|
+
| Name | Description |
|
|
11
|
+
|---|---|
|
|
12
|
+
| EpigraphBaseSolutionHtmlElement | A base class intended to enforce some common functionalities across our solutions, built by extending the HTMLElement |
|
|
13
|
+
| EpigraphBaseSolutionLitElement | A base class intended to enforce some common functionalities across our solutions, built by extending the LitElement |
|
|
14
|
+
| EpigraphLogger | A logger class that provides a convenient way for logging info, warning or errors in any given session |
|
|
15
|
+
| EpigraphQrCoreGenerator | A Utility class that allows the generation of a QR code from a give string input |
|
|
16
|
+
| EpigraphUnitsConverter | |
|
|
17
|
+
| EpigraphUrlProcessor | |
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# HOW TO:
|
|
21
|
+
|
|
22
|
+
### Add a new EpigraphLibrary:
|
|
23
|
+
1. Create a new directory under lib/EpigraphLibs/`<MyEpigraphLibrary>`
|
|
24
|
+
2. Create the module file/s. Ensure that the names of these files are in camelCase.
|
|
25
|
+
3. Write a test for this Library under tests/<MyEpigraphLibrary.test.ts>
|
|
26
|
+
4. Add the module that you wish to export as an entry in vite.config.ts > defineConfig > build > entry, similar to other entries in there. This will bundle the new module on build.
|
|
27
|
+
5. Go to package.json:
|
|
28
|
+
- Add the new module entry under exports similar to other entries in that field.
|
|
29
|
+
- Add the new module entry under typesVersions similar to other entries in that field.
|
|
30
|
+
|
|
31
|
+
### Use the library
|
|
32
|
+
This library exports the module into submodules to allow for better tree shaking when bundling the final product. Here is how you can import the submodules individually.
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
// Epigraph Object
|
|
36
|
+
import { Epigraph } from "@epigraph/epigraph-std-lib/dist/Epigraph/epigraph";
|
|
37
|
+
|
|
38
|
+
// Epigraph libs
|
|
39
|
+
import { EpigraphAnalytics } from "@epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphAnalytics";
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Exported Submodules:
|
|
44
|
+
| Name | Description |
|
|
45
|
+
|---|---|
|
|
46
|
+
| @epigraph/epigraph-std-lib/dist/Epigraph/epigraph | A base class intended to enforce some common functionalities across our solutions, built by extending the HTMLElement |
|
|
47
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphAnalytics | An Analytics modules that exports handy ways to log analytics across our solutions |
|
|
48
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphLogger | A Logger modules that exports handy ways to log across our solutions |
|
|
49
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphNexusApi | A Nexus API modules that exports handy ways to interact with the Nexus API across our solutions |
|
|
50
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphQrCodeGenerator | A QR Code generator modules that exports handy ways to generate QR Codes across our solutions |
|
|
51
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphResultFactory | A Result Factory modules that exports handy ways to generate Result objects across our solutions |
|
|
52
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphUnitsConverter | A Utility class that allows conversion between different standard unit, including but not limited to Distance, Color, etc. |
|
|
53
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphUrlProcessor | A Utility class that provides various methods to generate, process, manipulate URLs |
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Write a test:
|
|
57
|
+
We use [vitest](https://vitest.dev/guide/) to write tests in this repository using [happy-dom](https://www.npmjs.com/package/happy-dom) to support some but not all browser functionalities. In order to write a new test:
|
|
58
|
+
|
|
59
|
+
1. Create a new file for a specific test under tests/ as `<MyEpigraphLibrary>`.test.ts
|
|
60
|
+
2. Write a test following the instructions and samples [here](https://vitest.dev/guide/#writing-tests)
|
|
61
|
+
3. Make sure to import the library from "../dist/epigraph-std-lib" to avoid any issues that might come up after bundling.
|
|
62
|
+
4. Open a terminal and execute "npm run test". This will build all the libraries under dist/ and then run tests using those.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# REFERENCES
|
|
66
|
+
A huge thanks to everyone who inspired the setup for this repository:
|
|
67
|
+
1. [Andreas Riedmuller's Article](https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma)
|
|
68
|
+
2. [Vitest Docs](https://vitest.dev/guide/)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=Symbol("data"),u=Symbol("next"),m=class p{constructor(e){this[g]=e,this[u]=null}get data(){return this[g]}set next(e){if(!(e instanceof p)&&e!==null)throw new Error("This node is not an instance of the custom class 'Node'.");this[u]=e}get next(){return this[u]}};let f=m;const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=Symbol("data"),u=Symbol("next"),m=class p{constructor(e){this[g]=e,this[u]=null}get data(){return this[g]}set next(e){if(!(e instanceof p)&&e!==null)throw new Error("This node is not an instance of the custom class 'Node'.");this[u]=e}get next(){return this[u]}};let f=m;const l=Symbol("head");class q{constructor(){this[l]=null}set head(e){this[l]=e}get head(){return this[l]}addToTail(e){let t=this.head;if(t){for(;t.next!==null;)t=t?.next;return t.next=new f(e)}return this.head=new f(e)}removeHead(){const e=this.head;if(e)return this.head=e.next,e.data}}const y=Symbol("queue"),o=Symbol("size");class h{constructor(){this[y]=new q,this[o]=0}get queue(){return this[y]}get size(){return this[o]}enqueue(e){this.queue.addToTail(e),this[o]++}dequeue(){const e=this.queue.removeHead();return this[o]--,e}}class A{constructor(e,t,n,s){this.name=this.pluginName="GA3-PLUGIN",this.trackingID=e,this.verboseLogging=t,this.user=n,this.trackerName=s,this.queue=new h,this.trackerInterval=0,this.trackerCreated=!1}sendEvent(e){if(this.queue.enqueue(e),window.ga!==void 0&&typeof ga=="function")try{this.dequeueAndSendEvents()}catch(t){this.logger(t)}else this.logger("Cannot send Google Analytics 3 event: ga function is not defined.");return!0}dequeueAndSendEvents(){if(this.trackerCreated){let e=this.queue.size;for(let t=0;t<e;t++){const n=this.queue.dequeue();ga(`${this.trackerName}.send`,n.type,n.category,n.action,n.label,n.interaction),this.logger(`Google Analytics 3 event successfully sent: ${n.action}`)}}else this.logger("Cannot sent Google Analytics 3 event: tracker was not created.")}async createTracker(){if(window.ga!==void 0&&typeof ga=="function")try{ga("create",this.trackingID,"auto",this.trackerName,{userId:this.user});const e=new URL(window.location.href);ga(`${this.trackerName}.set`,"page",e.pathname),ga(`${this.trackerName}.set`,"location",e.href),this.trackerCreated=!0,this.logger("Google Analytics 3 tracker successfully created."),this.dequeueAndSendEvents(),window.clearInterval(this.trackerInterval)}catch(e){this.logger(e)}else this.logger("Error: Cannot create tracker, ga function is not defined.")}logger(e){this.verboseLogging&&console.warn(e)}getUniquePluginIdentifier(){return this.pluginName+"-"+this.trackingID}setupPlugin(){var e=0;this.trackerInterval=window.setInterval(()=>{this.createTracker(),++e===10&&(window.clearInterval(this.trackerInterval),this.logger("Error: Failed to create Google Analytics tracker in the allotted timeframe."))},1e3)}}class P{constructor(e,t){this.name=this.pluginName="GA4-PLUGIN",this.trackingID=e,this.verboseLogging=t,this.queue=new h,this.dataLayer=window.dataLayer,this.dataLayerName="dataLayer",this.setupDataLayer(),this.initGtag(this.dataLayerName,this.trackingID)}setupDataLayer(){if(this.dataLayer)return;const t=this.findGA4ScriptInfo(this.trackingID)?.l;t&&(this.dataLayerName=t,this.dataLayer=window[t])}initGtag(e="dataLayer",t){window.epgDataLayerName=e,typeof window.gtag!="function"&&(window.gtag=function(){window[window.epgDataLayerName].push(arguments)},window.gtag("js",new Date),window.gtag("config",t,{send_page_view:!1}))}async sendEvent(e,t){this.queue.enqueue(e);let n=!0;if(t&&(n=t.hasConsent()),this.dataLayer!==void 0&&n)try{await this.dequeueAndSendEvents()}catch(s){this.logger(s)}else this.logger("Cannot send Google Analytics 4 event: dataLayer is not defined.")}async dequeueAndSendEvents(){let e=this.queue.size;for(let t=0;t<e;t++){const n=this.queue.dequeue();let s={send_to:this.trackingID,event_action:n.action,event_category:n.category,event_label:n.label,epg_event_tag:""};if("parameters"in n&&Object.assign(s,n.parameters),JSON.stringify(s).length>459)try{let r=await this.sendGA4LongParameters(s);s={send_to:this.trackingID,event_action:n.action,event_category:n.category,event_label:n.label,epg_event_tag:r}}catch{}gtag("event",n.action,s),this.logger(`Google Analytics 4 event successfully sent: ${n.action}`)}}logger(e){this.verboseLogging&&console.warn(e)}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){this.dataLayer!==void 0&&this.dequeueAndSendEvents()}async sendGA4LongParameters(e){const t="https://api.myepigraph.com/api/analytics/ga4/custom",n={parameters:e};try{const s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});if(s.ok){const a=await s.json();return a&&a.id?a.id:""}else return""}catch{return""}}findGA4ScriptInfo(e){const t=document.querySelectorAll("script[src]");for(const n of t){const s=n.getAttribute("src");if(s&&s.includes(e)){const a=new URL(s,location.href),r=Object.fromEntries(a.searchParams.entries());return{fullSrc:a.href,id:r.id||void 0,l:r.l||void 0}}}return null}}class L{constructor(e,t,n,s,a=!1){this.sessionId=t,this.xPath=n,this.name=this.pluginName="NEXUS-PLUGIN",this.trackingID=e,this.verboseLogging=s,this.queue=new h,this.url=a?"https://nexus.epigraph.dev/api/analytics/event":"https://api.myepigraph.com/api/analytics/event"}async sendEvent(e,t){this.queue.enqueue(e);let n=!0;t&&(n=t.hasConsent()),n&&await this.dequeueAndSendEvents()}async dequeueAndSendEvents(){for(let e=0;e<this.queue.size;e++){const t=this.queue.dequeue(),n={experience_id:this.trackingID,action:t.action,parameters:t.parameters};try{return(await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","EPG-SESSION-ID":this.sessionId,"EPG-XPATH":this.xPath,Origin:typeof window<"u"?window.location.origin:""},body:JSON.stringify(n)})).status===204,""}catch{return""}}return""}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){}}class w{constructor(e){this.consentSet=!1,this.consent=!1,this.pluginName="OneTrustConsentPlugin",this.consentIdentifier=e,this.consent=!1,this.addConsentChangedListener()}hasConsent(){if(this.consentSet)return this.consent;if(window.OnetrustActiveGroup!==void 0){let e=window.OnetrustActiveGroup;e!==void 0&&e.split(",").forEach(n=>{n===this.consentIdentifier&&(this.consent=!0,this.consentSet=!0)})}return this.consent}addConsentChangedListener(){window.addEventListener("load",()=>{this.hasConsent(),window.OneTrust!==void 0&&typeof window.OneTrust=="object"&&window.OneTrust.OnConsentChanged(()=>{this.consentSet=!1,this.hasConsent()})})}}var d=(i=>(i.OneTrust="onetrust",i))(d||{});/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright (c) 2023 Epigraph LLC. All Rights Reserved.
|
|
4
4
|
*
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
|
-
*/var
|
|
16
|
+
*/var v;const c=Symbol("analyticsPluginsMap");v=c;class S{constructor(e,t){this[v]=new Map,this._consentPlugin=null,e&&t&&(this._consentPlugin=this.buildConsentPlugin(e,t))}addEventPlugin(e){this[c].has(e.getUniquePluginIdentifier())||(this[c].set(e.getUniquePluginIdentifier(),e),e.setupPlugin())}sendEvent(e){this[c].forEach(t=>{t.sendEvent(e,this._consentPlugin)})}buildConsentPlugin(e,t){return e.toLowerCase()===d.OneTrust.toLowerCase()?new w(t):null}}exports.ConsentPluginNames=d;exports.EpigraphAnalytics=S;exports.GA3AnalyticsPlugin=A;exports.GA4AnalyticsPlugin=P;exports.NexusAnalyticsPlugin=L;exports.OneTrustConsentPlugin=w;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const d = Symbol("data"), u = Symbol("next"),
|
|
1
|
+
const d = Symbol("data"), u = Symbol("next"), v = class y {
|
|
2
2
|
constructor(e) {
|
|
3
3
|
this[d] = e, this[u] = null;
|
|
4
4
|
}
|
|
@@ -16,7 +16,7 @@ const d = Symbol("data"), u = Symbol("next"), w = class y {
|
|
|
16
16
|
return this[u];
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
let g =
|
|
19
|
+
let g = v;
|
|
20
20
|
const h = Symbol("head");
|
|
21
21
|
class m {
|
|
22
22
|
constructor() {
|
|
@@ -62,7 +62,7 @@ class l {
|
|
|
62
62
|
return this[o]--, e;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
class
|
|
65
|
+
class L {
|
|
66
66
|
constructor(e, t, n, s) {
|
|
67
67
|
this.name = this.pluginName = "GA3-PLUGIN", this.trackingID = e, this.verboseLogging = t, this.user = n, this.trackerName = s, this.queue = new l(), this.trackerInterval = 0, this.trackerCreated = !1;
|
|
68
68
|
}
|
|
@@ -145,7 +145,7 @@ class I {
|
|
|
145
145
|
}, 1e3);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
class
|
|
148
|
+
class I {
|
|
149
149
|
constructor(e, t) {
|
|
150
150
|
this.name = this.pluginName = "GA4-PLUGIN", this.trackingID = e, this.verboseLogging = t, this.queue = new l(), this.dataLayer = window.dataLayer, this.dataLayerName = "dataLayer", this.setupDataLayer(), this.initGtag(this.dataLayerName, this.trackingID);
|
|
151
151
|
}
|
|
@@ -155,9 +155,9 @@ class A {
|
|
|
155
155
|
t && (this.dataLayerName = t, this.dataLayer = window[t]);
|
|
156
156
|
}
|
|
157
157
|
initGtag(e = "dataLayer", t) {
|
|
158
|
-
typeof window.gtag != "function" && (window.gtag = function() {
|
|
159
|
-
window[
|
|
160
|
-
});
|
|
158
|
+
window.epgDataLayerName = e, typeof window.gtag != "function" && (window.gtag = function() {
|
|
159
|
+
window[window.epgDataLayerName].push(arguments);
|
|
160
|
+
}, window.gtag("js", /* @__PURE__ */ new Date()), window.gtag("config", t, { send_page_view: !1 }));
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* This function will send an Event to GA3.
|
|
@@ -194,13 +194,13 @@ class A {
|
|
|
194
194
|
};
|
|
195
195
|
if ("parameters" in n && Object.assign(s, n.parameters), JSON.stringify(s).length > 459)
|
|
196
196
|
try {
|
|
197
|
-
let
|
|
197
|
+
let r = await this.sendGA4LongParameters(s);
|
|
198
198
|
s = {
|
|
199
199
|
send_to: this.trackingID,
|
|
200
200
|
event_action: n.action,
|
|
201
201
|
event_category: n.category,
|
|
202
202
|
event_label: n.label,
|
|
203
|
-
epg_event_tag:
|
|
203
|
+
epg_event_tag: r
|
|
204
204
|
};
|
|
205
205
|
} catch {
|
|
206
206
|
}
|
|
@@ -238,8 +238,8 @@ class A {
|
|
|
238
238
|
body: JSON.stringify(n)
|
|
239
239
|
});
|
|
240
240
|
if (s.ok) {
|
|
241
|
-
const
|
|
242
|
-
return
|
|
241
|
+
const a = await s.json();
|
|
242
|
+
return a && a.id ? a.id : "";
|
|
243
243
|
} else
|
|
244
244
|
return "";
|
|
245
245
|
} catch {
|
|
@@ -251,20 +251,20 @@ class A {
|
|
|
251
251
|
for (const n of t) {
|
|
252
252
|
const s = n.getAttribute("src");
|
|
253
253
|
if (s && s.includes(e)) {
|
|
254
|
-
const
|
|
254
|
+
const a = new URL(s, location.href), r = Object.fromEntries(a.searchParams.entries());
|
|
255
255
|
return {
|
|
256
|
-
fullSrc:
|
|
257
|
-
id:
|
|
258
|
-
l:
|
|
256
|
+
fullSrc: a.href,
|
|
257
|
+
id: r.id || void 0,
|
|
258
|
+
l: r.l || void 0
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
return null;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
class
|
|
266
|
-
constructor(e, t, n, s,
|
|
267
|
-
this.sessionId = t, this.xPath = n, this.name = this.pluginName = "NEXUS-PLUGIN", this.trackingID = e, this.verboseLogging = s, this.queue = new l(), this.url =
|
|
265
|
+
class A {
|
|
266
|
+
constructor(e, t, n, s, a = !1) {
|
|
267
|
+
this.sessionId = t, this.xPath = n, this.name = this.pluginName = "NEXUS-PLUGIN", this.trackingID = e, this.verboseLogging = s, this.queue = new l(), this.url = a ? "https://nexus.epigraph.dev/api/analytics/event" : "https://api.myepigraph.com/api/analytics/event";
|
|
268
268
|
}
|
|
269
269
|
async sendEvent(e, t) {
|
|
270
270
|
this.queue.enqueue(e);
|
|
@@ -346,12 +346,12 @@ var p = /* @__PURE__ */ ((i) => (i.OneTrust = "onetrust", i))(p || {});
|
|
|
346
346
|
* See the License for the specific language governing permissions and
|
|
347
347
|
* limitations under the License.
|
|
348
348
|
*/
|
|
349
|
-
var
|
|
349
|
+
var w;
|
|
350
350
|
const c = Symbol("analyticsPluginsMap");
|
|
351
|
-
|
|
351
|
+
w = c;
|
|
352
352
|
class S {
|
|
353
353
|
constructor(e, t) {
|
|
354
|
-
this[
|
|
354
|
+
this[w] = /* @__PURE__ */ new Map(), this._consentPlugin = null, e && t && (this._consentPlugin = this.buildConsentPlugin(e, t));
|
|
355
355
|
}
|
|
356
356
|
/**
|
|
357
357
|
* Epigraph Analytics uses plugins to send events to multiple trackers at a time. You can create a customer tracker
|
|
@@ -389,8 +389,8 @@ class S {
|
|
|
389
389
|
export {
|
|
390
390
|
p as ConsentPluginNames,
|
|
391
391
|
S as EpigraphAnalytics,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
L as GA3AnalyticsPlugin,
|
|
393
|
+
I as GA4AnalyticsPlugin,
|
|
394
|
+
A as NexusAnalyticsPlugin,
|
|
395
395
|
q as OneTrustConsentPlugin
|
|
396
396
|
};
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@epigraph/epigraph-std-lib",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/epigraph-std-lib.cjs",
|
|
6
|
-
"module": "./dist/epigraph-std-lib.js",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"dist/**/*"
|
|
10
|
-
],
|
|
11
|
-
"types": "./dist/epigraph-std-lib.d.ts",
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"types": "./dist/epigraph-std-lib.d.ts",
|
|
15
|
-
"import": "./dist/epigraph-std-lib.js",
|
|
16
|
-
"require": "./dist/epigraph-std-lib.cjs"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "vite",
|
|
21
|
-
"build": "tsc -b ./tsconfig.lib.json && vite build",
|
|
22
|
-
"preview": "vite preview",
|
|
23
|
-
"prepublishOnly": "npm run build",
|
|
24
|
-
"test": "npm run build && vitest"
|
|
25
|
-
},
|
|
26
|
-
"dependencies": {},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"lit": "^3.2.1",
|
|
29
|
-
"qr-creator": "^1.0.0"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/node": "^22.13.0",
|
|
33
|
-
"happy-dom": "^16.8.1",
|
|
34
|
-
"typescript": "^5.8.2",
|
|
35
|
-
"vite": "^6.0.5",
|
|
36
|
-
"vite-plugin-dts": "^4.5.0",
|
|
37
|
-
"vitest": "^3.0.5",
|
|
38
|
-
"@types/google.analytics": "^0.0.42",
|
|
39
|
-
"@types/gtag.js": "^0.0.20"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@epigraph/epigraph-std-lib",
|
|
3
|
+
"version": "4.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/epigraph-std-lib.cjs",
|
|
6
|
+
"module": "./dist/epigraph-std-lib.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"dist/**/*"
|
|
10
|
+
],
|
|
11
|
+
"types": "./dist/epigraph-std-lib.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/epigraph-std-lib.d.ts",
|
|
15
|
+
"import": "./dist/epigraph-std-lib.js",
|
|
16
|
+
"require": "./dist/epigraph-std-lib.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"build": "tsc -b ./tsconfig.lib.json && vite build",
|
|
22
|
+
"preview": "vite preview",
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"test": "npm run build && vitest"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"lit": "^3.2.1",
|
|
29
|
+
"qr-creator": "^1.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.13.0",
|
|
33
|
+
"happy-dom": "^16.8.1",
|
|
34
|
+
"typescript": "^5.8.2",
|
|
35
|
+
"vite": "^6.0.5",
|
|
36
|
+
"vite-plugin-dts": "^4.5.0",
|
|
37
|
+
"vitest": "^3.0.5",
|
|
38
|
+
"@types/google.analytics": "^0.0.42",
|
|
39
|
+
"@types/gtag.js": "^0.0.20"
|
|
40
|
+
}
|
|
41
|
+
}
|