From 899b486b0f497b27055cccb612fd9a449c712ba4 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Fri, 12 Jul 2024 12:17:45 -0400 Subject: [PATCH 1/9] ci: Add Reusable PR Workflow --- .github/workflows/pull-request.yml | 32 ------------------------ .github/workflows/reusable-workflows.yml | 23 +++++++++-------- package.json | 1 + 3 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml deleted file mode 100644 index c840480..0000000 --- a/.github/workflows/pull-request.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Web Kit SDK Build & Test - -on: pull_request - -jobs: - build-and-test: - name: Build and Test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: NPM install - uses: actions/setup-node@v4 - with: - node-version: 20.x - - - name: Run NPM CI - run: npm ci - - - name: Build Files - run: npm run build - - - name: Run Core tests - run: npm run test - - - name: Archive npm failure logs - uses: actions/upload-artifact@v4 - if: failure() - with: - name: npm-logs - path: ~/.npm/_logs diff --git a/.github/workflows/reusable-workflows.yml b/.github/workflows/reusable-workflows.yml index a733811..765b113 100644 --- a/.github/workflows/reusable-workflows.yml +++ b/.github/workflows/reusable-workflows.yml @@ -1,15 +1,18 @@ name: Reusable Workflows on: - pull_request: + pull_request: jobs: - pr-branch-check-name: - name: Check PR for semantic branch name - uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-check-name.yml@stable - pr-title-check: - name: Check PR for semantic title - uses: mParticle/mparticle-workflows/.github/workflows/pr-title-check.yml@stable - pr-branch-target-gitflow: - name: Check PR for semantic target branch - uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-target-gitflow.yml@stable + web-kit-pull-request: + name: Run Web Kit PR Workflow + uses: mParticle/mparticle-workflows/.github/workflows/web-kit-pull-request.yml@370b52b2c5b6e6b0b74e88062da8f44603260b13 + pr-branch-check-name: + name: Check PR for semantic branch name + uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-check-name.yml@stable + pr-title-check: + name: Check PR for semantic title + uses: mParticle/mparticle-workflows/.github/workflows/pr-title-check.yml@stable + pr-branch-target-gitflow: + name: Check PR for semantic target branch + uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-target-gitflow.yml@stable diff --git a/package.json b/package.json index 546b5d1..91e75be 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "scripts": { "build": "ENVIRONMENT=production rollup --config rollup.config.js", "build:test": "rollup --config rollup.test.config.js", + "lint": "eslint src/ test/src/", "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", From 4bc6296d230e7374d2a2a243a0faf0764684aa83 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Fri, 12 Jul 2024 12:29:17 -0400 Subject: [PATCH 2/9] Update workflow branch --- .github/workflows/reusable-workflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-workflows.yml b/.github/workflows/reusable-workflows.yml index 765b113..0b1b536 100644 --- a/.github/workflows/reusable-workflows.yml +++ b/.github/workflows/reusable-workflows.yml @@ -6,7 +6,7 @@ on: jobs: web-kit-pull-request: name: Run Web Kit PR Workflow - uses: mParticle/mparticle-workflows/.github/workflows/web-kit-pull-request.yml@370b52b2c5b6e6b0b74e88062da8f44603260b13 + uses: mParticle/mparticle-workflows/.github/workflows/web-kit-pull-request.yml@ci/SQDSDKS-6549-add-reusable-pr-workflow pr-branch-check-name: name: Check PR for semantic branch name uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-check-name.yml@stable From 09764979407f647ffdbffbd9517c87ce732d981e Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Tue, 16 Jul 2024 10:30:24 -0400 Subject: [PATCH 3/9] Update to stable version of reusable pr action --- .github/workflows/reusable-workflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-workflows.yml b/.github/workflows/reusable-workflows.yml index 0b1b536..95183a5 100644 --- a/.github/workflows/reusable-workflows.yml +++ b/.github/workflows/reusable-workflows.yml @@ -6,7 +6,7 @@ on: jobs: web-kit-pull-request: name: Run Web Kit PR Workflow - uses: mParticle/mparticle-workflows/.github/workflows/web-kit-pull-request.yml@ci/SQDSDKS-6549-add-reusable-pr-workflow + uses: mParticle/mparticle-workflows/.github/workflows/web-kit-pull-request.yml@stable pr-branch-check-name: name: Check PR for semantic branch name uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-check-name.yml@stable From c2691a4c67ff156021fbbfee4fb9d3bd4b4d7699 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Tue, 16 Jul 2024 10:46:00 -0400 Subject: [PATCH 4/9] style: Clean up lint --- .eslintrc | 2 +- package.json | 1 + src/commerce-handler.js | 133 +++++++++++++++++++--------------- src/common.js | 4 +- src/event-handler.js | 22 +----- src/identity-handler.js | 27 ++----- src/initialization.js | 15 ++-- src/session-handler.js | 8 +- src/user-attribute-handler.js | 16 +--- test/src/tests.js | 31 +++----- 10 files changed, 110 insertions(+), 149 deletions(-) diff --git a/.eslintrc b/.eslintrc index 5f5cc11..df73644 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,7 +16,7 @@ "before": true, "beforeEach": true, "after": true, - "Leanplum": true + "heap": true }, "extends": ["plugin:prettier/recommended", "eslint:recommended"], "plugins": ["prettier"], diff --git a/package.json b/package.json index 91e75be..d01e7b8 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "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", diff --git a/src/commerce-handler.js b/src/commerce-handler.js index 1b4bdd6..27c3683 100644 --- a/src/commerce-handler.js +++ b/src/commerce-handler.js @@ -8,56 +8,56 @@ var ProductActionTypes = { Refund: 17, RemoveFromCart: 11, ViewDetail: 15, -} +}; var ProductActionNames = { - 0: "Unknown", - 1: "Add To Cart", - 2: "Remove From Cart", - 3: "Checkout", - 4: "Checkout Option", - 5: "Click", - 6: "View Detail", - 7: "Purchase", - 8: "Refund", - 9: "Add To Wishlist", - 10: "Remove From Wishlist", -} + 0: 'Unknown', + 1: 'Add To Cart', + 2: 'Remove From Cart', + 3: 'Checkout', + 4: 'Checkout Option', + 5: 'Click', + 6: 'View Detail', + 7: 'Purchase', + 8: 'Refund', + 9: 'Add To Wishlist', + 10: 'Remove From Wishlist', +}; var PromotionType = { PromotionClick: 19, PromotionView: 18, -} +}; var PromotionTypeNames = { - 19: "Click", - 18: "View", -} + 19: 'Click', + 18: 'View', +}; var HeapConstants = { - EventNameItem: "Item", - EventNameProductAction: "Product Action Event", - EventNameProductActionPart: "Product Action: ", - EventNamePromotionPart: "Promotion: ", - EventNameImpression: "Impression Event", + EventNameItem: 'Item', + EventNameProductAction: 'Product Action Event', + EventNameProductActionPart: 'Product Action: ', + EventNamePromotionPart: 'Promotion: ', + EventNameImpression: 'Impression Event', MaxPropertyLength: 1023, - KeyProductName: "product_name", - KeyProductPrice: "product_price", - KeyProductQuantity: "product_quantity", - KeyProductTotalProductAmount: "total_product_amount", - KeyProductSku: "product_id", - KeyProductBrand: "product_brand", - KeyProductCategory: "product_category", - KeyProductSkus: "skus", - KeyPromotionCreative: "creative", - KeyPromotionId: "id", - KeyPromotionPosition: "position", -} + KeyProductName: 'product_name', + KeyProductPrice: 'product_price', + KeyProductQuantity: 'product_quantity', + KeyProductTotalProductAmount: 'total_product_amount', + KeyProductSku: 'product_id', + KeyProductBrand: 'product_brand', + KeyProductCategory: 'product_category', + KeyProductSkus: 'skus', + KeyPromotionCreative: 'creative', + KeyPromotionId: 'id', + KeyPromotionPosition: 'position', +}; function CommerceHandler(common) { this.common = common || {}; } -CommerceHandler.prototype.logCommerceEvent = function(event) { +CommerceHandler.prototype.logCommerceEvent = function (event) { /* Sample ecommerce event schema: { @@ -128,11 +128,10 @@ CommerceHandler.prototype.logCommerceEvent = function(event) { break; default: events = buildProductActionEvents(event); - }; + } for (var i = 0; i < events.length; i++) { - var event = events[i]; - window.heap.track(event.Name, event.Properties); + window.heap.track(events[i].Name, events[i].Properties); } }; @@ -144,23 +143,28 @@ function buildImpressionEvents(event) { var impression = event.ProductImpressions[i]; var productSkus = []; if (impression.ProductList.length > 0) { - for(var j = 0; j < impression.ProductList.length; j++) { + for (var j = 0; j < impression.ProductList.length; j++) { var product = impression.ProductList[j]; var eventObject = buildItemEvent(product); events.push(eventObject.event); - if(eventObject.sku) { + if (eventObject.sku) { productSkus.push(eventObject.sku); } } } - events.push(buildActionEvent(event, HeapConstants.EventNameImpression, productSkus)) + events.push( + buildActionEvent( + event, + HeapConstants.EventNameImpression, + productSkus + ) + ); } } - return events; -}; +} function buildPromotionEvents(event) { var events = []; @@ -171,13 +175,17 @@ function buildPromotionEvents(event) { var eventObject = buildPromotionItemEvent(promotion); events.push(eventObject.event); - if(eventObject.id) { + if (eventObject.id) { promotionIds.push(eventObject.id); } } } - var promotionActionEventName = HeapConstants.EventNamePromotionPart + PromotionTypeNames[event.EventCategory]; - events.push(buildActionEvent(event, promotionActionEventName, promotionIds)); + var promotionActionEventName = + HeapConstants.EventNamePromotionPart + + PromotionTypeNames[event.EventCategory]; + events.push( + buildActionEvent(event, promotionActionEventName, promotionIds) + ); return events; } @@ -202,8 +210,10 @@ function buildProductActionEvents(event) { if (!event.ProductAction) { actionEventName = HeapConstants.EventNameProductAction; } else { - var productActionKey = ProductActionNames[event.ProductAction.ProductActionType]; - actionEventName = HeapConstants.EventNameProductActionPart + productActionKey; + var productActionKey = + ProductActionNames[event.ProductAction.ProductActionType]; + actionEventName = + HeapConstants.EventNameProductActionPart + productActionKey; } events.push(buildActionEvent(event, actionEventName, productSkus)); @@ -212,9 +222,10 @@ function buildProductActionEvents(event) { } function buildActionEvent(event, eventName, productSkus) { - var properties = event && event.EventAttributes ? event.EventAttributes : {}; + var properties = + event && event.EventAttributes ? event.EventAttributes : {}; properties[HeapConstants.KeyProductSkus] = productSkus; - return {Name: eventName, Properties: properties}; + return { Name: eventName, Properties: properties }; } function buildItemEvent(product) { @@ -236,9 +247,12 @@ function buildItemEvent(product) { properties[HeapConstants.KeyProductQuantity] = validatedQuantity; } - var validatedTotalProductAmount = validateHeapPropertyValue(product.TotalProductAmount); + var validatedTotalProductAmount = validateHeapPropertyValue( + product.TotalProductAmount + ); if (validatedTotalProductAmount) { - properties[HeapConstants.KeyProductTotalProductAmount] = validatedTotalProductAmount; + properties[HeapConstants.KeyProductTotalProductAmount] = + validatedTotalProductAmount; } var validatedSku = validateHeapPropertyValue(product.Sku); @@ -259,18 +273,19 @@ function buildItemEvent(product) { event.Name = HeapConstants.EventNameItem; event.Properties = properties; - return {event: event, sku: validatedSku}; + return { event: event, sku: validatedSku }; } function buildPromotionItemEvent(promotion) { var event = {}; - var properties = promotion && promotion.Attributes ? promotion.Attributes : {}; + var properties = + promotion && promotion.Attributes ? promotion.Attributes : {}; var validatedPromotionValues = { KeyPromotionCreative: validateHeapPropertyValue(promotion.Creative), KeyPromotionId: validateHeapPropertyValue(promotion.Id), KeyPromotionPosition: validateHeapPropertyValue(promotion.Position), - } + }; var validatedPromotionKeys = Object.keys(validatedPromotionValues); for (var i = 0; i < validatedPromotionKeys.length; i++) { @@ -286,17 +301,17 @@ function buildPromotionItemEvent(promotion) { event.Properties = properties; var promotionId = validatedPromotionValues.KeyPromotionId; - return {event: event, id: promotionId}; + return { event: event, id: promotionId }; } -function validateHeapPropertyValue(value){ - if (typeof value === "boolean" || typeof value === "number") { +function validateHeapPropertyValue(value) { + if (typeof value === 'boolean' || typeof value === 'number') { return value; } if (value === undefined || value === null) { return value; - } else if (value.length > HeapConstants.MaxPropertyLength){ + } else if (value.length > HeapConstants.MaxPropertyLength) { return value.substring(0, HeapConstants.MaxPropertyLength); } else { return value; diff --git a/src/common.js b/src/common.js index 11f4d4e..a62e0d7 100644 --- a/src/common.js +++ b/src/common.js @@ -2,6 +2,6 @@ function Common() {} Common.prototype.exampleMethod = function () { return 'I am an example'; -} +}; -module.exports = Common; \ No newline at end of file +module.exports = Common; diff --git a/src/event-handler.js b/src/event-handler.js index aea6b0a..b536b0e 100644 --- a/src/event-handler.js +++ b/src/event-handler.js @@ -16,12 +16,8 @@ A non-ecommerce event has the following schema: function EventHandler(common) { this.common = common || {}; } -EventHandler.prototype.logEvent = function(event) { - var ignoredEvents = [ - 'click', - 'change', - 'submit' - ]; +EventHandler.prototype.logEvent = function (event) { + var ignoredEvents = ['click', 'change', 'submit']; if (ignoredEvents.includes(event.EventName.toLowerCase())) { return; @@ -29,19 +25,5 @@ EventHandler.prototype.logEvent = function(event) { window.heap.track(event.EventName, event.EventAttributes); }; -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) { - /* 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; diff --git a/src/identity-handler.js b/src/identity-handler.js index 62f3b99..57af87f 100644 --- a/src/identity-handler.js +++ b/src/identity-handler.js @@ -21,42 +21,31 @@ 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.onUserIdentified = function (mParticleUser) { if (!mParticleUser && !mParticleUser.getUserIdentities()) { return; } var identitiesObject = mParticleUser.getUserIdentities(); - var identity = identitiesObject.userIdentities[this.common.userIdentificationType]; + var identity = + identitiesObject.userIdentities[this.common.userIdentificationType]; if (identity) { window.heap.identify(identity); } }; -IdentityHandler.prototype.onIdentifyComplete = function( - mParticleUser, - identityApiRequest -) {}; -IdentityHandler.prototype.onLoginComplete = function( - mParticleUser, - identityApiRequest -) {}; -IdentityHandler.prototype.onLogoutComplete = function( - mParticleUser, - identityApiRequest -) { +IdentityHandler.prototype.onIdentifyComplete = function () {}; +IdentityHandler.prototype.onLoginComplete = function () {}; +IdentityHandler.prototype.onLogoutComplete = function () { window.heap.resetIdentity(); }; -IdentityHandler.prototype.onModifyComplete = function( - mParticleUser, - identityApiRequest -) {}; +IdentityHandler.prototype.onModifyComplete = function () {}; /* 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( +IdentityHandler.prototype.onSetUserIdentity = function ( forwarderSettings, id, type diff --git a/src/initialization.js b/src/initialization.js index aaac2f5..f1b1db6 100644 --- a/src/initialization.js +++ b/src/initialization.js @@ -1,7 +1,8 @@ var renderSnippet = function (appId) { + // prettier-ignore window.heapReadyCb=window.heapReadyCb||[],window.heap=window.heap||[],heap.load=function(e,t){window.heap.envId=e,window.heap.clientConfig=t=t||{},window.heap.clientConfig.shouldFetchServerConfig=!1;var a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src="https://cdn.us.heap-api.com/config/"+e+"/heap_config.js";var r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(a,r);var n=["init","startTracking","stopTracking","track","resetIdentity","identify","getSessionId","getUserId","getIdentity","addUserProperties","addEventProperties","removeEventProperty","clearEventProperties","addAccountProperties","addAdapter","addTransformer","addTransformerFn","onReady","addPageviewProperties","removePageviewProperty","clearPageviewProperties","trackPageview"],i=function(e){return function(){var t=Array.prototype.slice.call(arguments,0);window.heapReadyCb.push({name:e,fn:function(){heap[e]&&heap[e].apply(heap,t)}})}};for(var p=0;p tags Generally, our integrations create script tags and append them to the . Please follow the following format as a guide: */ - common.userIdentificationType = forwarderSettings.userIdentificationType + common.userIdentificationType = + forwarderSettings.userIdentificationType; - var forwardWebRequestsServerSide = forwarderSettings.forwardWebRequestsServerSide === 'True'; + var forwardWebRequestsServerSide = + forwarderSettings.forwardWebRequestsServerSide === 'True'; common.forwardWebRequestsServerSide = forwardWebRequestsServerSide; if (!forwardWebRequestsServerSide) { if (!window.heap) { diff --git a/src/session-handler.js b/src/session-handler.js index 96d5bf4..0d65be7 100644 --- a/src/session-handler.js +++ b/src/session-handler.js @@ -1,10 +1,6 @@ var sessionHandler = { - onSessionStart: function(event) { - - }, - onSessionEnd: function(event) { - - } + onSessionStart: function () {}, + onSessionEnd: function () {}, }; module.exports = sessionHandler; diff --git a/src/user-attribute-handler.js b/src/user-attribute-handler.js index d00a122..cb187d5 100644 --- a/src/user-attribute-handler.js +++ b/src/user-attribute-handler.js @@ -10,18 +10,11 @@ For any additional methods, see http://docs.mparticle.com/developers/sdk/javascr function UserAttributeHandler(common) { this.common = common || {}; } -UserAttributeHandler.prototype.onRemoveUserAttribute = function( - key, - mParticleUser -) { +UserAttributeHandler.prototype.onRemoveUserAttribute = function (key) { delete this.common.userAttributes[key]; window.heap.addUserProperties(this.common.userAttributes); }; -UserAttributeHandler.prototype.onSetUserAttribute = function( - key, - value, - mParticleUser -) { +UserAttributeHandler.prototype.onSetUserAttribute = function (key, value) { if (!this.common.userAttributes) { this.common.userAttributes = {}; } @@ -29,10 +22,5 @@ UserAttributeHandler.prototype.onSetUserAttribute = function( this.common.userAttributes[key] = value; window.heap.addUserProperties(this.common.userAttributes); }; -UserAttributeHandler.prototype.onConsentStateUpdated = function( - oldState, - newState, - mParticleUser -) {}; module.exports = UserAttributeHandler; diff --git a/test/src/tests.js b/test/src/tests.js index 9eb748a..2f03b59 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -118,11 +118,11 @@ describe('Heap Forwarder', function () { this.getIdentity = function () { return self.identity; - } + }; this.resetIdentity = function () { self.identity = null; - } + }; this.addUserProperties = function (properties) { self.addUserPropertiesCalled = true; @@ -267,7 +267,7 @@ describe('Heap Forwarder', function () { mParticle.forwarder.onLogoutComplete(); - expect(window.heap.getIdentity()).to.be.null + expect(window.heap.getIdentity()).to.be.null; done(); }); }); @@ -339,43 +339,34 @@ describe('Heap Forwarder', function () { }, }; - var purchaseEvent = { + var purchaseEvent = { EventName: 'Test Purchase Event', EventDataType: MessageType.Commerce, EventCategory: EventType.ProductPurchase, ProductAction: { ProductActionType: ProductActionType.Purchase, - ProductList: [ - product, - product, - ], + ProductList: [product, product], TransactionId: 123, Affiliation: 'my-affiliation', TotalAmount: 450, TaxAmount: 40, ShippingAmount: 10, - CouponCode: null - } + CouponCode: null, + }, }; - var impressionEvent = { + var impressionEvent = { EventName: 'eCommerce - Impression', EventDataType: 16, EventCategory: 22, ProductImpressions: [ { ProductImpressionList: 'Suggested Products List1', - ProductList: [ - product, - product, - ], + ProductList: [product, product], }, { ProductImpressionList: 'Suggested Products List2', - ProductList: [ - product, - product, - ], + ProductList: [product, product], }, ], }; @@ -391,7 +382,7 @@ describe('Heap Forwarder', function () { { Id: 'my_promo_1', Creative: 'sale_banner_1', - Position: 'top' + Position: 'top', }, { Id: 'my_promo_2', From 2c6a047855c54330dd5a91629b9ceba28196e36f Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Tue, 16 Jul 2024 11:03:41 -0400 Subject: [PATCH 5/9] Address PR Comments --- src/event-handler.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/event-handler.js b/src/event-handler.js index b536b0e..e508eab 100644 --- a/src/event-handler.js +++ b/src/event-handler.js @@ -26,4 +26,15 @@ EventHandler.prototype.logEvent = function (event) { window.heap.track(event.EventName, event.EventAttributes); }; +// This is used by the SDK Wrapper even if it is not used in an extended kit. +// eslint-disable-next-line no-unused-vars +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; From 2ec12b04906e713e065f0455d026a5e7b1ba2adf Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Tue, 16 Jul 2024 11:04:19 -0400 Subject: [PATCH 6/9] Address PR Comments --- src/event-handler.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/event-handler.js b/src/event-handler.js index e508eab..580d00e 100644 --- a/src/event-handler.js +++ b/src/event-handler.js @@ -29,8 +29,7 @@ EventHandler.prototype.logEvent = function (event) { // This is used by the SDK Wrapper even if it is not used in an extended kit. // eslint-disable-next-line no-unused-vars EventHandler.prototype.logPageView = function (event) { - /* - The schema for a logPagView event is the same, but noteworthy differences are as follows: + /* 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(...) } From ab30dcdaed81ca18ee43f88af8a2e9fc848a2292 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Tue, 16 Jul 2024 11:13:11 -0400 Subject: [PATCH 7/9] Address PR Comments --- src/event-handler.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/event-handler.js b/src/event-handler.js index 580d00e..babacf4 100644 --- a/src/event-handler.js +++ b/src/event-handler.js @@ -26,6 +26,16 @@ EventHandler.prototype.logEvent = function (event) { window.heap.track(event.EventName, event.EventAttributes); }; +// This is used by the SDK Wrapper even if it is not used in an extended kit. +// eslint-disable-next-line no-unused-vars +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" + // } +}; + // This is used by the SDK Wrapper even if it is not used in an extended kit. // eslint-disable-next-line no-unused-vars EventHandler.prototype.logPageView = function (event) { From 0cde03105e20e486eb214e715f30439aee4ba644 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Tue, 16 Jul 2024 11:13:48 -0400 Subject: [PATCH 8/9] Address PR Comments --- src/event-handler.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/event-handler.js b/src/event-handler.js index babacf4..2059c31 100644 --- a/src/event-handler.js +++ b/src/event-handler.js @@ -39,11 +39,11 @@ EventHandler.prototype.logError = function (event) { // This is used by the SDK Wrapper even if it is not used in an extended kit. // eslint-disable-next-line no-unused-vars 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(...) - } - */ + // 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; From 5be0fa8ce07c227497e8f862280e070848ec1b99 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Wed, 17 Jul 2024 09:19:48 -0400 Subject: [PATCH 9/9] Address PR Comments --- src/initialization.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/initialization.js b/src/initialization.js index f1b1db6..b18bfe7 100644 --- a/src/initialization.js +++ b/src/initialization.js @@ -23,6 +23,12 @@ var initialization = { eventQueue, isInitialized, common + + // The following are all optional parameters that may not be used by your forwarder. + // appVersion, + // appName, + // customFlags, + // clientId ) { /* `forwarderSettings` contains your SDK specific settings such as apiKey that your customer needs in order to initialize your SDK properly */ if (!testMode) {