Skip to content

Commit

Permalink
6.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
piano-analytics committed Oct 10, 2024
1 parent 221bcb5 commit 18abf2d
Show file tree
Hide file tree
Showing 24 changed files with 638 additions and 452 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# Changelog
## 6.15.0
### New
- [browser] New AV Insights method (`media.playbackKill`) to technically stop a playback session
- [browser] `browserId` can now be set from `pdl`
- [browser] Cookie testing (`_cookie_test`) skipped when cookie domain configured

### Fixes
- [browser] Fixed empty campaign parameters sent with `undefined` value
- [browser] Fixed an issue with empty cookie domain when none configured
- [browser] Manage case where `PA` is not part of `consent.products`

### Changes
- [dev] Configuration file does not contain the version by default. Version is now added during build

## 6.14.2
### Fixes
- [react-native] Fixed android user-agent value to prevent default processing exclusion
Expand Down
14 changes: 13 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs');
"use strict";

module.exports = function (grunt) {
Expand Down Expand Up @@ -26,11 +27,22 @@ module.exports = function (grunt) {
},
concat: {
es5polyfills: {
src: ['polyfills/core-js-bundle-3.6.5.min.js', 'dist/browser/piano-analytics.es5.js'],
src: ['polyfills/core-js-bundle-3.6.4.min.js', 'dist/browser/piano-analytics.es5.js'],
dest: 'dist/browser/piano-analytics.es5.js',
},
},
});
grunt.registerTask('get-version', 'Copy version to the configuration', function() {
try {
const packageJsonVersion = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
let configFile = fs.readFileSync('./src/config.js', 'utf8');
configFile = configFile.replace(/'version': '.*'/,`'version': '${packageJsonVersion}'`);
fs.writeFileSync('./src/config.js', configFile);
} catch (err) {
console.error(err);
process.exit(1);
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
};
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "piano-analytics-js",
"description": "JavaScript library for Piano Analytics",
"version": "6.14.2",
"version": "6.15.0",
"main": "dist/browserless/piano-analytics.cjs.js",
"module": "dist/browserless/piano-analytics.esm.js",
"browser": "dist/browser/piano-analytics.umd.js",
Expand All @@ -26,26 +26,26 @@
"prebuild:node": "grunt copy:http-node",
"prebuild:react-native": "grunt copy:http-react-native",
"clean": "grunt copy:http-clean",
"rollup:browser": "npm run prebuild:browser && rollup --config rollup.config-browser.js && npm run clean",
"rollup:browser-es5": "npm run prebuild:browser-es5 && rollup --config rollup.config-browser-es5.js && grunt concat:es5polyfills && npm run clean",
"rollup:node": "npm run prebuild:node && rollup --config rollup.config-node.js && npm run clean",
"rollup:react-native": "npm run prebuild:react-native && rollup --config rollup.config-react-native.js && npm run clean",
"rollup:browser": "grunt get-version && npm run prebuild:browser && rollup --config rollup.config-browser.js && npm run clean",
"rollup:browser-es5": "grunt get-version && npm run prebuild:browser-es5 && rollup --config rollup.config-browser-es5.js && grunt concat:es5polyfills && npm run clean",
"rollup:node": "grunt get-version && npm run prebuild:node && rollup --config rollup.config-node.js && npm run clean",
"rollup:react-native": "grunt get-version && npm run prebuild:react-native && rollup --config rollup.config-react-native.js && npm run clean",
"build": "npm run rollup:browser --omit=dev && npm run rollup:browser-es5 --omit=dev && npm run rollup:node --omit=dev && npm run rollup:react-native --omit=dev",
"test": "npm run test:browser && npm run test:browser-es5 && npm run test:node",
"test:browser": "npm run rollup:browser && karma start",
"test:browser-es5": "npm run rollup:browser-es5 && karma start ./karma.conf.es5.js",
"test:node": "npm run rollup:node && node test/node.run.js"
},
"devDependencies": {
"@babel/core": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/core": "7.24.9",
"@babel/preset-env": "7.24.8",
"@rollup/plugin-babel": "6.0.4",
"chai": "4.3.8",
"eslint": "9.5.0",
"eslint": "8.57.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.2.0",
"eslint-plugin-promise": "7.0.0",
"grunt": "1.6.1",
"grunt-contrib-concat": "^2.1.0",
"grunt-contrib-copy": "^1.0.0",
Expand All @@ -54,8 +54,8 @@
"karma-chrome-launcher": "3.2.0",
"karma-mocha": "2.0.1",
"load-grunt-tasks": "5.1.0",
"mocha": "10.4.0",
"puppeteer": "22.11.2",
"mocha": "10.7.0",
"puppeteer": "22.14.0",
"rollup": "2.79.1",
"rollup-plugin-eslint": "7.0.0",
"rollup-plugin-replace": "2.2.0",
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions src/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"business/ext/storage/storage.js",
"business/ext/data-layer/data-layer.js",
"business/ext/consent/consent.js",
"business/privacy/privacy.js",
"business/privacy/privacy-template.js",
"business/avinsights.js",
"utils/request/http.js",
"utils/request/http-templates.js"
Expand Down
11 changes: 11 additions & 0 deletions src/business/avinsights.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,17 @@ const AVInsights = function (pa) {
_resetSession();

};
_thisMedia.playbackKill = function () {
_timers.initBaseTime();
_context.isPlaying = false;
_context.isPlaybackActivated = false;
_timers.stopHeartbeatTimer(false);
_timers.stopHeartbeatTimer(true);
_timers.resetProperties();
_restoreDelayConfiguration(false);
_restoreDelayConfiguration(true);
_resetSession();
};
_thisMedia.seek = function (oldCursorPosition, newCursorPosition, eventOptions, extraProps) {

const processedOldPosition = _utility.value2Number(oldCursorPosition);
Expand Down
46 changes: 46 additions & 0 deletions src/business/content-properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import dataLayer from './ext/data-layer/data-layer';

const MAP_DL_PA = [
['createdAt', 'content_publication_date'],
['tags', 'tags_array']
];

function processContentProperties(model) {
const content = dataLayer.get('content');
for (const propContent in content) {
if (Object.prototype.hasOwnProperty.call(content, propContent)) {
// searching for a DL property name and replacing it with its PA name
const datalayerPropFoundResult = MAP_DL_PA.find((items) => items[0] === propContent);
const propFinalName = datalayerPropFoundResult ? datalayerPropFoundResult[1] : _camelToSnake(`content_${propContent}`);
model.addEventsProperty(propFinalName, content[propContent]);
}
}
}

function initContentProperties(pa) {
pa.setContentProperty = function (name, value) {
// searching for a PA property name and replacing it with its DL name
const pianoAnalyticsPropFound = MAP_DL_PA.find((items) => items[1] === name);
dataLayer.set('content', {
[pianoAnalyticsPropFound ? pianoAnalyticsPropFound[0] : name]: value
});
};
pa.setContentProperties = function (content) {
for (const prop in content) {
if (Object.prototype.hasOwnProperty.call(content, prop)) {
pa.setContentProperty(prop, content[prop]);
}
}
};
}

function _camelToSnake(string) {
return string.replace(/[\w]([A-Z])/g, function (m) {
return m[0] + '_' + m[1];
}).toLowerCase();
}

export {
processContentProperties,
initContentProperties
};
12 changes: 8 additions & 4 deletions src/business/ext/consent/consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ var createBaseConsentStorage = function createBaseConsentStorage(storage2, itemT
var checkProperty = createCheckConsentWrapper(config.dataLayer, {
items: config.items,
type: itemType,
getConsent: getConsent
getConsent: getConsent,
product: config.productName
});
var _init = function _init() {
var removeOnInit = config.checkConsentOnInit === void 0 ? config.enableAutoRemove : false;
Expand Down Expand Up @@ -85,7 +86,8 @@ var createTTLChecker = function createTTLChecker(dataLayer) {
var checker = createCheckConsentWrapper(config.dataLayer, {
items: (_a = {}, _a[name] = "mandatory", _a),
type: "localStorage",
getConsent: createConsentWrapper(config)
getConsent: createConsentWrapper(config),
product: config.productName
});
return function () {
var result = checker(name);
Expand Down Expand Up @@ -158,7 +160,8 @@ var createCookie = function createCookie(config) {
var checkProperty = createCheckConsentWrapper(config.dataLayer, {
items: items,
type: ITEM_TYPE,
getConsent: getConsent
getConsent: getConsent,
product: config.productName
});
var _init = function _init() {
var removeOnInit = !!(config.checkConsentOnInit === void 0 ? config.enableAutoRemove : false);
Expand Down Expand Up @@ -205,7 +208,8 @@ var createBasePropertyWrapper = function createBasePropertyWrapper(itemType, con
check: createCheckConsentWrapper(config.dataLayer, {
items: config.items,
type: itemType,
getConsent: createConsentWrapper(config)
getConsent: createConsentWrapper(config),
product: config.productName
})
};
};
Expand Down
Loading

0 comments on commit 18abf2d

Please sign in to comment.