-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add appVersion configuration option to track a context entity with th…
…e application version
- Loading branch information
1 parent
967733d
commit 97d05cd
Showing
7 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...on/changes/@snowplow/browser-tracker-core/issue-application_context_2024-11-08-11-09.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@snowplow/browser-tracker-core", | ||
"comment": "Add appVersion configuration option to track a context entity with the application version", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@snowplow/browser-tracker-core" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const WEB_PAGE_SCHEMA = 'iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0'; | ||
export const BROWSER_CONTEXT_SCHEMA = 'iglu:com.snowplowanalytics.snowplow/browser_context/jsonschema/2-0-0'; | ||
export const CLIENT_SESSION_SCHEMA = 'iglu:com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-2'; | ||
export const APPLICATION_CONTEXT_SCHEMA = 'iglu:com.snowplowanalytics.snowplow/application/jsonschema/1-0-0'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
libraries/browser-tracker-core/test/tracker/application_context.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { APPLICATION_CONTEXT_SCHEMA } from '../../src/tracker/schemata'; | ||
import { createTracker } from '../helpers'; | ||
|
||
describe('Application context:', () => { | ||
it('Adds the entity when the appVersion option is configured', (done) => { | ||
const tracker = createTracker({ | ||
appVersion: '1.0.2-beta.2', | ||
plugins: [ | ||
{ | ||
filter: (payload) => { | ||
const { data: payloadData } = JSON.parse(payload.co as string); | ||
const appContext = payloadData.find((context: any) => context.schema.match(APPLICATION_CONTEXT_SCHEMA)); | ||
expect(appContext).toBeTruthy(); | ||
expect(appContext.data.version).toBe('1.0.2-beta.2'); | ||
done(); | ||
return false; | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
tracker?.trackPageView(); | ||
}); | ||
|
||
it('Does not attach the entity if not configured', (done) => { | ||
const tracker = createTracker({ | ||
plugins: [ | ||
{ | ||
filter: (payload) => { | ||
const { data: payloadData } = JSON.parse(payload.co as string); | ||
const applicationContext = payloadData.find((context: any) => | ||
context.schema.match(APPLICATION_CONTEXT_SCHEMA) | ||
); | ||
expect(applicationContext).toBeUndefined(); | ||
done(); | ||
return false | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
tracker?.trackPageView(); | ||
}); | ||
}); |