Skip to content

Commit

Permalink
Merge pull request #335 from sandeep-vedam/feature/splitsdk
Browse files Browse the repository at this point in the history
Feature/splitsdk
  • Loading branch information
michielvandergeest authored Aug 19, 2022
2 parents f7e65c6 + 147bc5e commit ecadc01
Show file tree
Hide file tree
Showing 19 changed files with 2,059 additions and 3,396 deletions.
3,697 changes: 2,028 additions & 1,669 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"@babel/polyfill": "^7.11.5",
"@lightningjs/core": "*",
"@metrological/sdk": "github:metrological/metrological-sdk",
"@michieljs/execute-as-promise": "^1.0.0",
"deepmerge": "^4.2.2",
"localCookie": "github:WebPlatformForEmbedded/localCookie",
Expand Down
2 changes: 1 addition & 1 deletion src/Ads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import Log from '../Log'
import { mediaUrl } from '../VideoPlayer'
import { mediaUrl } from '@metrological/sdk'

let consumer

Expand Down
2 changes: 1 addition & 1 deletion src/Img/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default (imageUrl, options) => {
)
} else {
// Lightning will handle the resizing and has only 2 flavours (cover and contain)
if(options.type!=='cover') {
if (options.type !== 'cover') {
if (options.type === 'crop') options.type = 'cover'
else options.type = 'contain'
}
Expand Down
23 changes: 13 additions & 10 deletions src/Launch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,30 @@
*/

import { initUtils } from '../Utils'
import { initProfile } from '../Profile'
import { initMetrics } from '../Metrics'
import { initProfile } from '@metrological/sdk'
import { initMetrics } from '@metrological/sdk'
import { initLightningSdkPlugin } from '@metrological/sdk'
import { initSettings } from '../Settings'
import { initMediaPlayer } from '../MediaPlayer'
import { initVideoPlayer } from '../VideoPlayer'
import { initVideoPlayer } from '@metrological/sdk'
import { initStorage } from '../Storage'
import { initAds } from '../Ads'
import { initRouter } from '../Router'
import { initTV } from '../TV'
import { initPurchase } from '../Purchase'
import { initPin } from '../Pin'
import { initMetadata } from '../Metadata'
import { initTV } from '@metrological/sdk'
import { initPurchase } from '@metrological/sdk'
import { initPin } from '@metrological/sdk'
import { initMetadata } from '@metrological/sdk'
import Application from '../Application'
import Settings from '../Settings'
import Log from '../Log'
import Ads from '../Ads'

export let ApplicationInstance

export default (App, appSettings, platformSettings, appData) => {
initSettings(appSettings, platformSettings)
initMetadata(appSettings)

initUtils(platformSettings)
initMetadata(appSettings)
initStorage()
// Initialize plugins
if (platformSettings.plugins) {
Expand All @@ -52,8 +55,8 @@ export default (App, appSettings, platformSettings, appData) => {
platformSettings.plugins.purchase && initPurchase(platformSettings.plugins.purchase)
platformSettings.plugins.pin && initPin(platformSettings.plugins.pin)
}

const app = Application(App, appData, platformSettings)
ApplicationInstance = new app(appSettings)
initLightningSdkPlugin(ApplicationInstance, Log, Settings, Ads)
return ApplicationInstance
}
30 changes: 2 additions & 28 deletions src/Metadata/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
let metadata = {}

export const initMetadata = metadataObj => {
metadata = metadataObj
}
import { Metadata } from '@metrological/sdk'

export default {
get(key, fallback = undefined) {
return key in metadata ? metadata[key] : fallback
},
appId() {
return this.get('id')
},
safeAppId() {
return this.get('id').replace(/[^0-9a-zA-Z_$]/g, '_')
},
appName() {
return this.get('name')
},
appVersion() {
return (this.get('version') || '').split('-').shift()
},
appIcon() {
return this.get('icon')
},
// Version from app store (with commit hash)
appFullVersion() {
return this.get('version')
},
}
export default Metadata
73 changes: 2 additions & 71 deletions src/Metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,75 +17,6 @@
* limitations under the License.
*/

import Log from '../Log'
import { Metrics } from '@metrological/sdk'

let sendMetric = (type, event, params) => {
Log.info('Sending metric', type, event, params)
}

export const initMetrics = config => {
sendMetric = config.sendMetric
}

// available metric per category
const metrics = {
app: ['launch', 'loaded', 'ready', 'close'],
page: ['view', 'leave'],
user: ['click', 'input'],
media: [
'abort',
'canplay',
'ended',
'pause',
'play',
// with some videos there occur almost constant suspend events ... should investigate
// 'suspend',
'volumechange',
'waiting',
'seeking',
'seeked',
],
}

// error metric function (added to each category)
const errorMetric = (type, message, code, visible, params = {}) => {
params = { params, ...{ message, code, visible } }
sendMetric(type, 'error', params)
}

const Metric = (type, events, options = {}) => {
return events.reduce(
(obj, event) => {
obj[event] = (name, params = {}) => {
params = { ...options, ...(name ? { name } : {}), ...params }
sendMetric(type, event, params)
}
return obj
},
{
error(message, code, params) {
errorMetric(type, message, code, params)
},
event(name, params) {
sendMetric(type, name, params)
},
}
)
}

const Metrics = types => {
return Object.keys(types).reduce(
(obj, type) => {
// media metric works a bit different!
// it's a function that accepts a url and returns an object with the available metrics
// url is automatically passed as a param in every metric
type === 'media'
? (obj[type] = url => Metric(type, types[type], { url }))
: (obj[type] = Metric(type, types[type]))
return obj
},
{ error: errorMetric, event: sendMetric }
)
}

export default Metrics(metrics)
export default Metrics
207 changes: 0 additions & 207 deletions src/Pin/dialog.js

This file was deleted.

Loading

0 comments on commit ecadc01

Please sign in to comment.