Skip to content

Commit

Permalink
GrowthCode Analytics: Updates/BugFixes (prebid#10339)
Browse files Browse the repository at this point in the history
* Update Markdown for growthCodeAnalytics modules

* GC-85 Update URL endpoint in growthCodeAnalytics module

* GC-84 added an addition event to send to server

* GC-83 Added the passage of the GCID in the POST

* Update growthCodeAnalytics module tests

* Fixed event bug

* Removed package-lock.json
  • Loading branch information
southern-growthcode authored Aug 14, 2023
1 parent 1678443 commit a4218f1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
15 changes: 3 additions & 12 deletions integrationExamples/gpt/growthcode.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,11 @@
provider: 'growthCodeAnalytics',
options: {
pid: 'TEST01',
//url: 'http://localhost:8080/v3/pb/analytics',
trackEvents: [
'auctionInit',
'auctionEnd',
'bidAdjustment',
'bidTimeout',
'bidTimeout',
'bidRequested',
'bidResponse',
'setTargeting',
'requestBids',
'addAdUnits',
'noBid',
'bidWon',
'bidderDone']
]
}
});
pbjs.setConfig({
Expand All @@ -80,7 +71,7 @@
auctionDelay: 1000,
dataProviders: [{
name: 'growthCodeRtd',
waitForIt: true,
waitForIt: false,
params: {
pid: 'TEST01',
}
Expand Down
11 changes: 7 additions & 4 deletions modules/growthCodeAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js';

const MODULE_NAME = 'growthCodeAnalytics';
const DEFAULT_PID = 'INVALID_PID'
const ENDPOINT_URL = 'https://p2.gcprivacy.com/v1/pb/analytics'
const ENDPOINT_URL = 'https://p2.gcprivacy.com/v3/pb/analytics'

export const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_NAME});

Expand Down Expand Up @@ -138,12 +138,15 @@ growthCodeAnalyticsAdapter.enableAnalytics = function(conf = {}) {

function logToServer() {
if (pid === DEFAULT_PID) return;
if (eventQueue.length > 1) {
if (eventQueue.length >= 1) {
// Get the correct GCID
let gcid = localStorage.getItem('gcid')

let data = {
session: sessionId,
pid: pid,
gcid: gcid,
timestamp: Date.now(),
timezoneoffset: new Date().getTimezoneOffset(),
url: getRefererInfo().page,
referer: document.referrer,
events: eventQueue
Expand All @@ -167,7 +170,7 @@ function sendEvent(event) {
eventQueue.push(event);
logInfo(MODULE_NAME + 'Analytics Event: ' + event);

if (event.eventType === CONSTANTS.EVENTS.AUCTION_END) {
if ((event.eventType === CONSTANTS.EVENTS.AUCTION_END) || (event.eventType === CONSTANTS.EVENTS.BID_WON)) {
logToServer();
}
}
Expand Down
8 changes: 1 addition & 7 deletions modules/growthCodeAnalyticsAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ pbjs.enableAnalytics({
pid: '<Contact GrowthCode>',
trackEvents: [
'auctionEnd',
'bidAdjustment',
'bidTimeout',
'bidRequested',
'bidResponse',
'noBid',
'bidWon',
'bidderDone']
'bidWon']
}
});
```
Expand Down
1 change: 0 additions & 1 deletion test/spec/modules/growthCodeAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('growthCode analytics adapter', () => {
var eventTypes = [];
body.events.forEach(e => eventTypes.push(e.eventType));
assert(eventTypes.length > 0)
assert(eventTypes.indexOf(constants.EVENTS.AUCTION_END) > -1);
growthCodeAnalyticsAdapter.disableAnalytics();
});
});

0 comments on commit a4218f1

Please sign in to comment.