@blotoutio/providers-bing-sdk 1.11.6 → 1.12.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/index.cjs.js CHANGED
@@ -48,6 +48,38 @@ const init = ({ manifest }) => {
48
48
  initBing(manifest.variables['tagId']);
49
49
  };
50
50
 
51
+ const canLog = () => {
52
+ try {
53
+ return localStorage.getItem('edgeTagDebug') === '1';
54
+ }
55
+ catch {
56
+ return false;
57
+ }
58
+ };
59
+ const prefix = `[EdgeTag]`;
60
+ const logger = {
61
+ log: (...args) => {
62
+ if (canLog()) {
63
+ console.log(prefix, ...args);
64
+ }
65
+ },
66
+ error: (...args) => {
67
+ if (canLog()) {
68
+ console.error(prefix, ...args);
69
+ }
70
+ },
71
+ info: (...args) => {
72
+ if (canLog()) {
73
+ console.info(prefix, ...args);
74
+ }
75
+ },
76
+ trace: (...args) => {
77
+ if (canLog()) {
78
+ console.trace(prefix, ...args);
79
+ }
80
+ },
81
+ };
82
+
51
83
  const getConversionEventName = (eventName) => {
52
84
  if (!eventName) {
53
85
  return;
@@ -78,7 +110,20 @@ const handleTag = ({ data, eventName, manifestVariables, }) => {
78
110
  if (!window || !eventName || !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'])) {
79
111
  return;
80
112
  }
81
- const conversionEventName = getConversionEventName(eventName);
113
+ let mapping = new Map();
114
+ let conversionEventName;
115
+ if (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['mappedEvents']) {
116
+ try {
117
+ mapping = new Map(JSON.parse(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['mappedEvents']));
118
+ }
119
+ catch (error) {
120
+ logger.error('Could not parse mapped events', error);
121
+ }
122
+ conversionEventName = mapping.get(eventName);
123
+ }
124
+ else {
125
+ conversionEventName = getConversionEventName(eventName);
126
+ }
82
127
  if (!conversionEventName) {
83
128
  return;
84
129
  }
@@ -88,7 +133,7 @@ const handleTag = ({ data, eventName, manifestVariables, }) => {
88
133
 
89
134
  const tag = ({ data, eventName, manifestVariables }) => {
90
135
  const payload = {
91
- sdkVersion: "1.11.6" ,
136
+ sdkVersion: "1.12.0" ,
92
137
  };
93
138
  if (window.edgeUET && manifestVariables['enableBrowser'] === '1') {
94
139
  handleTag({ data, eventName, manifestVariables });
package/index.js CHANGED
@@ -49,6 +49,38 @@ var ProvidersBingSdk = (function () {
49
49
  initBing(manifest.variables['tagId']);
50
50
  };
51
51
 
52
+ const canLog = () => {
53
+ try {
54
+ return localStorage.getItem('edgeTagDebug') === '1';
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ };
60
+ const prefix = `[EdgeTag]`;
61
+ const logger = {
62
+ log: (...args) => {
63
+ if (canLog()) {
64
+ console.log(prefix, ...args);
65
+ }
66
+ },
67
+ error: (...args) => {
68
+ if (canLog()) {
69
+ console.error(prefix, ...args);
70
+ }
71
+ },
72
+ info: (...args) => {
73
+ if (canLog()) {
74
+ console.info(prefix, ...args);
75
+ }
76
+ },
77
+ trace: (...args) => {
78
+ if (canLog()) {
79
+ console.trace(prefix, ...args);
80
+ }
81
+ },
82
+ };
83
+
52
84
  const getConversionEventName = (eventName) => {
53
85
  if (!eventName) {
54
86
  return;
@@ -79,7 +111,20 @@ var ProvidersBingSdk = (function () {
79
111
  if (!window || !eventName || !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'])) {
80
112
  return;
81
113
  }
82
- const conversionEventName = getConversionEventName(eventName);
114
+ let mapping = new Map();
115
+ let conversionEventName;
116
+ if (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['mappedEvents']) {
117
+ try {
118
+ mapping = new Map(JSON.parse(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['mappedEvents']));
119
+ }
120
+ catch (error) {
121
+ logger.error('Could not parse mapped events', error);
122
+ }
123
+ conversionEventName = mapping.get(eventName);
124
+ }
125
+ else {
126
+ conversionEventName = getConversionEventName(eventName);
127
+ }
83
128
  if (!conversionEventName) {
84
129
  return;
85
130
  }
@@ -89,7 +134,7 @@ var ProvidersBingSdk = (function () {
89
134
 
90
135
  const tag = ({ data, eventName, manifestVariables }) => {
91
136
  const payload = {
92
- sdkVersion: "1.11.6" ,
137
+ sdkVersion: "1.12.0" ,
93
138
  };
94
139
  if (window.edgeUET && manifestVariables['enableBrowser'] === '1') {
95
140
  handleTag({ data, eventName, manifestVariables });
package/index.mjs CHANGED
@@ -46,6 +46,38 @@ const init = ({ manifest }) => {
46
46
  initBing(manifest.variables['tagId']);
47
47
  };
48
48
 
49
+ const canLog = () => {
50
+ try {
51
+ return localStorage.getItem('edgeTagDebug') === '1';
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ };
57
+ const prefix = `[EdgeTag]`;
58
+ const logger = {
59
+ log: (...args) => {
60
+ if (canLog()) {
61
+ console.log(prefix, ...args);
62
+ }
63
+ },
64
+ error: (...args) => {
65
+ if (canLog()) {
66
+ console.error(prefix, ...args);
67
+ }
68
+ },
69
+ info: (...args) => {
70
+ if (canLog()) {
71
+ console.info(prefix, ...args);
72
+ }
73
+ },
74
+ trace: (...args) => {
75
+ if (canLog()) {
76
+ console.trace(prefix, ...args);
77
+ }
78
+ },
79
+ };
80
+
49
81
  const getConversionEventName = (eventName) => {
50
82
  if (!eventName) {
51
83
  return;
@@ -76,7 +108,20 @@ const handleTag = ({ data, eventName, manifestVariables, }) => {
76
108
  if (!window || !eventName || !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'])) {
77
109
  return;
78
110
  }
79
- const conversionEventName = getConversionEventName(eventName);
111
+ let mapping = new Map();
112
+ let conversionEventName;
113
+ if (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['mappedEvents']) {
114
+ try {
115
+ mapping = new Map(JSON.parse(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['mappedEvents']));
116
+ }
117
+ catch (error) {
118
+ logger.error('Could not parse mapped events', error);
119
+ }
120
+ conversionEventName = mapping.get(eventName);
121
+ }
122
+ else {
123
+ conversionEventName = getConversionEventName(eventName);
124
+ }
80
125
  if (!conversionEventName) {
81
126
  return;
82
127
  }
@@ -86,7 +131,7 @@ const handleTag = ({ data, eventName, manifestVariables, }) => {
86
131
 
87
132
  const tag = ({ data, eventName, manifestVariables }) => {
88
133
  const payload = {
89
- sdkVersion: "1.11.6" ,
134
+ sdkVersion: "1.12.0" ,
90
135
  };
91
136
  if (window.edgeUET && manifestVariables['enableBrowser'] === '1') {
92
137
  handleTag({ data, eventName, manifestVariables });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-bing-sdk",
3
- "version": "1.11.6",
3
+ "version": "1.12.0",
4
4
  "description": "Bing Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",