diff --git a/plugins/browser-plugin-webview/src/index.ts b/plugins/browser-plugin-webview/src/index.ts index d69d687d0..0e971cf0c 100644 --- a/plugins/browser-plugin-webview/src/index.ts +++ b/plugins/browser-plugin-webview/src/index.ts @@ -4,7 +4,8 @@ import { Logger, SelfDescribingEvent, SelfDescribingJson } from '@snowplow/track import { base64urldecode } from './utils'; type WebViewPluginOptions = { - /** Provide a list of tracker namespaces to forward events to. + /** + * Provide a list of tracker namespaces to forward events to. * By default, the events will be forwarded to the default mobile tracker. */ trackerNamespaces?: string[]; @@ -59,10 +60,10 @@ export function WebViewPlugin(configuration?: WebViewPluginOptions): BrowserPlug function getSelfDescribingEventData(payload: Payload): SelfDescribingEvent | undefined { if (payload.ue_pr) { - return JSON.parse(payload.ue_pr as string); + return JSON.parse(payload.ue_pr as string).data; } else if (payload.ue_px) { let decoded = base64urldecode(payload.ue_px as string); - return JSON.parse(decoded); + return JSON.parse(decoded).data; } return undefined; } diff --git a/plugins/browser-plugin-webview/test/webview.test.ts b/plugins/browser-plugin-webview/test/webview.test.ts index 495068b04..66708fb8d 100644 --- a/plugins/browser-plugin-webview/test/webview.test.ts +++ b/plugins/browser-plugin-webview/test/webview.test.ts @@ -108,11 +108,8 @@ describe('WebView plugin', () => { maxYOffset: undefined, }, event: { - schema: 'iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0', - data: { - schema: 'iglu:com.snowplowanalytics.snowplow.media/play_event/jsonschema/1-0-0', - data: { a: 'b' }, - }, + schema: 'iglu:com.snowplowanalytics.snowplow.media/play_event/jsonschema/1-0-0', + data: { a: 'b' }, }, context: [ { @@ -170,11 +167,8 @@ describe('WebView plugin', () => { url: expect.any(String), }, event: { - schema: 'iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0', - data: { - schema: 'iglu:com.snowplowanalytics.snowplow/example/jsonschema/1-0-0', - data: { hello: 'world' }, - }, + schema: 'iglu:com.snowplowanalytics.snowplow/example/jsonschema/1-0-0', + data: { hello: 'world' }, }, context: [ {