Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "@mparticle/web-rokt-wsdk-kit",
"name": "@mparticle/web-rokt-kit",
"version": "0.0.2",
"main": "dist/RoktWsdk-Kit.common.js",
"description": "mParticle integration kit for Rokt",
"main": "dist/Rokt-Kit.common.js",
"files": [
"dist/RoktWsdk-Kit.common.js"
"dist/Rokt-Kit.common.js",
"dist/Rokt-Kit.iife.js"
],
"repository": "https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt",
"scripts": {
"build": "ENVIRONMENT=production rollup --config rollup.config.js",
"build": "rollup --config rollup.config.js",
"build:test": "rollup --config rollup.test.config.js",
"lint": "eslint src/ test/src/",
"lint:fix": "eslint src/ test/src/ --fix",
"watch": "ENVIRONMENT=production rollup --config rollup.config.js -w",
"test": "npm run build && npm run build:test && DEBUG=false karma start test/karma.config.js",
"test:debug": "npm run build && npm run build:test && DEBUG=true karma start test/karma.config.js",
"testEndToEnd": "ENVIRONMENT=testEndToEnd rollup --config rollup.config.js && open http://localhost:8082/node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/index.html && node node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/server"
"watch": "rollup --config rollup.config.js -w",
"test": "npm run build && npm run build:test && karma start test/karma.config.js",
"test:debug": "npm run build && npm run build:test && karma start test/karma.config.js"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@mparticle/web-kit-wrapper": "^1.0.5",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
Expand Down
68 changes: 27 additions & 41 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,38 @@
// This file is all boilerplate. Do not edit unless you know what you're doing.
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

import {
production,
testEndToEnd,
} from './node_modules/@mparticle/web-kit-wrapper/rollup.base';
const kitName = 'Rokt';

const { ENVIRONMENT } = process.env;
const initialization = require('./src/initialization');
const outputs = {
name: `${kitName}Kit`,
exports: 'named',
strict: true,
};

const plugins = [
resolve({
browser: true
}),
commonjs(),
];

const productionBuilds = {
iife: {
input: production.input,
export default [
{
input: `src/${kitName}-Kit.js`,
output: {
...production.output,
...outputs,
format: 'iife',
file: `dist/${initialization.name}-Kit.iife.js`,
name: `${initialization.name}Kit`,
file: `dist/${kitName}-Kit.iife.js`,
},
plugins: [...production.plugins],
plugins,
},
cjs: {
input: production.input,
{
input: `src/${kitName}-Kit.js`,
output: {
...production.output,
...outputs,
format: 'cjs',
file: `dist/${initialization.name}-Kit.common.js`,
name: `${initialization.name}Kit`,
file: `dist/${kitName}-Kit.common.js`,
},
plugins: [...production.plugins],
},
};

const testEndToEndBuild = {
input: testEndToEnd.input,
output: {
...testEndToEnd.output,
format: 'iife',
file: 'test/end-to-end-testapp/build/compilation.js',
name: `${initialization.name}Kit`,
plugins,
},
plugins: [...testEndToEnd.plugins],
};

let selectedBuilds = [];
if (ENVIRONMENT === 'production') {
selectedBuilds.push(productionBuilds.iife, productionBuilds.cjs);
} else if (ENVIRONMENT === 'testEndToEnd') {
selectedBuilds.push(testEndToEndBuild);
}

export default selectedBuilds;
];
129 changes: 129 additions & 0 deletions src/Rokt-Kit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* eslint-disable no-undef */
// Copyright 2025 mParticle, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var roktLauncherScript = 'https://apps.rokt.com/wsdk/integrations/launcher.js';

var name = 'Rokt';
var moduleId = 181;

var constructor = function () {
var self = this;

self.name = name;
self.moduleId = moduleId;

function initForwarder(settings) {
var accountId = settings.accountId;
var sandboxMode = settings.sandboxMode === 'True';

if (!window.Rokt || !(window.Rokt && window.Rokt.currentLauncher)) {
var target = document.head || document.body;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = roktLauncherScript;
script.async = true;
script.crossOrigin = 'anonymous';
script.fetchPriority = 'high';
script.id = 'rokt-launcher';

script.onload = function () {
// Once the script loads, ensure the Rokt object is available
if (
window.Rokt &&
typeof window.Rokt.createLauncher === 'function' &&
window.Rokt.currentLauncher === undefined
) {
window.Rokt.createLauncher({
accountId: accountId,
sandbox: sandboxMode,
})
.then(function (launcher) {
// Assign the launcher to a global variable for later access
window.Rokt.currentLauncher = launcher;
window.mParticle.Rokt.attachLauncher(launcher);
})
.catch(function (err) {
console.error('Error creating Rokt launcher:', err);
});
} else {
console.error(
'Rokt object is not available after script load.'
);
}
};

script.onerror = function (error) {
console.error('Error loading Rokt launcher script:', error);
};

target.appendChild(script);
} else {
console.warn('Unable to find Rokt on the page');
}
}

this.init = initForwarder;
};

function getId() {
return moduleId;
}

function register(config) {
if (!config) {
window.console.log(
'You must pass a config object to register the kit ' + name
);
return;
}
if (!isObject(config)) {
window.console.log(
"'config' must be an object. You passed in a " + typeof config
);
return;
}

if (isObject(config.kits)) {
config.kits[name] = {
constructor: constructor,
};
} else {
config.kits = {};
config.kits[name] = {
constructor: constructor,
};
}
window.console.log(
'Successfully registered ' + name + ' to your mParticle configuration'
);
}

function isObject(val) {
return (
val != null && typeof val === 'object' && Array.isArray(val) === false
);
}

if (window && window.mParticle && window.mParticle.addForwarder) {
window.mParticle.addForwarder({
name: name,
constructor: constructor,
getId: getId,
});
}

module.exports = {
register: register,
};
66 changes: 0 additions & 66 deletions src/commerce-handler.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/common.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/event-handler.js

This file was deleted.

Loading
Loading