-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tracking for clicking on push notifications with actions (#518)
- Loading branch information
Showing
12 changed files
with
235 additions
and
24 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
apps/platform/db/migrations/20241012155809_add_push_link_wrapping.js
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,13 @@ | ||
exports.up = async function(knex) { | ||
await knex.schema.table('projects', function(table) { | ||
table.renameColumn('link_wrap', 'link_wrap_email') | ||
table.boolean('link_wrap_push').defaultTo(0) | ||
}) | ||
} | ||
|
||
exports.down = async function(knex) { | ||
await knex.schema.table('projects', function(table) { | ||
table.renameColumn('link_wrap_email', 'link_wrap') | ||
table.dropColumn('link_wrap_push') | ||
}) | ||
} |
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
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
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,128 @@ | ||
import { Variables } from '..' | ||
import Project from '../../projects/Project' | ||
import { User } from '../../users/User' | ||
import { EmailTemplate, PushTemplate } from '../Template' | ||
|
||
describe('Template', () => { | ||
describe('compile email', () => { | ||
test('link wrap enabled', async () => { | ||
const url = 'https://google.com' | ||
const template = EmailTemplate.fromJson({ | ||
type: 'email', | ||
data: { | ||
from: 'from', | ||
subject: 'subject', | ||
html: `<html><body><a href="${url}">link</a></body></html>`, | ||
}, | ||
}) | ||
const variables: Variables = { | ||
project: Project.fromJson({ | ||
link_wrap_email: true, | ||
}), | ||
user: User.fromJson({ id: 1 }), | ||
context: { | ||
template_id: 1, | ||
campaign_id: 1, | ||
reference_id: '1', | ||
subscription_id: 1, | ||
reference_type: 'type', | ||
}, | ||
} | ||
const compiled = template.compile(variables) | ||
expect(compiled).toMatchSnapshot() | ||
}) | ||
|
||
test('link wrap disabled', async () => { | ||
const url = 'https://google.com' | ||
const template = EmailTemplate.fromJson({ | ||
type: 'email', | ||
data: { | ||
from: 'from', | ||
subject: 'subject', | ||
html: `<html><body><a href="${url}">link</a></body></html>`, | ||
}, | ||
}) | ||
const variables: Variables = { | ||
project: Project.fromJson({ | ||
link_wrap_email: false, | ||
}), | ||
user: User.fromJson({ id: 1 }), | ||
context: { | ||
template_id: 1, | ||
campaign_id: 1, | ||
reference_id: '1', | ||
subscription_id: 1, | ||
reference_type: 'type', | ||
}, | ||
} | ||
const compiled = template.compile(variables) | ||
expect(compiled).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('compile push', () => { | ||
test('link wrap disabled', async () => { | ||
const url = 'https://google.com' | ||
const template = PushTemplate.fromJson({ | ||
type: 'push', | ||
data: { | ||
title: 'title', | ||
topic: 'topic', | ||
body: 'body', | ||
url, | ||
custom: { | ||
key: 'value', | ||
}, | ||
}, | ||
}) | ||
const variables: Variables = { | ||
project: Project.fromJson({ | ||
link_wrap_push: false, | ||
}), | ||
user: User.fromJson({ id: 1 }), | ||
context: { | ||
template_id: 1, | ||
campaign_id: 1, | ||
reference_id: '1', | ||
subscription_id: 1, | ||
reference_type: 'type', | ||
}, | ||
} | ||
const compiled = template.compile(variables) | ||
expect(compiled).toMatchSnapshot() | ||
expect(compiled.custom.url).toBe(url) | ||
}) | ||
|
||
test('link wrap enabled', async () => { | ||
const url = 'https://google.com' | ||
const template = PushTemplate.fromJson({ | ||
type: 'push', | ||
data: { | ||
title: 'title', | ||
topic: 'topic', | ||
body: 'body', | ||
url, | ||
custom: { | ||
key: 'value', | ||
}, | ||
}, | ||
}) | ||
const variables: Variables = { | ||
project: Project.fromJson({ | ||
link_wrap_push: true, | ||
}), | ||
user: User.fromJson({ id: 1 }), | ||
context: { | ||
template_id: 1, | ||
campaign_id: 1, | ||
reference_id: '1', | ||
subscription_id: 1, | ||
reference_type: 'type', | ||
}, | ||
} | ||
const compiled = template.compile(variables) | ||
expect(compiled).toMatchSnapshot() | ||
expect(compiled.custom.url).not.toBe(url) | ||
}) | ||
}) | ||
}) |
43 changes: 43 additions & 0 deletions
43
apps/platform/src/render/__tests__/__snapshots__/Template.spec.ts.snap
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,43 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Template compile email link wrap disabled 1`] = ` | ||
Object { | ||
"from": "from", | ||
"html": "<html><body><a href=\\"https://google.com\\">link</a><img border=\\"0\\" width=\\"1\\" height=\\"1\\" alt=\\"\\" src=\\"https://parcelvoy.com/o?u=M8LRMWZ645&c=M8LRMWZ645&s=1\\" /></body></html>", | ||
"subject": "subject", | ||
"text": "link [https://google.com]", | ||
} | ||
`; | ||
|
||
exports[`Template compile email link wrap enabled 1`] = ` | ||
Object { | ||
"from": "from", | ||
"html": "<html><body><a href=\\"https://parcelvoy.com/c?u=M8LRMWZ645&c=M8LRMWZ645&s=1&r=https%253A%252F%252Fgoogle.com\\">link</a><img border=\\"0\\" width=\\"1\\" height=\\"1\\" alt=\\"\\" src=\\"https://parcelvoy.com/o?u=M8LRMWZ645&c=M8LRMWZ645&s=1\\" /></body></html>", | ||
"subject": "subject", | ||
"text": "link [https://google.com]", | ||
} | ||
`; | ||
|
||
exports[`Template compile push link wrap disabled 1`] = ` | ||
Object { | ||
"body": "body", | ||
"custom": Object { | ||
"key": "value", | ||
"url": "https://google.com", | ||
}, | ||
"title": "title", | ||
"topic": "topic", | ||
} | ||
`; | ||
|
||
exports[`Template compile push link wrap enabled 1`] = ` | ||
Object { | ||
"body": "body", | ||
"custom": Object { | ||
"key": "value", | ||
"url": "https://parcelvoy.com/c?u=M8LRMWZ645&c=M8LRMWZ645&s=1&r=https%253A%252F%252Fgoogle.com", | ||
}, | ||
"title": "title", | ||
"topic": "topic", | ||
} | ||
`; |
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
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
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