@mparticle/web-rokt-kit 1.4.1 → 1.5.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.
@@ -17,8 +17,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
17
17
  // See the License for the specific language governing permissions and
18
18
  // limitations under the License.
19
19
 
20
- var roktLauncherScript = 'https://apps.rokt.com/wsdk/integrations/launcher.js';
21
-
22
20
  var name = 'Rokt';
23
21
  var moduleId = 181;
24
22
 
@@ -34,6 +32,20 @@ var constructor = function () {
34
32
  self.filteredUser = {};
35
33
  self.userAttributes = {};
36
34
 
35
+ /**
36
+ * Generates the Rokt launcher script URL with optional domain override
37
+ * @param {string} domain - The CNAME domain to use for overriding the launcher url
38
+ * @returns {string} The complete launcher script URL
39
+ */
40
+ function generateLauncherScript(_domain) {
41
+ // Override domain if a customer is using a CNAME
42
+ // If a customer is using a CNAME, a domain will be passed. If not, we use the default domain.
43
+ var domain = typeof _domain !== 'undefined' ? _domain : 'apps.rokt.com';
44
+ var protocol = 'https://';
45
+ var launcherPath = '/wsdk/integrations/launcher.js';
46
+
47
+ return [protocol, domain, launcherPath].join('');
48
+ }
37
49
  /**
38
50
  * Passes attributes to the Rokt Web SDK for client-side hashing
39
51
  * @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher#hash-attributes
@@ -59,13 +71,16 @@ var constructor = function () {
59
71
  var accountId = settings.accountId;
60
72
  self.userAttributes = filteredUserAttributes;
61
73
  self.onboardingExpProvider = settings.onboardingExpProvider;
62
-
74
+ var domain = window.mParticle.Rokt.domain;
63
75
  var launcherOptions = window.mParticle.Rokt.launcherOptions || {};
64
76
  launcherOptions.integrationName = generateIntegrationName(
65
77
  launcherOptions.integrationName
66
78
  );
67
79
 
68
80
  if (testMode) {
81
+ self.testHelpers = {
82
+ generateLauncherScript: generateLauncherScript,
83
+ };
69
84
  attachLauncher(accountId, launcherOptions);
70
85
  return;
71
86
  }
@@ -74,7 +89,7 @@ var constructor = function () {
74
89
  var target = document.head || document.body;
75
90
  var script = document.createElement('script');
76
91
  script.type = 'text/javascript';
77
- script.src = roktLauncherScript;
92
+ script.src = generateLauncherScript(domain);
78
93
  script.async = true;
79
94
  script.crossOrigin = 'anonymous';
80
95
  script.fetchPriority = 'high';
@@ -284,7 +299,7 @@ var constructor = function () {
284
299
 
285
300
  function generateIntegrationName(customIntegrationName) {
286
301
  var coreSdkVersion = window.mParticle.getVersion();
287
- var kitVersion = "1.4.1";
302
+ var kitVersion = "1.5.0";
288
303
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
289
304
 
290
305
  if (customIntegrationName) {
@@ -16,8 +16,6 @@ var RoktKit = (function (exports) {
16
16
  // See the License for the specific language governing permissions and
17
17
  // limitations under the License.
18
18
 
19
- var roktLauncherScript = 'https://apps.rokt.com/wsdk/integrations/launcher.js';
20
-
21
19
  var name = 'Rokt';
22
20
  var moduleId = 181;
23
21
 
@@ -33,6 +31,20 @@ var RoktKit = (function (exports) {
33
31
  self.filteredUser = {};
34
32
  self.userAttributes = {};
35
33
 
34
+ /**
35
+ * Generates the Rokt launcher script URL with optional domain override
36
+ * @param {string} domain - The CNAME domain to use for overriding the launcher url
37
+ * @returns {string} The complete launcher script URL
38
+ */
39
+ function generateLauncherScript(_domain) {
40
+ // Override domain if a customer is using a CNAME
41
+ // If a customer is using a CNAME, a domain will be passed. If not, we use the default domain.
42
+ var domain = typeof _domain !== 'undefined' ? _domain : 'apps.rokt.com';
43
+ var protocol = 'https://';
44
+ var launcherPath = '/wsdk/integrations/launcher.js';
45
+
46
+ return [protocol, domain, launcherPath].join('');
47
+ }
36
48
  /**
37
49
  * Passes attributes to the Rokt Web SDK for client-side hashing
38
50
  * @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher#hash-attributes
@@ -58,13 +70,16 @@ var RoktKit = (function (exports) {
58
70
  var accountId = settings.accountId;
59
71
  self.userAttributes = filteredUserAttributes;
60
72
  self.onboardingExpProvider = settings.onboardingExpProvider;
61
-
73
+ var domain = window.mParticle.Rokt.domain;
62
74
  var launcherOptions = window.mParticle.Rokt.launcherOptions || {};
63
75
  launcherOptions.integrationName = generateIntegrationName(
64
76
  launcherOptions.integrationName
65
77
  );
66
78
 
67
79
  if (testMode) {
80
+ self.testHelpers = {
81
+ generateLauncherScript: generateLauncherScript,
82
+ };
68
83
  attachLauncher(accountId, launcherOptions);
69
84
  return;
70
85
  }
@@ -73,7 +88,7 @@ var RoktKit = (function (exports) {
73
88
  var target = document.head || document.body;
74
89
  var script = document.createElement('script');
75
90
  script.type = 'text/javascript';
76
- script.src = roktLauncherScript;
91
+ script.src = generateLauncherScript(domain);
77
92
  script.async = true;
78
93
  script.crossOrigin = 'anonymous';
79
94
  script.fetchPriority = 'high';
@@ -283,7 +298,7 @@ var RoktKit = (function (exports) {
283
298
 
284
299
  function generateIntegrationName(customIntegrationName) {
285
300
  var coreSdkVersion = window.mParticle.getVersion();
286
- var kitVersion = "1.4.1";
301
+ var kitVersion = "1.5.0";
287
302
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
288
303
 
289
304
  if (customIntegrationName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "files": [