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
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"no-prototype-builtins": "off",
"no-empty": "off",
"no-useless-escape": "off",
"no-unexpected-multiline": "off"
"no-unexpected-multiline": "off",
"no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }]
}
}
}
Empty file added dist/.keep
Empty file.
27,471 changes: 14,384 additions & 13,087 deletions package-lock.json

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
{
"name": "@mparticle/web-rokt-wsdk-kit",
"version": "1.0.0",
"main": "dist/RoktWSDK-Kit.common.js",
"files": [
"dist/RoktWSDK-Kit.common.js"
],
"repository": "https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt",
"scripts": {
"build": "ENVIRONMENT=production 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"
},
"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",
"mocha": "^5.2.0",
"chai": "^4.2.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "3.4.1",
"karma": "^5.1.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.1",
"prettier": "^2.4.1",
"rollup": "^1.15.6",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.3",
"shelljs": "0.8.3",
"should": "13.2.3",
"watchify": "^3.11.0"
},
"dependencies": {
"@mparticle/web-sdk": "^2.20.0"
},
"license": "Apache-2.0"
}
"name": "@mparticle/web-rokt-wsdk-kit",
"version": "0.0.1",
"main": "dist/RoktWsdk-Kit.common.js",
"files": [
"dist/RoktWsdk-Kit.common.js"
],
"repository": "https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt",
"scripts": {
"build": "ENVIRONMENT=production 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"
},
"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",
"mocha": "^5.2.0",
"chai": "^4.2.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "3.4.1",
"karma": "^5.1.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.1",
"prettier": "^2.4.1",
"rollup": "^1.15.6",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.3",
"shelljs": "0.8.3",
"should": "13.2.3",
"watchify": "^3.11.0"
},
"dependencies": {
"@mparticle/web-sdk": "^2.20.0"
},
"license": "Apache-2.0"
}
33 changes: 18 additions & 15 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,45 @@ module.exports = {
{ type: 'style', release: 'patch' },
{ type: 'build', release: 'patch' },
{ type: 'chore', release: 'patch' },
{ type: 'revert', release: 'patch' }
]
}
{ type: 'revert', release: 'patch' },
],
},
],
[
'@semantic-release/release-notes-generator',
{
preset: 'angular'
}
preset: 'angular',
},
],
[
'@semantic-release/changelog',
{
changelogFile: 'CHANGELOG.md'
}
changelogFile: 'CHANGELOG.md',
},
],
['@semantic-release/npm'],
[
'@semantic-release/exec',
{
prepareCmd: 'sh ./scripts/release.sh'
}
prepareCmd: 'sh ./scripts/release.sh',
},
],
[
'@semantic-release/github',
{
assets: ['dist/RoktWSDK-Kit.common.js', 'dist/RoktWSDK-Kit.iife.js']
}
assets: [
'dist/RoktWsdk-Kit.common.js',
'dist/RoktWsdk-Kit.iife.js',
],
},
],
[
'@semantic-release/git',
{
assets: ['package.json', 'package-lock.json', 'CHANGELOG.md'],
message:
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}
]
]
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
},
],
],
};
2 changes: 1 addition & 1 deletion src/commerce-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function CommerceHandler(common) {
this.common = common || {};
}

