@artisan-commerce/analytics-web 0.2.0-canary.96 → 0.2.0-canary.98

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/dist/bundle.d.ts CHANGED
@@ -454,6 +454,7 @@ interface FacebookPixelProviderConfig {
454
454
  * @property {string} fbPixelId Facebook pixel id
455
455
  * @property {string} apiURL api URL
456
456
  * @property {string} authToken user's authorization token
457
+ * @property {string} testCode code for test conversion api
457
458
  */
458
459
  interface FacebookConversionsApiConfig {
459
460
  eventSourceUrl: string;
@@ -462,6 +463,7 @@ interface FacebookConversionsApiConfig {
462
463
  fbPixelId: string;
463
464
  apiURL: string;
464
465
  authToken: string;
466
+ testCode?: string;
465
467
  }
466
468
  /**
467
469
  * Facebook Pixel event shared parameters.
@@ -50,7 +50,7 @@ State$1._instance = null;
50
50
 
51
51
  var name = "@artisan-commerce/analytics-web";
52
52
  var description = "Artisn commerce analytics web library";
53
- var version = "0.2.0-canary.95";
53
+ var version = "0.2.0-canary.97";
54
54
  var main = "./dist/bundle.cjs.js";
55
55
  var module = "./dist/bundle.esm.js";
56
56
  var types = "./dist/bundle.d.ts";
@@ -83,8 +83,8 @@ var dependencies = {
83
83
  "snake-case": "^3.0.4"
84
84
  };
85
85
  var devDependencies = {
86
- "@artisan-commerce/products": "0.9.0-canary.60",
87
- "@artisan-commerce/shopping-cart-core": "0.12.0-canary.91",
86
+ "@artisan-commerce/products": "0.9.0-canary.61",
87
+ "@artisan-commerce/shopping-cart-core": "0.12.0-canary.92",
88
88
  "@artisan-commerce/state": "0.3.0-canary.11",
89
89
  "@artisan-commerce/types": "0.14.0-canary.39"
90
90
  };
@@ -424,7 +424,7 @@ class FacebookPixel extends AnalyticsProvider {
424
424
  initTag.innerText = `!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='${this.version}';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init', '${this.trackingId}');fbq('trackSingle', '${this.trackingId}', 'PageView');`;
425
425
  const noScript = document.createElement("noscript");
426
426
  noScript.innerHTML = `
427
- <img height="1" width="1" style="display:none"
427
+ <img height="1" width="1" style="display:none"
428
428
  src="https://www.facebook.com/tr?id={${this.trackingId}}&noscript=1"/>
429
429
  `;
430
430
  document.head.appendChild(linkTag);
@@ -622,7 +622,6 @@ const initAnalytics = (config) => {
622
622
  const isServer = typeof window === "undefined";
623
623
  if (isServer)
624
624
  return;
625
- State().setState({ initialized: true });
626
625
  const { initialized } = State().state;
627
626
  if (initialized) {
628
627
  logMessage("initAnalytics has been called more than once. This behaviour will very likely result in unexpected outcomes so its call was skipped. Please make sure initAnalytics is only called once.", "debug");
@@ -818,7 +817,7 @@ const checkAnalyticsInitialized = (providers) => {
818
817
 
819
818
  const postFacebookConversion = async (config) => {
820
819
  const { apiURL, eventName, customData, authToken } = config;
821
- const { eventSourceUrl } = config;
820
+ const { eventSourceUrl, testCode } = config;
822
821
  const { countryISOCode, fbAccessToken, fbPixelId } = config;
823
822
  const { platform = "web" } = customData != null ? customData : {};
824
823
  const { debug } = State().state;
@@ -833,7 +832,8 @@ const postFacebookConversion = async (config) => {
833
832
  countryISOCode,
834
833
  customData,
835
834
  fbAccessToken,
836
- fbPixelId
835
+ fbPixelId,
836
+ testCode
837
837
  };
838
838
  try {
839
839
  const data = await fetch(url, {