-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(metrics): ✨ Adding patched analytics. #1232
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7b4d93d
feat(mv3): :sparkles: Patching countly-sdk-web
whizzzkid f3305fe
feat(mv3): :sparkles: Implementing Custom Async Store.
whizzzkid 83af58f
chore(mv3): :adhesive_bandage: Hooking everything up together.
whizzzkid d504c71
fix(mv3): Countly Patching + ignite-metrics@2.0.0
whizzzkid 4fab16a
fix(mv3): :adhesive_bandage: Patching the Patch
whizzzkid f02d6a2
fix: tests
whizzzkid dbab08c
fix: lint
whizzzkid 44653de
fix: :adhesive_bandage: Patching error messages
whizzzkid 64fcde7
fix(patch): countly-web-sdk
whizzzkid 66b13dc
fix(patch): :pin: Pinning countly-web-sdk to 23.2.2
whizzzkid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
40 changes: 40 additions & 0 deletions
40
add-on/src/lib/storage-provider/WebExtensionStorageProvider.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,40 @@ | ||
import type { consentTypes } from '@ipfs-shipyard/ignite-metrics/typings/countly' | ||
import type { StorageProviderInterface } from '@ipfs-shipyard/ignite-metrics/StorageProvider' | ||
import browser from 'webextension-polyfill' | ||
|
||
export class WebExtensionStorageProvider implements StorageProviderInterface { | ||
async setStore (consentArray: consentTypes[]): Promise<void> { | ||
try { | ||
const jsonString = JSON.stringify(consentArray) | ||
if ('localStorage' in globalThis) { | ||
globalThis.localStorage.setItem('@ipfs-shipyard/ignite-metrics:consent', jsonString) | ||
} else { | ||
await browser.storage.local.set({ '@ipfs-shipyard/ignite-metrics:consent': jsonString }) | ||
} | ||
} catch (err) { | ||
// eslint-disable-next-line no-console | ||
console.error(err) | ||
} | ||
} | ||
|
||
async getStore (): Promise<consentTypes[]> { | ||
try { | ||
let jsonString | ||
if ('localStorage' in globalThis) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
jsonString = globalThis.localStorage.getItem('@ipfs-shipyard/ignite-metrics:consent') | ||
} else { | ||
jsonString = (await browser.storage.local.get(['@ipfs-shipyard/ignite-metrics:consent']))['@ipfs-shipyard/ignite-metrics:consent'] | ||
} | ||
if (jsonString != null) { | ||
return JSON.parse(jsonString) | ||
} | ||
} catch (err) { | ||
// eslint-disable-next-line no-console | ||
console.error(err) | ||
} | ||
/** | ||
* Return minimal consent if there is nothing in the store. | ||
*/ | ||
return ['minimal'] | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wont this always be false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firefox will make this true :-( in their event listener pages.