CommerceHandler.prototype.logCommerceEvent = function() {
CommerceHandler.prototype.logCommerceEvent = function () {
/*
Sample ecommerce event schema:
{
Expand Down
4 changes: 2 additions & 2 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ function Common() {}

Common.prototype.exampleMethod = function () {
return 'I am an example';
}
};

module.exports = Common;
module.exports = Common;
8 changes: 4 additions & 4 deletions src/event-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ A non-ecommerce event has the following schema:
function EventHandler(common) {
this.common = common || {};
}
EventHandler.prototype.logEvent = function(event) {};
EventHandler.prototype.logError = function(event) {
EventHandler.prototype.logEvent = function (_event) {};
EventHandler.prototype.logError = function (_event) {
// The schema for a logError event is the same, but noteworthy differences are as follows:
// {
// EventAttributes: {m: 'name of error passed into MP', s: "Error", t: 'stack trace in string form if applicable'},
// EventName: "Error"
// }
};
EventHandler.prototype.logPageView = function(event) {
EventHandler.prototype.logPageView = function (_event) {
/* The schema for a logPagView event is the same, but noteworthy differences are as follows:
{
EventAttributes: {hostname: "www.google.com", title: 'Test Page'}, // These are event attributes only if no additional event attributes are explicitly provided to mParticle.logPageView(...)
}
*/
};

module.exports = EventHandler;
module.exports = EventHandler;
36 changes: 18 additions & 18 deletions src/identity-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ For more userIdentity types, see https://docs.mparticle.com/developers/sdk/web/i
function IdentityHandler(common) {
this.common = common || {};
}
IdentityHandler.prototype.onUserIdentified = function(mParticleUser) {};
IdentityHandler.prototype.onIdentifyComplete = function(
mParticleUser,
identityApiRequest
IdentityHandler.prototype.onUserIdentified = function (_mParticleUser) {};
IdentityHandler.prototype.onIdentifyComplete = function (
_mParticleUser,
_identityApiRequest
) {};
IdentityHandler.prototype.onLoginComplete = function(
mParticleUser,
identityApiRequest
IdentityHandler.prototype.onLoginComplete = function (
_mParticleUser,
_identityApiRequest
) {};
IdentityHandler.prototype.onLogoutComplete = function(
mParticleUser,
identityApiRequest
IdentityHandler.prototype.onLogoutComplete = function (
_mParticleUser,
_identityApiRequest
) {};
IdentityHandler.prototype.onModifyComplete = function(
mParticleUser,
identityApiRequest
IdentityHandler.prototype.onModifyComplete = function (
_mParticleUser,
_identityApiRequest
) {};

/* In previous versions of the mParticle web SDK, setting user identities on
kits is only reachable via the onSetUserIdentity method below. We recommend
filling out `onSetUserIdentity` for maximum compatibility
*/
IdentityHandler.prototype.onSetUserIdentity = function(
forwarderSettings,
id,
type
IdentityHandler.prototype.onSetUserIdentity = function (
_forwarderSettings,
_id,
_type
) {};

module.exports = IdentityHandler;
module.exports = IdentityHandler;
111 changes: 82 additions & 29 deletions src/initialization.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,95 @@
var roktLauncherScript = 'https://apps.rokt.com/wsdk/integrations/launcher.js';

var initialization = {
name: 'insertSDKNameHere',
/* ****** Fill out initForwarder to load your SDK ******
name: 'RoktWsdk',
moduleId: 181,
/* ****** Fill out initForwarder to load your SDK ******
Note that not all arguments may apply to your SDK initialization.
These are passed from mParticle, but leave them even if they are not being used.
forwarderSettings contain settings that your SDK requires in order to initialize
userAttributes example: {gender: 'male', age: 25}
userIdentities example: { 1: 'customerId', 2: 'facebookId', 7: 'emailid@email.com' }
additional identityTypes can be found at https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/src/types.js#L88-L101
*/
initForwarder: function(forwarderSettings, testMode, userAttributes, userIdentities, processEvent, eventQueue, isInitialized, common, appVersion, appName, customFlags, clientId) {
/* `forwarderSettings` contains your SDK specific settings such as apiKey that your customer needs in order to initialize your SDK properly */

initForwarder: function (
forwarderSettings,
testMode,
_userAttributes,
_userIdentities,
processEvent,
eventQueue,
_isInitialized,
_common,
_appVersion,
_appName,
_customFlags,
_clientId
) {
if (!testMode) {
/* Load your Web SDK here using a variant of your snippet from your readme that your customers would generally put into their <head> tags
Generally, our integrations create script tags and append them to the <head>. Please follow the following format as a guide:
*/
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: forwarderSettings.accountId,
sandbox: forwarderSettings.sandboxMode === 'True'

Check failure on line 48 in src/initialization.js

View workflow job for this annotation

GitHub Actions / Run Web Kit PR Workflow / Build and Test

Insert `,`
})
.then(function (launcher) {
// Assign the launcher to a global variable for later access
window.Rokt.currentLauncher = launcher;
if (window['Rokt'] && eventQueue.length > 0) {
for (
var i = 0;
i < eventQueue.length;
i++
) {
processEvent(eventQueue[i]);
}
eventQueue = [];
}
Comment on lines +53 to +62
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a use case for an mparticle event to be passed to the Rokt SDK for processing? I don't think so. It doesn't hurt to have this, but if Rokt never processes mParticle events, then this can be removed.

Suggested change
if (window['Rokt'] && eventQueue.length > 0) {
for (
var i = 0;
i < eventQueue.length;
i++
) {
processEvent(eventQueue[i]);
}
eventQueue = [];
}

})
.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(
'Failed to load Rokt launcher script:',
error
);
};

// var clientScript = document.createElement('script');
// clientScript.type = 'text/javascript';
// clientScript.async = true;
// clientScript.src = 'https://www.clientscript.com/static/clientSDK.js'; // <---- Update this to be your script
// (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(clientScript);
// clientScript.onload = function() {
// if (clientSDKObject && eventQueue.length > 0) {
// // Process any events that may have been queued up while forwarder was being initialized.
// for (var i = 0; i < eventQueue.length; i++) {
// processEvent(eventQueue[i]);
// }
// // now that each queued event is processed, we empty the eventQueue
// eventQueue = [];
// }
// clientSDKObject.initialize(forwarderSettings.apiKey);
// };
} else {
// For testing, you should fill out this section in order to ensure any required initialization calls are made,
// clientSDKObject.initialize(forwarderSettings.apiKey)
target.appendChild(script);
} else {
// For testing, you can simulate initialization if needed.
console.log(
'Test mode enabled – skipping Rokt launcher script load.'
);
}
}
}
},
};

module.exports = initialization;
module.exports = initialization;
Loading
Loading